This commit is contained in:
Hellow2
2023-03-06 15:20:26 +01:00
parent 9eb7b66882
commit 191febd794
5 changed files with 83 additions and 14 deletions

View File

@@ -53,7 +53,7 @@ class MainObject(DatabaseObject):
"""
def __init__(self, _id: str = None, dynamic: bool = False, **kwargs):
super().__init__(_id=_id, dynamic=dynamic, **kwargs)
DatabaseObject.__init__(self, _id=_id, dynamic=dynamic, **kwargs)
self.additional_arguments: dict = kwargs

View File

@@ -167,6 +167,9 @@ class Song(MainObject, SourceAttribute, MetadataAttribute):
album_list: List[Type['Album']] = property(fget=lambda self: self.album_collection.copy())
lyrics_list: List[Type[Lyrics]] = property(fget=lambda self: self.lyrics_collection.copy())
COLLECTION_ATTRIBUTES = ("lyrics_collection", "album_collection", "main_artist_collection", "feature_artist_collection")
SIMPLE_ATTRIBUTES = ("title", "isrc", "length", "tracksort", "genre")
"""
All objects dependent on Album
@@ -317,6 +320,10 @@ class Album(MainObject, SourceAttribute, MetadataAttribute):
tracklist: List[Song] = property(fget=lambda self: self.song_collection.copy())
copyright = property(fget=get_copyright)
COLLECTION_ATTRIBUTES = ("label_collection", "artist_collection", "song_collection")
SIMPLE_ATTRIBUTES = ("title", "album_status", "album_type", "language", "date", "barcode", "albumsort")
"""
All objects dependent on Artist
@@ -460,7 +467,7 @@ class Artist(MainObject, SourceAttribute, MetadataAttribute):
return flat_copy_discography
album_list: List[Album] = property(fget=lambda self: self.album_collection.copy())
album_list: List[Album] = property(fget=lambda self: self.main_album_collection.copy())
complete_album_list: List[Album] = property(fget=get_discography)
discography: List[Album] = property(fget=get_discography)
@@ -468,6 +475,9 @@ class Artist(MainObject, SourceAttribute, MetadataAttribute):
feature_album: Album = property(fget=get_features)
song_list: List[Song] = property(fget=get_all_songs)
label_list: List[Type['Label']] = property(fget=lambda self: self.label_collection.copy())
COLLECTION_ATTRIBUTES = ("feature_song_collection", "main_album_collection", "label_collection")
SIMPLE_ATTRIBUTES = ("name", "name", "country", "formed_in", "notes", "lyrical_themes", "general_genre")
"""
@@ -511,3 +521,6 @@ class Label(MainObject, SourceAttribute, MetadataAttribute):
@property
def current_artist_list(self) -> List[Artist]:
self.current_artist_collection.copy()
COLLECTION_ATTRIBUTES = ("album_collection", "current_artist_collection")
SIMPLE_ATTRIBUTES = ("name",)

View File

@@ -126,7 +126,7 @@ class Source(DatabaseObject, MetadataAttribute):
homepage = property(fget=lambda self: SourcePages.get_homepage(self.page_enum))
class SourceAttribute:
class SourceAttribute(DatabaseObject):
"""
This is a class that is meant to be inherited from.
it adds the source_list attribute to a class
@@ -187,6 +187,12 @@ class SourceAttribute:
and the value is a List with all sources of according page
"""
return self._source_dict
def merge(self, other, override: bool = False):
super().merge(other, override)
for source in other.source_list:
self.add_source(source=source)
source_list: List[Source] = property(fget=get_source_list, fset=set_source_list)
source_dict: Dict[object, List[Source]] = property(fget=get_source_dict)

View File

@@ -237,17 +237,6 @@ class EncyclopaediaMetallum(Page):
except ValueError():
pass
album_obj: Album = artist.main_album_collection.get_object_with_source(album_url) or artist.main_album_collection.get_object_with_attribute("title", album_name)
if album_obj is not None:
album_obj.add_source(Source(SourcePages.ENCYCLOPAEDIA_METALLUM, album_url))
album_obj.title = album_name
album_obj.album_type = album_type
if date_obj is not None:
album_obj.date = date_obj
continue
artist.main_album_collection.append(Album(
id_=album_id,
title=album_name,