diff --git a/src/.fuse_hidden0000846000000007 b/src/.fuse_hidden0000846000000007 new file mode 100644 index 0000000..8043063 Binary files /dev/null and b/src/.fuse_hidden0000846000000007 differ diff --git a/src/goof.py b/src/goof.py index a024391..1ca9a54 100644 --- a/src/goof.py +++ b/src/goof.py @@ -12,7 +12,7 @@ import music_kraken.database.new_database as db cache = music_kraken.database.new_database.Database("test.db") cache.reset() -song = Song( +song_input = Song( title="Vein Deep in the Solution", release_name="One Final Action", length=666, @@ -37,4 +37,5 @@ lyrics = Lyrics(text="these are some Lyrics that don't belong to any Song", lang cache.push([song, lyrics]) -cache.pull_single_song(song_ref=song_ref) +song_output = cache.pull_single_song(song_ref=song_ref) +print(song_output) diff --git a/src/music_kraken/database/new_database.py b/src/music_kraken/database/new_database.py index c875e39..86b5d8e 100644 --- a/src/music_kraken/database/new_database.py +++ b/src/music_kraken/database/new_database.py @@ -186,7 +186,30 @@ class Database: pass def pull_lyrics(self, song_ref: Reference = None, lyrics_ref: Reference = None) -> List[Lyrics]: - pass + """ + Gets a list of sources. if lyrics_ref is passed in the List will most likely only + contain one Element if everything goes accordingly. + **If neither song_ref nor lyrics_ref are passed in it will return ALL lyrics** + :param song_ref: + :param lyrics_ref: + :return: + """ + + where = "1=1" + if song_ref is not None: + where = f"song_id=\"{song_ref.id}\"" + elif lyrics_ref is not None: + where = f"id=\"{lyrics_ref.id}\"" + + query = LYRICS_QUERY.format(where=where) + self.cursor.execute(query) + + lyrics_rows = self.cursor.fetchall() + return [Lyrics( + id_=lyrics_row['id'], + text=lyrics_row['text'], + language=lyrics_row['language'] + ) for lyrics_row in lyrics_rows] def pull_sources(self, song_ref: Reference = None, source_ref: Reference = None) -> List[Source]: """ @@ -234,7 +257,7 @@ class Database: logger.warning(f"Multiple Songs found for the id {song_ref.id}. Defaulting to the first one.") song_result = song_rows[0] - song = Song( + return Song( id_=song_result['song_id'], title=song_result['title'], isrc=song_result['isrc'], @@ -244,11 +267,10 @@ class Database: file=song_result['file'], path=song_result['path'] ), - sources=self.pull_sources(song_ref=song_ref) + sources=self.pull_sources(song_ref=song_ref), + lyrics=self.pull_lyrics(song_ref=song_ref) ) - return song - if __name__ == "__main__": cache = Database("") diff --git a/src/test.db b/src/test.db index 8043063..c19a713 100644 Binary files a/src/test.db and b/src/test.db differ