Skip to content

A feature-rich command-line audio/video downloader

[ie/youtube] Fix minor issues (#17060)

doe108057528faa3613
diff --git a/yt_dlp/extractor/youtube/_video.py b/yt_dlp/extractor/youtube/_video.py
index 3697717de8..9a81c709c9 100644
--- a/yt_dlp/extractor/youtube/_video.py
+++ b/yt_dlp/extractor/youtube/_video.py
@@ -3446,7 +3446,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
self._report_pot_format_skipped(video_id, client_name, proto)
return None
- name = fmt_stream.get('qualityLabel') or quality.replace('audio_quality_', '') or ''
+ name = fmt_stream.get('qualityLabel') or (quality or '').replace('audio_quality_', '')
fps = int_or_none(fmt_stream.get('fps')) or 0
dct = {
'asr': int_or_none(fmt_stream.get('audioSampleRate')),
@@ -4372,7 +4372,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
if not release_year:
release_year = release_date[:4]
info.update({
- 'album': mobj.group('album'.strip()),
+ 'album': mobj.group('album').strip(),
'artists': ([a] if (a := mobj.group('clean_artist'))
else [a.strip() for a in mobj.group('artist').split(' · ')]),
'track': mobj.group('track').strip(),
diff --git a/yt_dlp/extractor/youtube/jsc/_builtin/ejs.py b/yt_dlp/extractor/youtube/jsc/_builtin/ejs.py
index 11c8e7ac52..b8164e5836 100644
--- a/yt_dlp/extractor/youtube/jsc/_builtin/ejs.py
+++ b/yt_dlp/extractor/youtube/jsc/_builtin/ejs.py
@@ -233,8 +233,8 @@ class EJSBaseJCP(JsChallengeProvider):
self.logger.debug('Clearing outdated cached script')
self.ie.cache.store(self._CACHE_SECTION, script_type.value, None)
continue
- script_hashes = self._ALLOWED_HASHES[script.type].get(script.variant, [])
- if script_hashes and script.hash not in script_hashes:
+ expected_hash = self._ALLOWED_HASHES[script.type].get(script.variant)
+ if expected_hash and script.hash != expected_hash:
self.logger.warning(
f'Hash mismatch on challenge solver {script.type.value} script '
f'(source: {script.source.value}, variant: {script.variant}, hash: {script.hash})!{provider_bug_report_message(self)}')
diff --git a/yt_dlp/extractor/youtube/jsc/_director.py b/yt_dlp/extractor/youtube/jsc/_director.py
index 77857edfd4..79ee5a609d 100644
--- a/yt_dlp/extractor/youtube/jsc/_director.py
+++ b/yt_dlp/extractor/youtube/jsc/_director.py
@@ -278,7 +278,7 @@ def validate_nsig_challenge_output(challenge_output: NChallengeOutput, challenge
return True
-def validate_sig_challenge_output(challenge_output: SigChallengeOutput, challenge_input: SigChallengeInput) -> bool:
+def validate_sig_challenge_output(challenge_output: SigChallengeOutput, challenge_input: SigChallengeInput) -> bool | str:
return (
isinstance(challenge_output, SigChallengeOutput)
and len(challenge_output.results) == len(challenge_input.challenges)