diff --git a/src/music_kraken/database/new_database.py b/src/music_kraken/database/new_database.py index c8539a1..b36213f 100644 --- a/src/music_kraken/database/new_database.py +++ b/src/music_kraken/database/new_database.py @@ -325,9 +325,9 @@ class Database: table = "SongArtist" wheres = [] if song_ref is not None: - wheres.append("song_id=\"{song_ref.id}\"") + wheres.append(f"song_id=\"{song_ref.id}\"") if artist_ref is not None: - wheres.append("artist_id=\"{artist_ref.id}\"") + wheres.append(f"artist_id=\"{artist_ref.id}\"") where_str = "" if len(wheres) > 0: where_str = "WHERE " + " AND ".join(wheres) @@ -349,7 +349,7 @@ class Database: new_exclude_relations.add(Song) return Artist( id_=artist_row['artist_id'], - name=artist_row['name'] + name=artist_row['artist_name'] ) def pull_artists(self, artist_ref: Reference = None, exclude_relations: set = None) -> List[Artist]: @@ -398,11 +398,10 @@ class Database: main_artists = [] feature_artists = [] - print(exclude_relations) if Artist not in exclude_relations: - for song_ref, artist_ref, is_feature in self.pull_artist_song(song_ref=song_id): + for song_ref, artist_ref, is_feature in self.pull_artist_song(song_ref=Reference(song_id)): print(artist_ref) - if not is_feature: + if is_feature: feature_artists.extend(self.pull_artists(artist_ref=artist_ref)) else: main_artists.extend(self.pull_artists(artist_ref=artist_ref)) diff --git a/src/music_kraken/database/objects/song.py b/src/music_kraken/database/objects/song.py index f2fe82b..9932a53 100644 --- a/src/music_kraken/database/objects/song.py +++ b/src/music_kraken/database/objects/song.py @@ -320,14 +320,6 @@ All objects dependent on Artist """ -class ArtistSong(Song): - """ - A subclass of Song with the additional attribute is_feature, which - makes only sense when in/from the Artist class - """ - is_feature: bool = False - - class Artist(DatabaseObject): def __init__( self, @@ -340,7 +332,13 @@ class Artist(DatabaseObject): self.name: str | None = name - self.songs: List[ArtistSong] = [] + self.main_songs = [] + self.feature_songs = [] + + self.main_albums = [] + self.feature_albums = [] + + self.songs: List[Song] = [] self.album_refs: List[Album] = [] self.set_discography(discography) @@ -349,6 +347,21 @@ class Artist(DatabaseObject): def __str__(self): return self.name or "" + def add_song(self, song: Song, is_feature: bool): + """ + it is reccomendet, that the song object already contains the album, + else you will have to add it youreself + """ + + if is_feature: + self.feature_songs.append(song) + if song.album is not None: + self.feature_albums.append(song.album) + else: + self.main_songs.append(song) + if song.album is not None: + self.main_albums(song.album) + def add_album(self, album: Album): self.album_refs.append(album) diff --git a/test.db b/test.db index 4fbec7a..f534e7c 100644 Binary files a/test.db and b/test.db differ