diff options
author | bashonly <88596187+bashonly@users.noreply.github.com> | 2024-06-13 18:16:43 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-13 23:16:43 +0000 |
commit | ea88129784fcbb6987161df9ba05909325d8e2e9 (patch) | |
tree | 10ee7535827df5af78f793364690bf07f843f8d5 | |
parent | b8e2a5e0e1030076f833917906e19bb6c7b318f6 (diff) |
[ie/tiktok] Detect and raise when login is required (#10124)
Authored by: bashonly
-rw-r--r-- | yt_dlp/extractor/tiktok.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/yt_dlp/extractor/tiktok.py b/yt_dlp/extractor/tiktok.py index dc74d4a1f..48934fc6b 100644 --- a/yt_dlp/extractor/tiktok.py +++ b/yt_dlp/extractor/tiktok.py @@ -213,8 +213,19 @@ class TikTokBaseIE(InfoExtractor): return self._parse_aweme_video_app(aweme_detail) def _extract_web_data_and_status(self, url, video_id, fatal=True): - webpage = self._download_webpage(url, video_id, headers={'User-Agent': 'Mozilla/5.0'}, fatal=fatal) or '' - video_data, status = {}, None + video_data, status = {}, -1 + + res = self._download_webpage_handle(url, video_id, fatal=fatal, headers={'User-Agent': 'Mozilla/5.0'}) + if res is False: + return video_data, status + + webpage, urlh = res + if urllib.parse.urlparse(urlh.url).path == '/login': + message = 'TikTok is requiring login for access to this content' + if fatal: + self.raise_login_required(message) + self.report_warning(f'{message}. {self._login_hint()}') + return video_data, status if universal_data := self._get_universal_data(webpage, video_id): self.write_debug('Found universal data for rehydration') |