summaryrefslogtreecommitdiffstats
path: root/yt_dlp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-05 09:06:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-05 09:06:59 +0000
commit78c3c01dd972cf8770bc100ddb183eb890c6a10d (patch)
tree868be7a9ef73cf1861fad05c2028966dbf55ac6c /yt_dlp
parentAdding debian version 2024.07.07-1. (diff)
downloadyt-dlp-78c3c01dd972cf8770bc100ddb183eb890c6a10d.tar.xz
yt-dlp-78c3c01dd972cf8770bc100ddb183eb890c6a10d.zip
Merging upstream version 2024.07.09.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'yt_dlp')
-rw-r--r--yt_dlp/YoutubeDL.py9
-rw-r--r--yt_dlp/extractor/soundcloud.py34
-rw-r--r--yt_dlp/extractor/youtube.py15
-rw-r--r--yt_dlp/jsinterp.py18
-rw-r--r--yt_dlp/version.py6
5 files changed, 44 insertions, 38 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index e56c3ed..fd5aa01 100644
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -2190,9 +2190,8 @@ class YoutubeDL:
or all(f.get('acodec') == 'none' for f in formats)), # OR, No formats with audio
}))
- def _default_format_spec(self, info_dict, download=True):
- download = download and not self.params.get('simulate')
- prefer_best = download and (
+ def _default_format_spec(self, info_dict):
+ prefer_best = (
self.params['outtmpl']['default'] == '-'
or info_dict.get('is_live') and not self.params.get('live_from_start'))
@@ -2200,7 +2199,7 @@ class YoutubeDL:
merger = FFmpegMergerPP(self)
return merger.available and merger.can_merge()
- if not prefer_best and download and not can_merge():
+ if not prefer_best and not can_merge():
prefer_best = True
formats = self._get_formats(info_dict)
evaluate_formats = lambda spec: self._select_formats(formats, self.build_format_selector(spec))
@@ -2959,7 +2958,7 @@ class YoutubeDL:
continue
if format_selector is None:
- req_format = self._default_format_spec(info_dict, download=download)
+ req_format = self._default_format_spec(info_dict)
self.write_debug(f'Default format spec: {req_format}')
format_selector = self.build_format_selector(req_format)
diff --git a/yt_dlp/extractor/soundcloud.py b/yt_dlp/extractor/soundcloud.py
index 0c6f0b0..afb512d 100644
--- a/yt_dlp/extractor/soundcloud.py
+++ b/yt_dlp/extractor/soundcloud.py
@@ -314,23 +314,11 @@ class SoundcloudBaseIE(InfoExtractor):
self.write_debug(f'"{identifier}" is not a requested format, skipping')
continue
- stream = None
- for retry in self.RetryManager(fatal=False):
- try:
- stream = self._call_api(
- format_url, track_id, f'Downloading {identifier} format info JSON',
- query=query, headers=self._HEADERS)
- except ExtractorError as e:
- if isinstance(e.cause, HTTPError) and e.cause.status == 429:
- self.report_warning(
- 'You have reached the API rate limit, which is ~600 requests per '
- '10 minutes. Use the --extractor-retries and --retry-sleep options '
- 'to configure an appropriate retry count and wait time', only_once=True)
- retry.error = e.cause
- else:
- self.report_warning(e.msg)
-
- stream_url = traverse_obj(stream, ('url', {url_or_none}))
+ # XXX: if not extract_flat, 429 error must be caught where _extract_info_dict is called
+ stream_url = traverse_obj(self._call_api(
+ format_url, track_id, f'Downloading {identifier} format info JSON',
+ query=query, headers=self._HEADERS), ('url', {url_or_none}))
+
if invalid_url(stream_url):
continue
format_urls.add(stream_url)
@@ -647,7 +635,17 @@ class SoundcloudIE(SoundcloudBaseIE):
info = self._call_api(
info_json_url, full_title, 'Downloading info JSON', query=query, headers=self._HEADERS)
- return self._extract_info_dict(info, full_title, token)
+ for retry in self.RetryManager():
+ try:
+ return self._extract_info_dict(info, full_title, token)
+ except ExtractorError as e:
+ if not isinstance(e.cause, HTTPError) or not e.cause.status == 429:
+ raise
+ self.report_warning(
+ 'You have reached the API rate limit, which is ~600 requests per '
+ '10 minutes. Use the --extractor-retries and --retry-sleep options '
+ 'to configure an appropriate retry count and wait time', only_once=True)
+ retry.error = e.cause
class SoundcloudPlaylistBaseIE(SoundcloudBaseIE):
diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py
index 18e0ee9..1c0a70d 100644
--- a/yt_dlp/extractor/youtube.py
+++ b/yt_dlp/extractor/youtube.py
@@ -3130,7 +3130,8 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
def _extract_n_function_name(self, jscode):
funcname, idx = self._search_regex(
- r'\.get\("n"\)\)&&\(b=(?P<nfunc>[a-zA-Z0-9$]+)(?:\[(?P<idx>\d+)\])?\([a-zA-Z0-9]\)',
+ r'''(?x)(?:\.get\("n"\)\)&&\(b=|b=String\.fromCharCode\(110\),c=a\.get\(b\)\)&&\(c=)
+ (?P<nfunc>[a-zA-Z0-9$]+)(?:\[(?P<idx>\d+)\])?\([a-zA-Z0-9]\)''',
jscode, 'Initial JS player n function name', group=('nfunc', 'idx'))
if not idx:
return funcname
@@ -3150,17 +3151,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
func_name = self._extract_n_function_name(jscode)
- # For redundancy
- func_code = self._search_regex(
- rf'''(?xs){func_name}\s*=\s*function\s*\((?P<var>[\w$]+)\)\s*
- # NB: The end of the regex is intentionally kept strict
- {{(?P<code>.+?}}\s*return\ [\w$]+.join\(""\))}};''',
- jscode, 'nsig function', group=('var', 'code'), default=None)
- if func_code:
- func_code = ([func_code[0]], func_code[1])
- else:
- self.write_debug('Extracting nsig function with jsinterp')
- func_code = jsi.extract_function_code(func_name)
+ func_code = jsi.extract_function_code(func_name)
self.cache.store('youtube-nsig', player_id, func_code)
return jsi, player_id, func_code
diff --git a/yt_dlp/jsinterp.py b/yt_dlp/jsinterp.py
index a0f3289..851d4dc 100644
--- a/yt_dlp/jsinterp.py
+++ b/yt_dlp/jsinterp.py
@@ -636,6 +636,8 @@ class JSInterpreter:
raise self.Exception(f'{member} {msg}', expr)
def eval_method():
+ nonlocal member
+
if (variable, member) == ('console', 'debug'):
if Debugger.ENABLED:
Debugger.write(self.interpret_expression(f'[{arg_str}]', local_vars, allow_recursion))
@@ -644,6 +646,7 @@ class JSInterpreter:
types = {
'String': str,
'Math': float,
+ 'Array': list,
}
obj = local_vars.get(variable, types.get(variable, NO_DEFAULT))
if obj is NO_DEFAULT:
@@ -667,6 +670,21 @@ class JSInterpreter:
self.interpret_expression(v, local_vars, allow_recursion)
for v in self._separate(arg_str)]
+ # Fixup prototype call
+ if isinstance(obj, type) and member.startswith('prototype.'):
+ new_member, _, func_prototype = member.partition('.')[2].partition('.')
+ assertion(argvals, 'takes one or more arguments')
+ assertion(isinstance(argvals[0], obj), f'needs binding to type {obj}')
+ if func_prototype == 'call':
+ obj, *argvals = argvals
+ elif func_prototype == 'apply':
+ assertion(len(argvals) == 2, 'takes two arguments')
+ obj, argvals = argvals
+ assertion(isinstance(argvals, list), 'second argument needs to be a list')
+ else:
+ raise self.Exception(f'Unsupported Function method {func_prototype}', expr)
+ member = new_member
+
if obj is str:
if member == 'fromCharCode':
assertion(argvals, 'takes one or more arguments')
diff --git a/yt_dlp/version.py b/yt_dlp/version.py
index 323b54c..31de564 100644
--- a/yt_dlp/version.py
+++ b/yt_dlp/version.py
@@ -1,8 +1,8 @@
# Autogenerated by devscripts/update-version.py
-__version__ = '2024.07.07'
+__version__ = '2024.07.09'
-RELEASE_GIT_HEAD = 'b337d2989ce0614651d363383f6f743d977248ef'
+RELEASE_GIT_HEAD = '7ead7332af69422cee931aec3faa277288e9e212'
VARIANT = None
@@ -12,4 +12,4 @@ CHANNEL = 'stable'
ORIGIN = 'yt-dlp/yt-dlp'
-_pkg_version = '2024.07.07'
+_pkg_version = '2024.07.09'