From cbb56499bf15f1c9c6c8c1f9277a71a69a74bfe0 Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Tue, 6 Dec 2022 17:55:07 +0100 Subject: [PATCH] fda --- src/goof.py | 27 +++++++++++++++------- src/music_kraken/__init__.py | 7 ++++-- src/music_kraken/database/__init__.py | 2 +- src/music_kraken/database/new_database.py | 19 +++++++++++++-- test.db | Bin 0 -> 61440 bytes 5 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 test.db diff --git a/src/goof.py b/src/goof.py index 83a28c3..e0808b8 100644 --- a/src/goof.py +++ b/src/goof.py @@ -1,21 +1,32 @@ import music_kraken +from music_kraken import ( + Song, + Lyrics, + Target, + Source +) import music_kraken.database.new_database as db cache = music_kraken.database.new_database.Database("test.db") cache.reset() -artist = music_kraken.Artist( - name="I'm in a Coffin" -) - -song = music_kraken.Song( +song = Song( title="Vein Deep in the Solution", - release="One Final Action", - artists=[artist] + release_name="One Final Action", + target=Target(file="~/Music/genre/artist/album/song.mp3", path="~/Music/genre/artist/album"), + metadata={ + "album": "One Final Action" + }, + lyrics=[ + Lyrics(text="these are some depressive lyrics", language="en") + ], + sources=[ + Source(src="youtube", url="https://youtu.be/dfnsdajlhkjhsd") + ] ) -cache.push([artist, song]) +cache.push([song]) """ music_kraken.clear_cache() diff --git a/src/music_kraken/__init__.py b/src/music_kraken/__init__.py index 0b1b976..e40585d 100644 --- a/src/music_kraken/__init__.py +++ b/src/music_kraken/__init__.py @@ -17,7 +17,7 @@ from .utils.shared import ( NOT_A_GENRE ) -from .lyrics import lyrics +# from .lyrics import lyrics """ @@ -40,10 +40,13 @@ musicbrainzngs.set_useragent("metadata receiver", "0.1", "https://github.com/HeI # define the most important values and function for import in the __init__ file Song = database.Song Artist = database.Artist +Source = database.Source +Target = database.Target +Lyrics = database.Lyrics MetadataSearch = metadata.MetadataSearch MetadataDownload = metadata.MetadataDownload -cache = database.cache +# cache = database.cache def fetch_metadata(type_: str, id_: str): diff --git a/src/music_kraken/database/__init__.py b/src/music_kraken/database/__init__.py index 6e4b9a3..6ea74e3 100644 --- a/src/music_kraken/database/__init__.py +++ b/src/music_kraken/database/__init__.py @@ -10,4 +10,4 @@ Target = objects.Target Metadata = objects.Metadata Lyrics = objects.Lyrics -cache = temp_database.TempDatabase() +# cache = temp_database.TempDatabase() diff --git a/src/music_kraken/database/new_database.py b/src/music_kraken/database/new_database.py index d68ccb2..077ebda 100644 --- a/src/music_kraken/database/new_database.py +++ b/src/music_kraken/database/new_database.py @@ -4,7 +4,7 @@ import logging from typing import List from pkg_resources import resource_string -from .song import ( +from .objects import ( Song, Lyrics, Metadata, @@ -74,7 +74,22 @@ class Database: self.push_one(db_object) def push_song(self, song: Song): - pass + # ADDING THE DATA FOR THE SONG OBJECT + """ + db_field - object attribute + ------------------------------- + id - id + name - title + """ + table = "Song" + query = f"INSERT OR REPLACE INTO {table} (id, name) VALUES (?, ?);" + values = ( + song.id, + song.title + ) + + self.cursor.execute(query, values) + self.connection.commit() def push_lyrics(self, lyrics: Lyrics): pass diff --git a/test.db b/test.db new file mode 100644 index 0000000000000000000000000000000000000000..8d6d3aaf6acd17236e49929dfef4b9e40a0eb891 GIT binary patch literal 61440 zcmeI%U2D@&9LMow4{ewAVK*Zb5zZLsiZUqTg^0{H+bY-_RYKrhn^ zUx07L_u#Gfz61UTwDrzIfN|oizvIk+EQy zrtw?|!!R=8rx1R|i~K$_{t|A@$o@^c8DsU$i(KKSk)Qi+6b=jD@}CQjb3gKa?q2R| zc0c=T{!_MOeF;ypAbZ z-Kn^aa4YNEj)-d-+(b z%i|ZR`eCEL4mD~V>!7^GEh35ev|TKk!#gU{_QziPsIS-ASQLG16hjr|qAsHH+THc4 zweatEoSG~4>eZb}{XmvMJC8F*%NVWIq*zwzK{jQt6-}evIrcyF-=BtW4PNtn&{f|( z-7l}Kx4A&fMf14LUdtcowH3=VI;IEPzs+M!%A@<`mGyQ$xSLMfwrviJk$Xwr7@1fa zb^rX2;*>He`sZ^HJwC15Y##q&!Uc92{XFWCk-{B9uJ-7nJ*t7 zuJhIn$4+XJwZ3`7{;4ab12G*PJB{vn@5tBdnOG0?u`4~)gL_g3RsU{zFU(BJqx+5eOxuf#X7J?VX(gW(Q&*yNT7MkmI_djUDf{W-O#?w*SoW*anhyWD$oF|8Cszw{ z#ex6=2q1s}0tg_000IagfB*tX6|iJ5-v5(YUUDIT00IagfB*srAb