A feature-rich command-line audio/video downloader
[ie/tiktok] Improve error handling (#12445)
bashonly99ea2978757a
diff --git a/yt_dlp/extractor/tiktok.py b/yt_dlp/extractor/tiktok.pyindex 9e53b34072..19336252b1 100644--- a/yt_dlp/extractor/tiktok.py+++ b/yt_dlp/extractor/tiktok.py@@ -249,6 +249,12 @@ class TikTokBaseIE(InfoExtractor):elif fatal:raise ExtractorError('Unable to extract webpage video data')+ if not traverse_obj(video_data, ('video', {dict})) and traverse_obj(video_data, ('isContentClassified', {bool})):+ message = 'This post may not be comfortable for some audiences. Log in for access'+ if fatal:+ self.raise_login_required(message)+ self.report_warning(f'{message}. {self._login_hint()}', video_id=video_id)+return video_data, statusdef _get_subtitles(self, aweme_detail, aweme_id, user_name):@@ -895,8 +901,12 @@ class TikTokIE(TikTokBaseIE):if video_data and status == 0:return self._parse_aweme_video_web(video_data, url, video_id)- elif status == 10216:- raise ExtractorError('This video is private', expected=True)+ elif status in (10216, 10222):+ # 10216: private post; 10222: private account+ self.raise_login_required(+ 'You do not have permission to view this post. Log into an account that has access')+ elif status == 10204:+ raise ExtractorError('Your IP address is blocked from accessing this post', expected=True)raise ExtractorError(f'Video not available, status code {status}', video_id=video_id)