Skip audio track filtering if there's no audio tracks

This also bypasses the warning log about the audio likely being part of an invariant playlist, which may be true it is too specific of a warning when it could be multiple other reasons why.
This commit is contained in:
rlaphoenix 2023-12-29 21:19:53 +00:00
parent c0d940b17b
commit d690ca4d13
1 changed files with 21 additions and 23 deletions

View File

@ -417,6 +417,8 @@ class dl:
title.tracks.select_subtitles(lambda x: not x.forced or is_close_match(x.language, lang)) title.tracks.select_subtitles(lambda x: not x.forced or is_close_match(x.language, lang))
# filter audio tracks # filter audio tracks
# might have no audio tracks if part of the video, e.g. transport stream hls
if len(title.tracks.audio) > 0:
title.tracks.select_audio(lambda x: not x.descriptive) # exclude descriptive audio title.tracks.select_audio(lambda x: not x.descriptive) # exclude descriptive audio
if acodec: if acodec:
title.tracks.select_audio(lambda x: x.codec == acodec) title.tracks.select_audio(lambda x: x.codec == acodec)
@ -436,10 +438,6 @@ class dl:
if lang and "all" not in lang: if lang and "all" not in lang:
title.tracks.audio = title.tracks.by_language(title.tracks.audio, lang, per_language=1) title.tracks.audio = title.tracks.by_language(title.tracks.audio, lang, per_language=1)
if not title.tracks.audio: if not title.tracks.audio:
if all(x.descriptor == Video.Descriptor.M3U for x in title.tracks.videos):
self.log.warning(f"There's no {lang} Audio Tracks, "
f"likely part of an invariant playlist, continuing...")
else:
self.log.error(f"There's no {lang} Audio Track, cannot continue...") self.log.error(f"There's no {lang} Audio Track, cannot continue...")
sys.exit(1) sys.exit(1)