Skip to content

Commit

Permalink
[tiktok] detect private videos(closes #28453)
Browse files Browse the repository at this point in the history
  • Loading branch information
remitamine committed Mar 21, 2021
1 parent 7e79ba7 commit 21ccd0d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions youtube_dl/extractor/tiktok.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,12 @@ def _real_initialize(self):
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
data = self._parse_json(self._search_regex(
page_props = self._parse_json(self._search_regex(
r'<script[^>]+\bid=["\']__NEXT_DATA__[^>]+>\s*({.+?})\s*</script',
webpage, 'data'), video_id)['props']['pageProps']['itemInfo']['itemStruct']
webpage, 'data'), video_id)['props']['pageProps']
data = try_get(page_props, lambda x: x['itemInfo']['itemStruct'], dict)
if not data and page_props.get('statusCode') == 10216:
raise ExtractorError('This video is private', expected=True)
return self._extract_video(data, video_id)


Expand Down

0 comments on commit 21ccd0d

Please sign in to comment.