diff --git a/src/actual_donwload.py b/src/actual_donwload.py index 5c3cb71..b6fb29b 100644 --- a/src/actual_donwload.py +++ b/src/actual_donwload.py @@ -53,7 +53,10 @@ def real_download(): if __name__ == "__main__": music_kraken.cli(genre="test", command_list=[ - "https://musify.club/release/molchat-doma-etazhi-2018-1092949", + # "https://musify.club/release/molchat-doma-etazhi-2018-1092949", # "https://musify.club/release/ghost-bath-self-loather-2021-1554266", + "#a Ghost Bath", + "0", + "4", "ok" ]) diff --git a/src/music_kraken/__init__.py b/src/music_kraken/__init__.py index f4debe2..3e6d260 100644 --- a/src/music_kraken/__init__.py +++ b/src/music_kraken/__init__.py @@ -13,6 +13,8 @@ from .utils.shared import MUSIC_DIR, MODIFY_GC, NOT_A_GENRE_REGEX, get_random_me from .utils.string_processing import fit_to_file_system +import sys; sys.setrecursionlimit(100) + if MODIFY_GC: """ At the start I modify the garbage collector to run a bit fewer times. diff --git a/src/music_kraken/pages/abstract.py b/src/music_kraken/pages/abstract.py index cd29db3..33140db 100644 --- a/src/music_kraken/pages/abstract.py +++ b/src/music_kraken/pages/abstract.py @@ -75,9 +75,8 @@ def _clean_song(song: Song, collections: Dict[INDEPENDENT_DB_TYPES, Collection]) _clean_collection(song.feature_artist_collection, collections) _clean_collection(song.main_artist_collection, collections) - -def post_process_object(database_object: DatabaseObject, clean_up: bool = True) -> DatabaseObject: - if isinstance(database_object, INDEPENDENT_DB_OBJECTS) and clean_up: +def clean_object(dirty_object: DatabaseObject) -> DatabaseObject: + if isinstance(dirty_object, INDEPENDENT_DB_OBJECTS): collections = { Label: Collection(element_type=Label), Artist: Collection(element_type=Artist), @@ -85,10 +84,21 @@ def post_process_object(database_object: DatabaseObject, clean_up: bool = True) Song: Collection(element_type=Song) } - _clean_music_object(database_object, collections) + return _clean_music_object(dirty_object, collections) + +def build_new_object(new_object: DatabaseObject) -> DatabaseObject: + new_object = clean_object(new_object) + new_object.compile(merge_into=False) + + return new_object - database_object.compile(merge_into=True) - return database_object +def merge_together(old_object: DatabaseObject, new_object: DatabaseObject) -> DatabaseObject: + new_object = clean_object(new_object) + + old_object.merge(new_object) + old_object.compile(merge_into=False) + + return old_object class Page(threading.Thread): @@ -177,12 +187,7 @@ class Page(threading.Thread): new_music_object.merge( self.fetch_object_from_source(source=source, enforce_type=type(music_object), stop_at_level=stop_at_level, post_process=False)) - new_music_object = post_process_object(new_music_object) - - music_object.merge(new_music_object) - music_object.compile(merge_into=True) - - return music_object + return merge_together(music_object, new_music_object) def fetch_object_from_source(self, source: Source, stop_at_level: int = 2, enforce_type: Type[DatabaseObject] = None, post_process: bool = True) -> Optional[DatabaseObject]: obj_type = self.get_source_type(source) @@ -204,9 +209,12 @@ class Page(threading.Thread): if obj_type in fetch_map: music_object = fetch_map[obj_type](source, stop_at_level) + else: + self.LOGGER.warning(f"Can't fetch details of type: {obj_type}") + return None - if post_process and music_object is not None: - return post_process_object(music_object) + if post_process and music_object: + return build_new_object(music_object) return music_object