From 48b1ab92885df91afab12774e43e0357d41d5283 Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Mon, 16 Jan 2023 14:31:43 +0100 Subject: [PATCH] added genre --- src/goof.py | 1 + src/music_kraken/database/new_database.py | 8 +++++--- src/music_kraken/database/objects/song.py | 5 ++++- src/music_kraken/static_files/new_db.sql | 1 + test.db | Bin 69632 -> 69632 bytes 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/goof.py b/src/goof.py index d392223..83d1459 100644 --- a/src/goof.py +++ b/src/goof.py @@ -53,6 +53,7 @@ album_input.artists = [ ] song_input = Song( + genre="HS Core", title="Vein Deep in the Solution", length=666, isrc="US-S1Z-99-00001", diff --git a/src/music_kraken/database/new_database.py b/src/music_kraken/database/new_database.py index fec292a..e4ef7ea 100644 --- a/src/music_kraken/database/new_database.py +++ b/src/music_kraken/database/new_database.py @@ -27,7 +27,7 @@ logger = logging.getLogger("database") SONG_QUERY = """ SELECT Song.id AS song_id, Song.name AS title, Song.isrc AS isrc, Song.length AS length, Song.album_id, Song.tracksort, -Target.id AS target_id, Target.file AS file, Target.path AS path +Target.id AS target_id, Target.file AS file, Target.path AS path, Song.genre AS genre FROM Song LEFT JOIN Target ON Song.id=Target.song_id WHERE {where}; @@ -173,9 +173,10 @@ class Database: song.isrc, song.length, song.get_album_id(), - song.tracksort + song.tracksort, + song.genre ) - query = f"INSERT OR REPLACE INTO {table} (id, name, isrc, length, album_id, tracksort) VALUES (?, ?, ?, ?, ?, ?);" + query = f"INSERT OR REPLACE INTO {table} (id, name, isrc, length, album_id, tracksort, genre) VALUES (?, ?, ?, ?, ?, ?, ?);" self.cursor.execute(query, values) self.connection.commit() @@ -475,6 +476,7 @@ class Database: isrc=song_result['isrc'], length=song_result['length'], tracksort=song_result['tracksort'], + genre=song_result['genre'], target=Target( id_=song_result['target_id'], file=song_result['file'], diff --git a/src/music_kraken/database/objects/song.py b/src/music_kraken/database/objects/song.py index 07c7c23..42ba666 100644 --- a/src/music_kraken/database/objects/song.py +++ b/src/music_kraken/database/objects/song.py @@ -93,6 +93,7 @@ class Song(DatabaseObject, ID3Metadata): isrc: str = None, length: int = None, tracksort: int = None, + genre: str = None, sources: List[Source] = None, target: Target = None, lyrics: List[Lyrics] = None, @@ -115,6 +116,7 @@ class Song(DatabaseObject, ID3Metadata): self.mb_id: str | None = mb_id self.album_name: str | None = album_name self.tracksort: int | None = tracksort + self.genre: str = genre self.sources: List[Source] = [] if sources is not None: @@ -175,7 +177,8 @@ class Song(DatabaseObject, ID3Metadata): return { ID3_MAPPING.TITLE: [self.title], ID3_MAPPING.ISRC: [self.isrc], - ID3_MAPPING.LENGTH: [str(self.length)] + ID3_MAPPING.LENGTH: [str(self.length)], + ID3_MAPPING.GENRE: [self.genre] } def get_metadata(self) -> Metadata: diff --git a/src/music_kraken/static_files/new_db.sql b/src/music_kraken/static_files/new_db.sql index ef77458..7585a9c 100644 --- a/src/music_kraken/static_files/new_db.sql +++ b/src/music_kraken/static_files/new_db.sql @@ -5,6 +5,7 @@ CREATE TABLE Song isrc TEXT, length INT, -- length is in milliseconds (could be wrong) tracksort INT, + genre TEXT, album_id BIGINT, FOREIGN KEY(album_id) REFERENCES Album(id) ); diff --git a/test.db b/test.db index a291c6d153c9edbf3040157eb72ebdc147257adb..742490ea1e604bd6d40de6da92c47f2f19bbc96c 100644 GIT binary patch delta 2434 zcmc&#&1)T19L>DRB=05Zn*^y*T4*T26yi_r_XntHDWZ@Rl`_jHbHCEsl9VPDLGVS; zE_7p@h1)FLbrJiXx-M?q*^PyVt8QH=`X6{-y3mvauPbML=iGDdIluGU-5=lGAOGUL z^TV<3=jFqh-@5Niuh0B2#i!A9-oaDt_LrUU$@eF|Du(y>){4RJ#kcLwrEGHk^y%yq z-`wjyE;jt;ZQo=w^UYp)r~PQG{IERReKeSx{jvMfYk9j`85@045W%epU^S7zoW)>_ zpb!YPA|S8oAevL>p6{)<+SStNk1Am6u<{O&2^?5J4wOYTIObiTn6jYRrG;Q`T;JSS zxV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