[extractor/Douyin] Fix extraction from webpage

Closes #7431
Authored by: bashonly
pull/7454/head
bashonly 1 year ago
parent 8f05fbae2a
commit a2be9781fb
No known key found for this signature in database
GPG Key ID: 783F096F253D15B0

@ -1015,18 +1015,16 @@ class DouyinIE(TikTokBaseIE):
self.to_screen(f'{e}; trying with webpage')
webpage = self._download_webpage(url, video_id)
render_data_json = self._search_regex(
r'<script [^>]*\bid=[\'"]RENDER_DATA[\'"][^>]*>(%7B.+%7D)</script>',
webpage, 'render data', default=None)
if not render_data_json:
render_data = self._search_json(
r'<script [^>]*\bid=[\'"]RENDER_DATA[\'"][^>]*>', webpage, 'render data', video_id,
contains_pattern=r'%7B(?s:.+)%7D', fatal=False, transform_source=compat_urllib_parse_unquote)
if not render_data:
# TODO: Run verification challenge code to generate signature cookies
cookies = self._get_cookies(self._WEBPAGE_HOST)
expected = not cookies.get('s_v_web_id') or not cookies.get('ttwid')
raise ExtractorError(
'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)

Loading…
Cancel
Save