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,29 +417,27 @@ 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
title.tracks.select_audio(lambda x: not x.descriptive) # exclude descriptive audio # might have no audio tracks if part of the video, e.g. transport stream hls
if acodec: if len(title.tracks.audio) > 0:
title.tracks.select_audio(lambda x: x.codec == acodec) title.tracks.select_audio(lambda x: not x.descriptive) # exclude descriptive audio
if not title.tracks.audio: if acodec:
self.log.error(f"There's no {acodec.name} Audio Tracks...") title.tracks.select_audio(lambda x: x.codec == acodec)
sys.exit(1) if not title.tracks.audio:
if abitrate: self.log.error(f"There's no {acodec.name} Audio Tracks...")
title.tracks.select_audio(lambda x: x.bitrate and x.bitrate // 1000 == abitrate) sys.exit(1)
if not title.tracks.audio: if abitrate:
self.log.error(f"There's no {abitrate}kbps Audio Track...") title.tracks.select_audio(lambda x: x.bitrate and x.bitrate // 1000 == abitrate)
sys.exit(1) if not title.tracks.audio:
if channels: self.log.error(f"There's no {abitrate}kbps Audio Track...")
title.tracks.select_audio(lambda x: math.ceil(x.channels) == math.ceil(channels)) sys.exit(1)
if not title.tracks.audio: if channels:
self.log.error(f"There's no {channels} Audio Track...") title.tracks.select_audio(lambda x: math.ceil(x.channels) == math.ceil(channels))
sys.exit(1) if not title.tracks.audio:
if lang and "all" not in lang: self.log.error(f"There's no {channels} Audio Track...")
title.tracks.audio = title.tracks.by_language(title.tracks.audio, lang, per_language=1) sys.exit(1)
if not title.tracks.audio: if lang and "all" not in lang:
if all(x.descriptor == Video.Descriptor.M3U for x in title.tracks.videos): title.tracks.audio = title.tracks.by_language(title.tracks.audio, lang, per_language=1)
self.log.warning(f"There's no {lang} Audio Tracks, " if not title.tracks.audio:
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)