1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-07 11:42:43 +01:00

[tiktok] Extract user thumbnail

Closes #2186
Authored by: pukkandan, MinePlayersPE
This commit is contained in:
pukkandan 2022-01-10 19:24:10 +05:30
parent f1150b9e1e
commit b31874334d
No known key found for this signature in database
GPG Key ID: 0F00D95A001F4698
2 changed files with 20 additions and 10 deletions

View File

@ -9,7 +9,7 @@
str_or_none,
)
#2270
class FunkIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.|origin\.)?funk\.net/(?:channel|playlist)/[^/]+/(?P<display_id>[0-9a-z-]+)-(?P<id>\d+)'
_TESTS = [{

View File

@ -16,6 +16,7 @@
ExtractorError,
int_or_none,
join_nonempty,
LazyList,
str_or_none,
traverse_obj,
try_get,
@ -455,6 +456,7 @@ class TikTokUserIE(TikTokBaseIE):
'info_dict': {
'id': '6935371178089399301',
'title': 'corgibobaa',
'thumbnail': r're:https://.+_1080x1080\.webp'
},
'expected_warnings': ['Retrying']
}, {
@ -463,6 +465,7 @@ class TikTokUserIE(TikTokBaseIE):
'info_dict': {
'id': '79005827461758976',
'title': 'meme',
'thumbnail': r're:https://.+_1080x1080\.webp'
},
'expected_warnings': ['Retrying']
}]
@ -486,7 +489,7 @@ def _entries(self, webpage, user_id, username):
cursor = data_json['cursor']
'''
def _entries_api(self, webpage, user_id, username):
def _video_entries_api(self, webpage, user_id, username):
query = {
'user_id': user_id,
'count': 21,
@ -509,24 +512,31 @@ def _entries_api(self, webpage, user_id, username):
continue
raise
break
for video in post_list.get('aweme_list', []):
yield {
**self._parse_aweme_video_app(video),
'extractor_key': TikTokIE.ie_key(),
'extractor': 'TikTok',
'webpage_url': f'https://tiktok.com/@{user_id}/video/{video["aweme_id"]}',
}
yield from post_list.get('aweme_list', [])
if not post_list.get('has_more'):
break
query['max_cursor'] = post_list['max_cursor']
def _entries_api(self, user_id, videos):
for video in videos:
yield {
**self._parse_aweme_video_app(video),
'extractor_key': TikTokIE.ie_key(),
'extractor': 'TikTok',
'webpage_url': f'https://tiktok.com/@{user_id}/video/{video["aweme_id"]}',
}
def _real_extract(self, url):
user_name = self._match_id(url)
webpage = self._download_webpage(url, user_name, headers={
'User-Agent': 'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)'
})
user_id = self._html_search_regex(r'snssdk\d*://user/profile/(\d+)', webpage, 'user ID')
return self.playlist_result(self._entries_api(webpage, user_id, user_name), user_id, user_name)
videos = LazyList(self._video_entries_api(webpage, user_id, user_name))
thumbnail = traverse_obj(videos, (0, 'author', 'avatar_larger', 'url_list', 0))
return self.playlist_result(self._entries_api(user_id, videos), user_id, user_name, thumbnail=thumbnail)
class TikTokBaseListIE(TikTokBaseIE):