Skip to content

Commit

Permalink
[ie/triller] Fix unlisted video extraction (#7670)
Browse files Browse the repository at this point in the history
Authored by: bashonly
  • Loading branch information
bashonly committed Jul 23, 2023
1 parent 86aea0d commit 39837ae
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions yt_dlp/extractor/triller.py
Expand Up @@ -66,13 +66,6 @@ def _get_comments(self, video_id, limit=15):
'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')
Expand Down Expand Up @@ -231,8 +224,6 @@ def _real_extract(self, url):
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)


Expand Down Expand Up @@ -287,9 +278,14 @@ def _entries(self, username, user_id, limit=6):
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:
Expand Down

0 comments on commit 39837ae

Please sign in to comment.