prefer audio tags in audio files

This commit is contained in:
ed 2021-06-22 17:21:24 +02:00
parent f1a1c2ea45
commit aa4f352301

View file

@ -115,6 +115,19 @@ def parse_ffprobe(txt):
ret = {} # processed ret = {} # processed
md = {} # raw tags md = {} # raw tags
is_audio = fmt.get("format_name") in ["mp3", "ogg", "flac", "wav"]
if fmt.get("filename", "").split(".")[-1].lower() in ["m4a", "aac"]:
is_audio = True
# if audio file, ensure audio stream appears first
if (
is_audio
and len(streams) > 2
and streams[1].get("codec_type") != "audio"
and streams[2].get("codec_type") == "audio"
):
streams = [fmt, streams[2], streams[1]] + streams[3:]
have = {} have = {}
for strm in streams: for strm in streams:
typ = strm.get("codec_type") typ = strm.get("codec_type")
@ -134,9 +147,7 @@ def parse_ffprobe(txt):
] ]
if typ == "video": if typ == "video":
if strm.get("DISPOSITION:attached_pic") == "1" or fmt.get( if strm.get("DISPOSITION:attached_pic") == "1" or is_audio:
"format_name"
) in ["mp3", "ogg", "flac"]:
continue continue
kvm = [ kvm = [
@ -180,7 +191,7 @@ def parse_ffprobe(txt):
k = k[4:].strip() k = k[4:].strip()
v = v.strip() v = v.strip()
if k and v: if k and v and k not in md:
md[k] = [v] md[k] = [v]
for k in [".q", ".vq", ".aq"]: for k in [".q", ".vq", ".aq"]: