forked from kenzuya/unshackle
feat(music): pick the song container from the codec in the downloaded file
FFprobe sets the codec; DTS goes to .mka, PCM to .flac or .wav, AC-4/MPEG-H/DTS-UHD to MP4Box. The remux also cuts --sample, --no-mux no longer applies to a Song, and the tagger adds cover fallback, WebP, ARTISTS and ReplayGain. Song tag data now reaches a --remote client.
This commit is contained in:
@@ -34,6 +34,46 @@ SONG_FIELDS = (
|
||||
)
|
||||
"""The `Song` attributes a remote session sends, beyond the fields every title has."""
|
||||
|
||||
MUSIC_DATA_KEYS = (
|
||||
"release_date",
|
||||
"composer",
|
||||
"performer",
|
||||
"comment",
|
||||
"source",
|
||||
"service",
|
||||
"track_id",
|
||||
"album_id",
|
||||
"track_url",
|
||||
"album_url",
|
||||
"artists",
|
||||
"replaygain_track_gain",
|
||||
"replaygain_track_peak",
|
||||
"replaygain_album_gain",
|
||||
"replaygain_album_peak",
|
||||
"quality",
|
||||
"quality_label",
|
||||
"lossless",
|
||||
"hires",
|
||||
"atmos",
|
||||
"duration",
|
||||
"released_at",
|
||||
"year",
|
||||
"barcode",
|
||||
"parental_warning",
|
||||
"unavailable_reason",
|
||||
"skip_reason",
|
||||
)
|
||||
"""The `Song.data` keys the music tagger and renderer read, which a remote session sends as `music_data`."""
|
||||
|
||||
|
||||
def song_metadata(song: Any) -> dict[str, Any]:
|
||||
"""``Song.data`` with its nested ``metadata`` dict merged over it, as the renderer also reads both."""
|
||||
data = getattr(song, "data", None)
|
||||
if not isinstance(data, dict):
|
||||
return {}
|
||||
nested = data.get("metadata")
|
||||
return {**data, **nested} if isinstance(nested, dict) else data
|
||||
|
||||
|
||||
class Song(Title):
|
||||
def __init__(
|
||||
|
||||
@@ -186,7 +186,8 @@ class Title:
|
||||
channels_str = f"{len(positions) - heights - lfe}.{lfe}.{heights}"
|
||||
else:
|
||||
channels_str = f"{channels:.1f}"
|
||||
builtin = AUDIO_CODEC_MAP.get(codec, codec)
|
||||
profile = getattr(primary_audio_track, "format_profile", None)
|
||||
builtin = AUDIO_CODEC_MAP.get(f"{codec} {profile}") or AUDIO_CODEC_MAP.get(codec, codec)
|
||||
audio = rename(builtin)
|
||||
spacer = " " if builtin in SPACED_AUDIO_CODECS or audio[-1:].isdigit() else ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user