Skip to content

Commit

Permalink
[CI] auto update yt_dlp to upstream commit 8ca1d57ed08d00efa117820a5a…
Browse files Browse the repository at this point in the history
…82f763b20e2d1d
  • Loading branch information
github-actions[bot] committed Jun 22, 2024
1 parent 1a9e95a commit ab5c1aa
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 28 deletions.
3 changes: 3 additions & 0 deletions lib/yt_dlp/extractor/facebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,9 @@ def parse_graphql_video(video):
'url': playable_url,
})
extract_dash_manifest(video, formats)
if not formats:
# Do not append false positive entry w/o any formats
return

automatic_captions, subtitles = {}, {}
is_broadcast = traverse_obj(video, ('is_video_broadcast', {bool}))
Expand Down
32 changes: 19 additions & 13 deletions lib/yt_dlp/extractor/tiktok.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
try_call,
try_get,
url_or_none,
urlencode_postdata,
)


Expand All @@ -43,8 +44,8 @@ class TikTokBaseIE(InfoExtractor):
'iid': None,
# TikTok (KR/PH/TW/TH/VN) = trill, TikTok (rest of world) = musical_ly, Douyin = aweme
'app_name': 'musical_ly',
'app_version': '34.1.2',
'manifest_app_version': '2023401020',
'app_version': '35.1.3',
'manifest_app_version': '2023501030',
# "app id": aweme = 1128, trill = 1180, musical_ly = 1233, universal = 0
'aid': '0',
}
Expand Down Expand Up @@ -114,7 +115,7 @@ def _get_universal_data(self, webpage, display_id):
'universal data', display_id, end_pattern=r'</script>', default={}),
('__DEFAULT_SCOPE__', {dict})) or {}

def _call_api_impl(self, ep, query, video_id, fatal=True,
def _call_api_impl(self, ep, video_id, query=None, data=None, headers=None, fatal=True,
note='Downloading API JSON', errnote='Unable to download API page'):
self._set_cookie(self._API_HOSTNAME, 'odin_tt', ''.join(random.choices('0123456789abcdef', k=160)))
webpage_cookies = self._get_cookies(self._WEBPAGE_HOST)
Expand All @@ -125,7 +126,8 @@ def _call_api_impl(self, ep, query, video_id, fatal=True,
fatal=fatal, note=note, errnote=errnote, headers={
'User-Agent': self._APP_USER_AGENT,
'Accept': 'application/json',
}, query=query)
**(headers or {}),
}, query=query, data=data)

def _build_api_query(self, query):
return filter_dict({
Expand Down Expand Up @@ -174,7 +176,7 @@ def _build_api_query(self, query):
'openudid': ''.join(random.choices('0123456789abcdef', k=16)),
})

def _call_api(self, ep, query, video_id, fatal=True,
def _call_api(self, ep, video_id, query=None, data=None, headers=None, fatal=True,
note='Downloading API JSON', errnote='Unable to download API page'):
if not self._APP_INFO and not self._get_next_app_info():
message = 'No working app info is available'
Expand All @@ -187,9 +189,11 @@ def _call_api(self, ep, query, video_id, fatal=True,
max_tries = len(self._APP_INFO_POOL) + 1 # _APP_INFO_POOL + _APP_INFO
for count in itertools.count(1):
self.write_debug(str(self._APP_INFO))
real_query = self._build_api_query(query)
real_query = self._build_api_query(query or {})
try:
return self._call_api_impl(ep, real_query, video_id, fatal, note, errnote)
return self._call_api_impl(
ep, video_id, query=real_query, data=data, headers=headers,
fatal=fatal, note=note, errnote=errnote)
except ExtractorError as e:
if isinstance(e.cause, json.JSONDecodeError) and e.cause.pos == 0:
message = str(e.cause or e.msg)
Expand All @@ -204,12 +208,13 @@ def _call_api(self, ep, query, video_id, fatal=True,
raise

def _extract_aweme_app(self, aweme_id):
feed_list = self._call_api(
'feed', {'aweme_id': aweme_id}, aweme_id, note='Downloading video feed',
errnote='Unable to download video feed').get('aweme_list') or []
aweme_detail = next((aweme for aweme in feed_list if str(aweme.get('aweme_id')) == aweme_id), None)
aweme_detail = traverse_obj(
self._call_api('multi/aweme/detail', aweme_id, data=urlencode_postdata({
'aweme_ids': f'[{aweme_id}]',
'request_source': '0',
}), headers={'X-Argus': ''}), ('aweme_details', 0, {dict}))
if not aweme_detail:
raise ExtractorError('Unable to find video in feed', video_id=aweme_id)
raise ExtractorError('Unable to extract aweme detail info', video_id=aweme_id)
return self._parse_aweme_video_app(aweme_detail)

def _extract_web_data_and_status(self, url, video_id, fatal=True):
Expand Down Expand Up @@ -1037,7 +1042,8 @@ def _entries(self, list_id, display_id):
for retry in self.RetryManager():
try:
post_list = self._call_api(
self._API_ENDPOINT, query, display_id, note=f'Downloading video list page {page}',
self._API_ENDPOINT, display_id, query=query,
note=f'Downloading video list page {page}',
errnote='Unable to download video list')
except ExtractorError as e:
if isinstance(e.cause, json.JSONDecodeError) and e.cause.pos == 0:
Expand Down
27 changes: 13 additions & 14 deletions lib/yt_dlp/extractor/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -3847,6 +3847,13 @@ def build_fragments(f):
itag_qualities[itag] = quality
if height:
res_qualities[height] = quality

is_default = audio_track.get('audioIsDefault')
is_descriptive = 'descriptive' in (audio_track.get('displayName') or '').lower()
language_code = audio_track.get('id', '').split('.')[0]
if language_code and is_default:
original_language = language_code

# FORMAT_STREAM_TYPE_OTF(otf=1) requires downloading the init fragment
# (adding `&sq=0` to the URL) and parsing emsg box to determine the
# number of fragment that would subsequently requested with (`&sq=N`)
Expand All @@ -3872,7 +3879,6 @@ def build_fragments(f):
continue

query = parse_qs(fmt_url)
throttled = False
if query.get('n'):
try:
decrypt_nsig = self._cached(self._decrypt_nsig, 'nsig', query['n'][0])
Expand All @@ -3886,22 +3892,16 @@ def build_fragments(f):
f'to workaround the issue. {PhantomJSwrapper.INSTALL_HINT}\n')
if player_url:
self.report_warning(
f'nsig extraction failed: You may experience throttling for some formats\n{phantomjs_hint}'
f'nsig extraction failed: Some formats may be missing\n{phantomjs_hint}'
f' n = {query["n"][0]} ; player = {player_url}', video_id=video_id, only_once=True)
self.write_debug(e, only_once=True)
else:
self.report_warning(
'Cannot decrypt nsig without player_url: You may experience throttling for some formats',
'Cannot decrypt nsig without player_url: Some formats may be missing',
video_id=video_id, only_once=True)
throttled = True
continue

tbr = float_or_none(fmt.get('averageBitrate') or fmt.get('bitrate'), 1000)
is_default = audio_track.get('audioIsDefault')
is_descriptive = 'descriptive' in (audio_track.get('displayName') or '').lower()
language_code = audio_track.get('id', '').split('.')[0]
if language_code and is_default:
original_language = language_code

format_duration = traverse_obj(fmt, ('approxDurationMs', {lambda x: float_or_none(x, 1000)}))
# Some formats may have much smaller duration than others (possibly damaged during encoding)
# E.g. 2-nOtRESiUc Ref: https://github.com/yt-dlp/yt-dlp/issues/2823
Expand Down Expand Up @@ -3932,12 +3932,11 @@ def build_fragments(f):
name, fmt.get('isDrc') and 'DRC',
try_get(fmt, lambda x: x['projectionType'].replace('RECTANGULAR', '').lower()),
try_get(fmt, lambda x: x['spatialAudioType'].replace('SPATIAL_AUDIO_TYPE_', '').lower()),
throttled and 'THROTTLED', is_damaged and 'DAMAGED', is_broken and 'BROKEN',
is_damaged and 'DAMAGED', is_broken and 'BROKEN',
(self.get_param('verbose') or all_formats) and client_name,
delim=', '),
# Format 22 is likely to be damaged. See https://github.com/yt-dlp/yt-dlp/issues/3372
'source_preference': ((-10 if throttled else -5 if itag == '22' else -1)
+ (100 if 'Premium' in name else 0)),
'source_preference': (-5 if itag == '22' else -1) + (100 if 'Premium' in name else 0),
'fps': fps if fps > 1 else None, # For some formats, fps is wrongly returned as 1
'audio_channels': fmt.get('audioChannels'),
'height': height,
Expand Down Expand Up @@ -4357,7 +4356,7 @@ def is_bad_format(fmt):
'playable_in_embed': get_first(playability_statuses, 'playableInEmbed'),
'live_status': live_status,
'release_timestamp': live_start_time,
'_format_sort_fields': ( # source_preference is lower for throttled/potentially damaged formats
'_format_sort_fields': ( # source_preference is lower for potentially damaged formats
'quality', 'res', 'fps', 'hdr:12', 'source', 'vcodec:vp9.2', 'channels', 'acodec', 'lang', 'proto'),
}

Expand Down
2 changes: 1 addition & 1 deletion lib/yt_dlp_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7aa322c02cec54eb77154a89da7e400194f0bd03
8ca1d57ed08d00efa117820a5a82f763b20e2d1d

0 comments on commit ab5c1aa

Please sign in to comment.