dsfjsd
This commit is contained in:
parent
933eddeea4
commit
0c2b604b92
@ -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))
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user