diff --git a/development/actual_donwload.py b/development/actual_donwload.py index 4b242ed..76cc2a3 100644 --- a/development/actual_donwload.py +++ b/development/actual_donwload.py @@ -6,8 +6,8 @@ logging.getLogger().setLevel(logging.DEBUG) if __name__ == "__main__": commands = [ - "s: #a Toxoplasma", - "d: 16", + "s: #a And End...", + "d: 10", ] diff --git a/development/objects_collection.py b/development/objects_collection.py index 46895bc..9e147f5 100644 --- a/development/objects_collection.py +++ b/development/objects_collection.py @@ -30,6 +30,37 @@ if __name__ == "__main__": ] ) + + other_artist: Artist = Artist( + name="artist", + main_album_list=[ + Album( + title="album", + song_list=[ + Song( + title="song", + album_list=[ + Album( + title="album", + albumsort=123, + main_artist=Artist(name="other_artist"), + ), + ], + ), + Song( + title="other_song", + album_list=[ + Album(title="album", albumsort=423), + ], + ), + ] + ), + Album(title="album", barcode="1234567890123"), + ] + ) + + artist.merge(other_artist) + a = artist.main_album_collection[0] b = a.song_collection[0].album_collection[0] c = a.song_collection[1].album_collection[0] diff --git a/music_kraken/__init__.py b/music_kraken/__init__.py index 73dbbf1..7697a3b 100644 --- a/music_kraken/__init__.py +++ b/music_kraken/__init__.py @@ -46,7 +46,7 @@ init_logging() from . import cli if DEBUG: - sys.setrecursionlimit(100) + sys.setrecursionlimit(500) if main_settings['modify_gc']: diff --git a/music_kraken/objects/lyrics.py b/music_kraken/objects/lyrics.py index 3650bfa..09f7a3a 100644 --- a/music_kraken/objects/lyrics.py +++ b/music_kraken/objects/lyrics.py @@ -34,6 +34,6 @@ class Lyrics(OuterProxy): @property def metadata(self) -> Metadata: return Metadata({ - id3Mapping.UNSYNCED_LYRICS: self.text.html + id3Mapping.UNSYNCED_LYRICS: [self.text.html] }) diff --git a/music_kraken/objects/parents.py b/music_kraken/objects/parents.py index 93bb3a9..6385a2d 100644 --- a/music_kraken/objects/parents.py +++ b/music_kraken/objects/parents.py @@ -7,7 +7,7 @@ from functools import lru_cache from typing import Optional, Dict, Tuple, List, Type, Generic, Any, TypeVar, Set from .metadata import Metadata -from ..utils import get_unix_time +from ..utils import get_unix_time, object_trace from ..utils.config import logging_settings, main_settings from ..utils.shared import HIGHEST_ID from ..utils.hacking import MetaClass @@ -107,6 +107,7 @@ class OuterProxy: self._inner: InnerData = InnerData(type(self), **kwargs) self._inner._refers_to_instances.add(self) + object_trace(f"creating {type(self).__name__} [{self.title_string}]") self.__init_collections__() for name, data_list in collection_data.items(): @@ -182,6 +183,8 @@ class OuterProxy: if __other is None: return + object_trace(f"merging {type(self).__name__} [{self.title_string}] with {type(__other).__name__} [{__other.title_string}]") + a = self b = __other diff --git a/music_kraken/objects/source.py b/music_kraken/objects/source.py index 3a1fec4..5a8a560 100644 --- a/music_kraken/objects/source.py +++ b/music_kraken/objects/source.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from collections import defaultdict from enum import Enum from typing import List, Dict, Set, Tuple, Optional, Iterable @@ -103,12 +105,23 @@ class Source(OuterProxy): ('audio_url', self.audio_url), ] + def __merge__(self, __other: Source, override: bool = False): + if override: + self.audio_url = __other.audio_url + + if self.audio_url is None or (override and __other.audio_url is not None): + self.audio_url = __other.audio_url + def __str__(self): return self.__repr__() def __repr__(self) -> str: return f"Src({self.page_enum.value}: {self.url}, {self.audio_url})" + @property + def title_string(self) -> str: + return self.url + page_str = property(fget=lambda self: self.page_enum.value) type_str = property(fget=lambda self: self.type_enum.value) homepage = property(fget=lambda self: SourcePages.get_homepage(self.page_enum)) diff --git a/music_kraken/utils/__init__.py b/music_kraken/utils/__init__.py index 6b4754e..67fcd7d 100644 --- a/music_kraken/utils/__init__.py +++ b/music_kraken/utils/__init__.py @@ -52,6 +52,12 @@ def trace(msg: str): output("trace: " + msg, BColors.OKBLUE) +def object_trace(obj): + if not DEBUG_TRACE: + return + + output("object: " + str(obj), BColors.GREY) + """ misc functions diff --git a/music_kraken/utils/shared.py b/music_kraken/utils/shared.py index cf3cda7..b3f30e5 100644 --- a/music_kraken/utils/shared.py +++ b/music_kraken/utils/shared.py @@ -15,6 +15,7 @@ __stage__ = os.getenv("STAGE", "prod") DEBUG = (__stage__ == "dev") and True DEBUG_LOGGING = DEBUG and False DEBUG_TRACE = DEBUG and True +DEBUG_OBJECT_TRACE = DEBUG and False DEBUG_YOUTUBE_INITIALIZING = DEBUG and False DEBUG_PAGES = DEBUG and False DEBUG_DUMP = DEBUG and True