added lyrics to object thingie
This commit is contained in:
parent
4b60ed7555
commit
7d21cb727e
BIN
src/.fuse_hidden0000846000000007
Normal file
BIN
src/.fuse_hidden0000846000000007
Normal file
Binary file not shown.
@ -12,7 +12,7 @@ import music_kraken.database.new_database as db
|
|||||||
cache = music_kraken.database.new_database.Database("test.db")
|
cache = music_kraken.database.new_database.Database("test.db")
|
||||||
cache.reset()
|
cache.reset()
|
||||||
|
|
||||||
song = Song(
|
song_input = Song(
|
||||||
title="Vein Deep in the Solution",
|
title="Vein Deep in the Solution",
|
||||||
release_name="One Final Action",
|
release_name="One Final Action",
|
||||||
length=666,
|
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.push([song, lyrics])
|
||||||
|
|
||||||
cache.pull_single_song(song_ref=song_ref)
|
song_output = cache.pull_single_song(song_ref=song_ref)
|
||||||
|
print(song_output)
|
||||||
|
@ -186,7 +186,30 @@ class Database:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def pull_lyrics(self, song_ref: Reference = None, lyrics_ref: Reference = None) -> List[Lyrics]:
|
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]:
|
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.")
|
logger.warning(f"Multiple Songs found for the id {song_ref.id}. Defaulting to the first one.")
|
||||||
song_result = song_rows[0]
|
song_result = song_rows[0]
|
||||||
|
|
||||||
song = Song(
|
return Song(
|
||||||
id_=song_result['song_id'],
|
id_=song_result['song_id'],
|
||||||
title=song_result['title'],
|
title=song_result['title'],
|
||||||
isrc=song_result['isrc'],
|
isrc=song_result['isrc'],
|
||||||
@ -244,11 +267,10 @@ class Database:
|
|||||||
file=song_result['file'],
|
file=song_result['file'],
|
||||||
path=song_result['path']
|
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__":
|
if __name__ == "__main__":
|
||||||
cache = Database("")
|
cache = Database("")
|
||||||
|
BIN
src/test.db
BIN
src/test.db
Binary file not shown.
Loading…
Reference in New Issue
Block a user