From 4cbbee26e46216e70e31a83ba9feb88e1c4618b1 Mon Sep 17 00:00:00 2001 From: Hellow <74311245+HeIIow2@users.noreply.github.com> Date: Fri, 29 Dec 2023 16:15:54 +0100 Subject: [PATCH] fixed the merging of collections --- src/actual_donwload.py | 3 ++- src/music_kraken/cli/main_downloader.py | 7 +++---- src/music_kraken/download/results.py | 6 +----- src/music_kraken/objects/collection.py | 7 ++++--- src/music_kraken/objects/parents.py | 2 +- src/music_kraken/objects/song.py | 6 ++++++ 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/actual_donwload.py b/src/actual_donwload.py index 293fe33..1654f67 100644 --- a/src/actual_donwload.py +++ b/src/actual_donwload.py @@ -47,4 +47,5 @@ if __name__ == "__main__": ] - music_kraken.cli.download(genre="test", command_list=bandcamp_test, process_metadata_anyway=True) \ No newline at end of file + music_kraken.cli.download(genre="test", command_list=bandcamp_test, process_metadata_anyway=True) + _ = "debug" \ No newline at end of file diff --git a/src/music_kraken/cli/main_downloader.py b/src/music_kraken/cli/main_downloader.py index 4c5ced2..3958150 100644 --- a/src/music_kraken/cli/main_downloader.py +++ b/src/music_kraken/cli/main_downloader.py @@ -295,9 +295,6 @@ class Downloader: page: Type[Page] music_object: DatabaseObject - if self.current_results is not None: - self.current_results.delete_details(index) - try: page, music_object = self.current_results.get_music_object_by_index(index) except KeyError: @@ -307,7 +304,9 @@ class Downloader: return self.pages.fetch_details(music_object) - + + print(music_object) + print(music_object.options) self.set_current_options(PageResults(page, music_object.options)) self.print_current_options() diff --git a/src/music_kraken/download/results.py b/src/music_kraken/download/results.py index bbe63bb..c0dff08 100644 --- a/src/music_kraken/download/results.py +++ b/src/music_kraken/download/results.py @@ -29,11 +29,7 @@ class Results: def get_music_object_by_index(self, index: int) -> Tuple[Type[Page], DatabaseObject]: # if this throws a key error, either the formatted generator needs to be iterated, or the option doesn't exist. return self._page_by_index[index], self._by_index[index] - - def delete_details(self, exclude_index: int): - for index, music_object in self._by_index.items(): - if index == exclude_index: - continue + class SearchResults(Results): def __init__( diff --git a/src/music_kraken/objects/collection.py b/src/music_kraken/objects/collection.py index 519e4cc..9863989 100644 --- a/src/music_kraken/objects/collection.py +++ b/src/music_kraken/objects/collection.py @@ -107,8 +107,6 @@ class Collection(Generic[T]): if self._contained_in_self(__object): return [self] - print(len(self.children), id(self), ";".join(str(id(i)) for i in self.children)) - print() for collection in self.children: results.extend(collection._contained_in_sub(__object, break_at_first=break_at_first)) @@ -186,11 +184,11 @@ class Collection(Generic[T]): return len(self._contained_in_sub(__object)) > 0 def _append(self, __object: T, from_map: bool = False): + # print(self, __object) self._map_element(__object, from_map=from_map) self._data.append(__object) def append(self, __object: Optional[T], already_is_parent: bool = False, from_map: bool = False): - print(__object) if __object is None or __object.id in self._contains_ids: return @@ -264,3 +262,6 @@ class Collection(Generic[T]): def __iter__(self) -> Iterator[T]: for element in self._data: yield element + + def __merge__(self, __other: Collection, override: bool = False): + self.extend(__other.shallow_list) \ No newline at end of file diff --git a/src/music_kraken/objects/parents.py b/src/music_kraken/objects/parents.py index 42172f3..572ad9a 100644 --- a/src/music_kraken/objects/parents.py +++ b/src/music_kraken/objects/parents.py @@ -47,7 +47,7 @@ class InnerData: # if the object of value implemented __merge__, it merges existing = self.__getattribute__(key) if hasattr(type(existing), "__merge__"): - existing.merge_into_self(value, override) + existing.__merge__(value, override) continue # override the existing value if requested diff --git a/src/music_kraken/objects/song.py b/src/music_kraken/objects/song.py index 2d54aa3..3dfc982 100644 --- a/src/music_kraken/objects/song.py +++ b/src/music_kraken/objects/song.py @@ -446,6 +446,12 @@ class Artist(Base): "current_artist_collection": self } + @property + def options(self) -> List[P]: + options = [self, *self.main_album_collection.shallow_list, *self.feature_album] + print(options) + return options + def update_albumsort(self): """ This updates the albumsort attributes, of the albums in