finished????

This commit is contained in:
Hellow 2022-12-16 18:26:05 +01:00
parent 23b3ab0101
commit b51904d438
3 changed files with 35 additions and 10 deletions

View File

@ -10,8 +10,8 @@ from music_kraken import (
import music_kraken.database.new_database as db import music_kraken.database.new_database as db
def div(): def div(msg:str=""):
print("-"*100) print("-"*50+msg+"-"*50)
cache = music_kraken.database.new_database.Database("test.db") cache = music_kraken.database.new_database.Database("test.db")
@ -34,6 +34,10 @@ feature_artist = Artist(
album_input = Album( album_input = Album(
title="One Final Action" title="One Final Action"
) )
album_input.artists = [
main_artist,
split_artist
]
song_input = Song( song_input = Song(
title="Vein Deep in the Solution", title="Vein Deep in the Solution",
@ -56,6 +60,12 @@ song_input = Song(
feature_artist_list = [feature_artist] feature_artist_list = [feature_artist]
) )
other_song = Song(
title="this is just another song",
main_artist_list=[feature_artist],
feature_artist_list=[main_artist]
)
print(song_input) print(song_input)
additional_song = Song( additional_song = Song(
@ -68,7 +78,7 @@ print(song_ref)
lyrics = Lyrics(text="these are some Lyrics that don't belong to any Song", language="en") lyrics = Lyrics(text="these are some Lyrics that don't belong to any Song", language="en")
cache.push([album_input, song_input, lyrics, additional_song]) cache.push([album_input, song_input, lyrics, additional_song, other_song])
# getting song by song ref # getting song by song ref
div() div()
@ -84,12 +94,17 @@ for song in song_output_list:
print(song, song.album) print(song, song.album)
# getting album # getting album
div() div("album")
album_output_list = cache.pull_albums(album_ref=album_input.reference) album_output_list = cache.pull_albums(album_ref=album_input.reference)
album_output = album_output_list[0] album_output = album_output_list[0]
print(album_output) print(album_output)
print(f"--tracklist-{len(album_output)}--")
for track in album_output.tracklist: for track in album_output.tracklist:
print(track.tracksort, track) print(track.tracksort, track)
print("--artist--")
for artist in album_output.artists:
print(artist)
# getting album by song # getting album by song
div() div()
@ -98,9 +113,16 @@ print(album_output_list)
print("len of album ->", len(album_output_list[0]), album_output_list[0], sep=" | ") print("len of album ->", len(album_output_list[0]), album_output_list[0], sep=" | ")
# get artist # get artist
div() div("artist")
artist_output = cache.pull_artists(artist_ref=artist_ref)[0] artist_output = cache.pull_artists(artist_ref=artist_ref)[0]
print(artist_output) print(artist_output)
print(artist_output.main_albums)
print(artist_output.main_songs) print("---static---")
print(artist_output.feature_songs) print("albums", artist_output.main_albums)
print("main_s", artist_output.main_songs)
print("feat_s", artist_output.feature_songs)
print("---dynamic---")
print("discography", artist_output.discography)
print("songs", artist_output.songs, artist_output.songs.tracklist)
print("features", artist_output.features, artist_output.features.tracklist)

View File

@ -298,6 +298,9 @@ class Album(DatabaseObject):
def __str__(self) -> str: def __str__(self) -> str:
return f"Album: \"{self.title}\"" return f"Album: \"{self.title}\""
def __repr__(self):
return self.__str__()
def __len__(self) -> int: def __len__(self) -> int:
return len(self.tracklist) return len(self.tracklist)
@ -335,7 +338,7 @@ class Artist(DatabaseObject):
name: str = None, name: str = None,
main_songs: List[Song] = None, main_songs: List[Song] = None,
feature_songs: List[Song] = None, feature_songs: List[Song] = None,
main_albums: List[Song] = None main_albums: List[Album] = None
): ):
DatabaseObject.__init__(self, id_=id_) DatabaseObject.__init__(self, id_=id_)
@ -389,7 +392,7 @@ class Artist(DatabaseObject):
return song_release return song_release
def get_discography(self) -> List[Album]: def get_discography(self) -> List[Album]:
flat_copy_discography = self.discography.copy() flat_copy_discography = self.main_albums.copy()
flat_copy_discography.append(self.get_features()) flat_copy_discography.append(self.get_features())
return flat_copy_discography return flat_copy_discography

Binary file not shown.