fix: downloading into correct artist

This commit is contained in:
Hazel 2024-01-15 11:52:31 +01:00
parent 1a3f164827
commit 564621b332
3 changed files with 21 additions and 13 deletions

View File

@ -61,7 +61,7 @@ class OuterProxy:
"""
_default_factories: dict = {}
_outer_attribute: Set[str] = {"options", "metadata", "indexing_values"}
_outer_attribute: Set[str] = {"options", "metadata", "indexing_values", "option_string"}
DOWNWARDS_COLLECTION_STRING_ATTRIBUTES = tuple()
UPWARDS_COLLECTION_STRING_ATTRIBUTES = tuple()

View File

@ -61,13 +61,13 @@ class Song(Base):
"album_collection": Collection,
"feature_artist_collection": Collection,
"title": lambda: None,
"title": lambda: "",
"unified_title": lambda: None,
"isrc": lambda: None,
"genre": lambda: None,
}
def __init__(self, title: str = None, unified_title: str = None, isrc: str = None, length: int = None,
def __init__(self, title: str = "", unified_title: str = None, isrc: str = None, length: int = None,
genre: str = None, note: FormattedText = None, source_list: List[Source] = None,
target_list: List[Target] = None, lyrics_list: List[Lyrics] = None,
main_artist_list: List[Artist] = None, feature_artist_list: List[Artist] = None,
@ -264,7 +264,7 @@ class Album(Base):
@property
def option_string(self) -> str:
return f"{self.__repr__()} " \
f"by Artist({OPTION_STRING_DELIMITER.join([str(artist.name) for artist in self.artist_collection])}) " \
f"by Artist({OPTION_STRING_DELIMITER.join([artist.name for artist in self.artist_collection])}) " \
f"under Label({OPTION_STRING_DELIMITER.join([label.name for label in self.label_collection])})"
@property
@ -390,7 +390,7 @@ class Artist(Base):
label_collection: Collection[Label]
_default_factories = {
"name": lambda: None,
"name": str,
"unified_name": lambda: None,
"country": lambda: None,
"unformated_location": lambda: None,
@ -408,7 +408,7 @@ class Artist(Base):
}
# This is automatically generated
def __init__(self, name: str = None, unified_name: str = None, country: Country = None,
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: List[Source] = None,
contact_list: List[Contact] = None, feature_song_list: List[Song] = None,

View File

@ -240,20 +240,28 @@ class Page:
"""
# creating a new object, of the same type
new_music_object: DatabaseObject = type(music_object)()
new_music_object: Optional[DatabaseObject] = None
# only certain database objects, have a source list
if isinstance(music_object, INDEPENDENT_DB_OBJECTS):
source: Source
for source in music_object.source_collection.get_sources_from_page(self.SOURCE_TYPE):
new_music_object.merge(self.fetch_object_from_source(
source=source,
enforce_type=type(music_object),
stop_at_level=stop_at_level,
tmp = self.fetch_object_from_source(
source=source,
enforce_type=type(music_object),
stop_at_level=stop_at_level,
post_process=False
))
)
return music_object.merge(new_music_object)
if new_music_object is None:
new_music_object = tmp
else:
new_music_object.merge(tmp)
if new_music_object is not None:
music_object.merge(new_music_object)
return 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)