feat: support song_id and album_id format

pull/13/head
WorldObservationLog 5 months ago
parent 0d98109468
commit d392686547
  1. 3
      config.example.toml
  2. 8
      src/metadata.py

@ -60,6 +60,7 @@ audioInfoFormat = ""
# title, artist, album, album_artist, composer, # title, artist, album, album_artist, composer,
# genre, created, track, tracknum, disk, # genre, created, track, tracknum, disk,
# record_company, upc, isrc, copyright, codec, audio_info # record_company, upc, isrc, copyright, codec, audio_info
# song_id, album_id
songNameFormat = "{disk}-{tracknum:02d} {title}" songNameFormat = "{disk}-{tracknum:02d} {title}"
# Ditto # Ditto
dirPathFormat = "downloads/{album_artist}/{album}" dirPathFormat = "downloads/{album_artist}/{album}"
@ -68,12 +69,14 @@ dirPathFormat = "downloads/{album_artist}/{album}"
# genre, created, track, tracknum, disk, # genre, created, track, tracknum, disk,
# record_company, upc, isrc, copyright, # record_company, upc, isrc, copyright,
# playlistName, playlistCuratorName, codec # playlistName, playlistCuratorName, codec
# song_id, album_id
playlistDirPathFormat = "downloads/playlists/{playlistName}" playlistDirPathFormat = "downloads/playlists/{playlistName}"
# Available values: # Available values:
# title, artist, album, album_artist, composer, # title, artist, album, album_artist, composer,
# genre, created, track, tracknum, disk, # genre, created, track, tracknum, disk,
# record_company, upc, isrc, copyright, audio_info # record_company, upc, isrc, copyright, audio_info
# playlistName, playlistCuratorName, playlistSongIndex, codec # playlistName, playlistCuratorName, playlistSongIndex, codec
# song_id, album_id
playlistSongNameFormat = "{playlistSongIndex:02d}. {artist} - {title}" playlistSongNameFormat = "{playlistSongIndex:02d}. {artist} - {title}"
# Save lyrics as .lrc file # Save lyrics as .lrc file
saveLyrics = true saveLyrics = true

@ -6,12 +6,15 @@ from src.api import get_cover
from src.models.song_data import Datum from src.models.song_data import Datum
from src.utils import ttml_convent_to_lrc from src.utils import ttml_convent_to_lrc
NOT_INCLUDED_FIELD = ["cover", "playlistIndex", "bit_depth", "sample_rate", "sample_rate_kHz"] NOT_INCLUDED_FIELD = ["cover", "playlistIndex", "bit_depth", "sample_rate",
"sample_rate_kHz", "song_id", "album_id"]
class SongMetadata(BaseModel): class SongMetadata(BaseModel):
song_id: Optional[str] = None
title: Optional[str] = None title: Optional[str] = None
artist: Optional[str] = None artist: Optional[str] = None
album_id: Optional[str] = None
album_artist: Optional[str] = None album_artist: Optional[str] = None
album: Optional[str] = None album: Optional[str] = None
composer: Optional[str] = None composer: Optional[str] = None
@ -65,7 +68,8 @@ class SongMetadata(BaseModel):
record_company=song_data.relationships.albums.data[0].attributes.recordLabel, record_company=song_data.relationships.albums.data[0].attributes.recordLabel,
upc=song_data.relationships.albums.data[0].attributes.upc, upc=song_data.relationships.albums.data[0].attributes.upc,
isrc=song_data.attributes.isrc, isrc=song_data.attributes.isrc,
rtng=1 if song_data.attributes.contentRating and song_data.attributes.contentRating == 'explicit' else 0 rtng=1 if song_data.attributes.contentRating and song_data.attributes.contentRating == 'explicit' else 0,
song_id=song_data.id, album_id=song_data.relationships.albums.data[0].id
) )
def set_lyrics(self, lyrics: str): def set_lyrics(self, lyrics: str):

Loading…
Cancel
Save