mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-30 07:28:19 +01:00
Compare commits
3 Commits
2e2513154c
...
20541c89d3
Author | SHA1 | Date | |
---|---|---|---|
|
20541c89d3 | ||
|
4b5eec0aaa | ||
|
dc3c1f4a56 |
|
@ -121,12 +121,21 @@ def _download_fragment(self, ctx, frag_url, info_dict, headers=None, request_dat
|
|||
frag_resume_len = self.filesize_or_none(self.temp_name(fragment_filename))
|
||||
fragment_info_dict['frag_resume_len'] = ctx['frag_resume_len'] = frag_resume_len
|
||||
|
||||
execute_before_frag_dl = info_dict.get('_fragment_hook_before_dl')
|
||||
if execute_before_frag_dl is not None and callable(execute_before_frag_dl):
|
||||
execute_before_frag_dl(fragment_filename, fragment_info_dict, ctx)
|
||||
|
||||
success, _ = ctx['dl'].download(fragment_filename, fragment_info_dict)
|
||||
if not success:
|
||||
return False
|
||||
if fragment_info_dict.get('filetime'):
|
||||
ctx['fragment_filetime'] = fragment_info_dict.get('filetime')
|
||||
ctx['fragment_filename_sanitized'] = fragment_filename
|
||||
|
||||
execute_after_frag_dl = info_dict.get('_fragment_hook_after_dl')
|
||||
if execute_after_frag_dl is not None and callable(execute_after_frag_dl):
|
||||
execute_after_frag_dl(fragment_filename, fragment_info_dict, ctx)
|
||||
|
||||
return True
|
||||
|
||||
def _read_fragment(self, ctx):
|
||||
|
|
|
@ -59,16 +59,15 @@ def _extract_from_api(self, video_id, tld):
|
|||
'Accept': 'application/json',
|
||||
}, fatal=False, impersonate=True) or {}
|
||||
|
||||
status = response.get('room_status')
|
||||
if status != 'public':
|
||||
if error := self._ERROR_MAP.get(status):
|
||||
raise ExtractorError(error, expected=True)
|
||||
self.report_warning('Falling back to webpage extraction')
|
||||
return None
|
||||
|
||||
m3u8_url = response.get('url')
|
||||
if not m3u8_url:
|
||||
status = response.get('room_status')
|
||||
if error := self._ERROR_MAP.get(status):
|
||||
raise ExtractorError(error, expected=True)
|
||||
if status == 'public':
|
||||
self.raise_geo_restricted()
|
||||
self.report_warning(f'Got status "{status}" from API; falling back to webpage extraction')
|
||||
return None
|
||||
|
||||
return {
|
||||
'id': video_id,
|
||||
|
|
|
@ -405,6 +405,16 @@ class InfoExtractor:
|
|||
extracted will not be available to output template and
|
||||
match_filter. So, only "comments" and "comment_count" are
|
||||
currently allowed to be extracted via this method.
|
||||
_fragment_hook_before_dl: A function to be called just before fragment is
|
||||
downloaded. It should take three positional arguments:
|
||||
'fragment_filename', 'fragment_info_dict' and 'ctx'.
|
||||
This is useful for special sites that need to change
|
||||
access cookies on every fragment/every few seconds.
|
||||
_fragment_hook_after_dl: A function to be called right after fragment is
|
||||
downloaded. It should take three positional arguments:
|
||||
'fragment_filename', 'fragment_info_dict' and 'ctx'.
|
||||
This is useful for special sites that need to change
|
||||
access cookies on every fragment/every few seconds.
|
||||
|
||||
The following fields should only be used when the video belongs to some logical
|
||||
chapter or section:
|
||||
|
|
Loading…
Reference in New Issue
Block a user