From 4a4aabe3745d95ed2c2ac9bc40148932b6ba6ca6 Mon Sep 17 00:00:00 2001 From: bashonly Date: Sat, 22 Feb 2025 16:43:42 -0600 Subject: [PATCH] [ie/tiktok] Improve error handling Authored by: bashonly --- yt_dlp/extractor/tiktok.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/yt_dlp/extractor/tiktok.py b/yt_dlp/extractor/tiktok.py index 9e53b3407..ca1225ed6 100644 --- a/yt_dlp/extractor/tiktok.py +++ b/yt_dlp/extractor/tiktok.py @@ -249,6 +249,19 @@ def _extract_web_data_and_status(self, url, video_id, fatal=True): elif fatal: raise ExtractorError('Unable to extract webpage video data') + if not video_data.get('video'): + msg = None + if traverse_obj(video_data, ('isContentClassified', {bool})): + msg = 'This post may not be comfortable for some audiences. Log in for access' + elif traverse_obj(video_data, ( + ('secret', 'forFriend', 'privateItem'), {bool}, {lambda x: x is True or None}, any), + ): + msg = 'You do not have permission to view this post. Log into an account that has access' + if msg and fatal: + self.raise_login_required(msg) + elif msg: + self.report_warning(msg, video_id=video_id) + return video_data, status def _get_subtitles(self, aweme_detail, aweme_id, user_name):