diff --git a/src/music_kraken/objects/collection.py b/src/music_kraken/objects/collection.py index 9863989..7bf4b6c 100644 --- a/src/music_kraken/objects/collection.py +++ b/src/music_kraken/objects/collection.py @@ -184,7 +184,7 @@ class Collection(Generic[T]): return len(self._contained_in_sub(__object)) > 0 def _append(self, __object: T, from_map: bool = False): - # print(self, __object) + print(self, __object) self._map_element(__object, from_map=from_map) self._data.append(__object) @@ -264,4 +264,5 @@ class Collection(Generic[T]): yield element def __merge__(self, __other: Collection, override: bool = False): + print(__other) 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 572ad9a..77630a9 100644 --- a/src/music_kraken/objects/parents.py +++ b/src/music_kraken/objects/parents.py @@ -38,7 +38,7 @@ class InnerData: :return: """ - for key, value in __other.__dict__.items(): + for key, value in __other.__dict__.copy().items(): # just set the other value if self doesn't already have it if key not in self.__dict__: self.__setattr__(key, value) @@ -78,20 +78,25 @@ class OuterProxy: kwargs["dynamic"] = dynamic for name, factory in type(self)._default_factories.items(): - if name not in kwargs: + if kwargs.get(name, None) is None: kwargs[name] = factory() + collection_data: Dict[str, list] = {} + for name, value in kwargs.copy().items(): + if isinstance(value, list) and name.endswith("_list"): + collection_name = name.replace("_list", "_collection") + collection_data[collection_name] = value + + del kwargs[name] + self._inner: InnerData = InnerData(**kwargs) self.__init_collections__() - for name, data_list in kwargs.items(): - if isinstance(data_list, list) and name.endswith("_list"): - collection_name = name.replace("_list", "_collection") + for name, data_list in collection_data.items(): + collection = self._inner.__getattribute__(name) + collection.extend(data_list) - collection = self._inner.__getattribute__(collection_name) - collection.extend(data_list) - - self._inner.__setattr__(collection_name, collection) + self._inner.__setattr__(name, collection) def __init_collections__(self): pass @@ -106,7 +111,7 @@ class OuterProxy: :return: """ - if __name.startswith("__"): + if __name.startswith("_"): return super().__getattribute__(__name) _inner: InnerData = super().__getattribute__("_inner") diff --git a/src/music_kraken/objects/song.py b/src/music_kraken/objects/song.py index b8772b0..d48dd1f 100644 --- a/src/music_kraken/objects/song.py +++ b/src/music_kraken/objects/song.py @@ -61,15 +61,18 @@ class Song(Base): "album_collection": Collection, "feature_artist_collection": Collection, + "title": lambda: None, "unified_title": lambda: None, "isrc": lambda: None, "genre": lambda: None, } - def __init__(self, title: str, unified_title: str = None, isrc: str = None, length: int = None, genre: str = None, - note: FormattedText = None, source_list: SourceCollection = None, target_list: List[Target] = None, - lyrics_list: List[Lyrics] = None, main_artist_list: List[Artist] = None, - feature_artist_list: List[Artist] = None, album_list: List[Album] = None, **kwargs) -> None: + def __init__(self, title: str = None, unified_title: str = None, isrc: str = None, length: int = None, + genre: str = None, note: FormattedText = None, source_list: SourceCollection = None, + target_list: List[Target] = None, lyrics_list: List[Lyrics] = None, + main_artist_list: List[Artist] = None, feature_artist_list: List[Artist] = None, + album_list: List[Album] = None, **kwargs) -> None: + super().__init__(title=title, unified_title=unified_title, isrc=isrc, length=length, genre=genre, note=note, source_list=source_list, target_list=target_list, lyrics_list=lyrics_list, main_artist_list=main_artist_list, feature_artist_list=feature_artist_list, @@ -193,6 +196,7 @@ class Album(Base): label_collection: Collection[Label] _default_factories = { + "title": lambda: None, "unified_title": lambda: None, "album_status": lambda: None, "barcode": lambda: None, @@ -211,7 +215,7 @@ class Album(Base): } # This is automatically generated - def __init__(self, title: str, unified_title: str = None, album_status: AlbumStatus = None, + def __init__(self, title: str = None, unified_title: str = None, album_status: AlbumStatus = None, album_type: AlbumType = None, language: Language = None, date: ID3Timestamp = None, barcode: str = None, albumsort: int = None, notes: FormattedText = None, source_list: SourceCollection = None, artist_list: List[Artist] = None, song_list: List[Song] = None, @@ -390,6 +394,7 @@ class Artist(Base): label_collection: Collection[Label] _default_factories = { + "name": lambda: None, "unified_name": lambda: None, "country": lambda: None, "unformated_location": lambda: None, @@ -407,11 +412,12 @@ class Artist(Base): } # This is automatically generated - def __init__(self, name: str, unified_name: str = None, country: Country = None, formed_in: ID3Timestamp = None, - notes: FormattedText = None, lyrical_themes: List[str] = None, general_genre: str = None, - unformated_location: str = None, source_list: SourceCollection = None, + def __init__(self, name: str = None, unified_name: str = None, country: Country = None, + formed_in: ID3Timestamp = None, notes: FormattedText = None, lyrical_themes: List[str] = None, + general_genre: str = None, unformated_location: str = None, source_list: SourceCollection = None, contact_list: List[Contact] = None, feature_song_list: List[Song] = None, main_album_list: List[Album] = None, label_list: List[Label] = None, **kwargs) -> None: + super().__init__(name=name, unified_name=unified_name, country=country, formed_in=formed_in, notes=notes, lyrical_themes=lyrical_themes, general_genre=general_genre, unformated_location=unformated_location, source_list=source_list, contact_list=contact_list, @@ -598,11 +604,11 @@ class Label(Base): "current_artist_collection": Collection, "source_collection": SourceCollection, "contact_collection": Collection, - + "name": lambda: None, "unified_name": lambda: None, } - def __init__(self, name: str, unified_name: str = None, notes: FormattedText = None, + def __init__(self, name: str = None, unified_name: str = None, notes: FormattedText = None, source_list: SourceCollection = None, contact_list: List[Contact] = None, album_list: List[Album] = None, current_artist_list: List[Artist] = None, **kwargs) -> None: super().__init__(name=name, unified_name=unified_name, notes=notes, source_list=source_list, diff --git a/src/music_kraken/objects/source.py b/src/music_kraken/objects/source.py index 1070bd5..8f39cb0 100644 --- a/src/music_kraken/objects/source.py +++ b/src/music_kraken/objects/source.py @@ -24,7 +24,7 @@ class Source(OuterProxy): } # This is automatically generated - def __init__(self, url: str, page_enum: SourcePages, referer_page: SourcePages = None, audio_url: str = None, + def __init__(self, page_enum: SourcePages, url: str, referer_page: SourcePages = None, audio_url: str = None, **kwargs) -> None: if referer_page is None: