From b94f29355304d8ca95c046697ab630cf58eb2816 Mon Sep 17 00:00:00 2001 From: wranai Date: Wed, 10 Nov 2021 23:43:55 +0100 Subject: [PATCH] fix tiktok when logged in tiktok now shows metadata in a diff format when logged in --- youtube_dl/extractor/tiktok.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/youtube_dl/extractor/tiktok.py b/youtube_dl/extractor/tiktok.py index 4faa6de54..f698e4cf4 100644 --- a/youtube_dl/extractor/tiktok.py +++ b/youtube_dl/extractor/tiktok.py @@ -107,10 +107,18 @@ class TikTokIE(TikTokBaseIE): def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) - page_props = self._parse_json(self._search_regex( - r']+\bid=["\']__NEXT_DATA__[^>]+>\s*({.+?})\s*]+\bid=["\']__NEXT_DATA__[^>]+>\s*({.+?})\s*]+\bid=["\']sigi-persisted-data[^>]+>window\[\'SIGI_STATE\']=({.+?});window\[', + webpage, 'data'), video_id) + data = try_get(page_props, lambda x: x['ItemModule'][video_id], dict) + author = try_get(page_props, lambda x: x['UserModule']['users'][data['author']], dict) + data['author'] = author if not data and page_props.get('statusCode') == 10216: raise ExtractorError('This video is private', expected=True) return self._extract_video(data, video_id)