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:
imSp4rky
2026-11-14 19:58:21 -07:00
parent 703bcf872c
commit 7a5ad5024a
24 changed files with 785 additions and 235 deletions
+40
View File
@@ -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__(
+2 -1
View File
@@ -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 ""