From 39837ae3199aa934299badbd0d63243ed639e6c8 Mon Sep 17 00:00:00 2001 From: bashonly <88596187+bashonly@users.noreply.github.com> Date: Sun, 23 Jul 2023 18:29:45 -0500 Subject: [PATCH] [ie/triller] Fix unlisted video extraction (#7670) Authored by: bashonly --- yt_dlp/extractor/triller.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/yt_dlp/extractor/triller.py b/yt_dlp/extractor/triller.py index c5d01c8271..56e51fea8f 100644 --- a/yt_dlp/extractor/triller.py +++ b/yt_dlp/extractor/triller.py @@ -66,13 +66,6 @@ class TrillerBaseIE(InfoExtractor): 'timestamp': ('timestamp', {unified_timestamp}), })) - def _check_user_info(self, user_info): - if user_info.get('private') and not user_info.get('followed_by_me'): - raise ExtractorError('This video is private', expected=True) - elif traverse_obj(user_info, 'blocked_by_user', 'blocking_user'): - raise ExtractorError('The author of the video is blocked', expected=True) - return user_info - def _parse_video_info(self, video_info, username, user_id, display_id=None): video_id = str(video_info['id']) display_id = display_id or video_info.get('video_uuid') @@ -231,8 +224,6 @@ class TrillerIE(TrillerBaseIE): f'{self._API_BASE_URL}/api/videos/{display_id}', display_id, headers=self._API_HEADERS)['videos'][0] - self._check_user_info(video_info.get('user') or {}) - return self._parse_video_info(video_info, username, None, display_id) @@ -287,9 +278,14 @@ class TrillerUserIE(TrillerBaseIE): def _real_extract(self, url): username = self._match_id(url) - user_info = self._check_user_info(self._download_json( + user_info = traverse_obj(self._download_json( f'{self._API_BASE_URL}/api/users/by_username/{username}', - username, note='Downloading user info', headers=self._API_HEADERS)['user']) + username, note='Downloading user info', headers=self._API_HEADERS), ('user', {dict})) or {} + + if user_info.get('private') and user_info.get('followed_by_me') not in (True, 'true'): + raise ExtractorError('This user profile is private', expected=True) + elif traverse_obj(user_info, (('blocked_by_user', 'blocking_user'), {bool}), get_all=False): + raise ExtractorError('The author of the video is blocked', expected=True) user_id = str_or_none(user_info.get('user_id')) if not user_id: