added genre
This commit is contained in:
parent
7817402a19
commit
48b1ab9288
@ -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",
|
||||
|
@ -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'],
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user