From 0c2b604b929aa5db0c8a9ca72f23a91144513b99 Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Fri, 16 Dec 2022 12:53:05 +0100 Subject: [PATCH] dsfjsd --- src/music_kraken/database/new_database.py | 11 ++++---- src/music_kraken/database/objects/song.py | 31 +++++++++++++++------- test.db | Bin 65536 -> 65536 bytes 3 files changed, 27 insertions(+), 15 deletions(-) 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 4fbec7aee1a2dc0a55f1acff7d651bea159596f8..f534e7c6d8e3e2f06c1abbb13665d6fc0d249493 100644 GIT binary patch delta 1635 zcmb`Hy=zoK6vg*t6U+wmnMP0pdBtJ`y=1;WKoYGiOu!(omibI%H7o80>~?L^T0Cs5 zEX8JJSF9{jS_rmwVlSBgAP(CJf>YQJzkANP=gxS%I36#)-&!AOOpTY=09J$mLtKFl zmH_6|MMpJt9N(#;>peQ$uO9Rd_qD)QIi$d-5P=2G!K7y(Yz)ymL!(B$;#|GmS}1Bk zG*VGBkk;!&Hx4W@0hm$9Q7LU3d(oV%uXS^<)A5ILCqwVTM!W9(b99wiey|I@=JW9^5-dpa}0V@_H^$9~$Oq^p#EDA(nDwQN$ zW8Qq+zShm5PODkDo1=5?JZJRu{+HxDW0kYhhd=XPPM>zlk;2B>AO#>zTnf{3P?{1D z4l7O>^&YF7%DuQ*EY(M@mXZtRwFE?r0;UWDLkt2-t)@|!#NwL={U>4bv3WMwY(9;u z=Iw~(rFuK1nj?6gYL1fsU(h!{E_Aguf``;i?Xgdprt8#E88BE<6ulJ4_-1KxYlO6> zOjwmV7gAVMaIn%LU@js;Nx(s&VHga| zxTXXF? z1#cW$0W4-=!BK;?K>pT2K13B zmQ3?;{YJk;b=u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