mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-10 09:07:58 +01:00
[extractor/Douyin] Fix extraction from webpage
Closes #7431 Authored by: bashonly
This commit is contained in:
parent
8f05fbae2a
commit
a2be9781fb
1 changed files with 4 additions and 6 deletions
|
@ -1015,18 +1015,16 @@ def _real_extract(self, url):
|
||||||
self.to_screen(f'{e}; trying with webpage')
|
self.to_screen(f'{e}; trying with webpage')
|
||||||
|
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
render_data_json = self._search_regex(
|
render_data = self._search_json(
|
||||||
r'<script [^>]*\bid=[\'"]RENDER_DATA[\'"][^>]*>(%7B.+%7D)</script>',
|
r'<script [^>]*\bid=[\'"]RENDER_DATA[\'"][^>]*>', webpage, 'render data', video_id,
|
||||||
webpage, 'render data', default=None)
|
contains_pattern=r'%7B(?s:.+)%7D', fatal=False, transform_source=compat_urllib_parse_unquote)
|
||||||
if not render_data_json:
|
if not render_data:
|
||||||
# TODO: Run verification challenge code to generate signature cookies
|
# TODO: Run verification challenge code to generate signature cookies
|
||||||
cookies = self._get_cookies(self._WEBPAGE_HOST)
|
cookies = self._get_cookies(self._WEBPAGE_HOST)
|
||||||
expected = not cookies.get('s_v_web_id') or not cookies.get('ttwid')
|
expected = not cookies.get('s_v_web_id') or not cookies.get('ttwid')
|
||||||
raise ExtractorError(
|
raise ExtractorError(
|
||||||
'Fresh cookies (not necessarily logged in) are needed', expected=expected)
|
'Fresh cookies (not necessarily logged in) are needed', expected=expected)
|
||||||
|
|
||||||
render_data = self._parse_json(
|
|
||||||
render_data_json, video_id, transform_source=compat_urllib_parse_unquote)
|
|
||||||
return self._parse_aweme_video_web(get_first(render_data, ('aweme', 'detail')), url, video_id)
|
return self._parse_aweme_video_web(get_first(render_data, ('aweme', 'detail')), url, video_id)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue