[tiktok] Extract user thumbnail

Closes #2186
Authored by: pukkandan, MinePlayersPE
pull/2294/head^2
pukkandan 3 years ago
parent f1150b9e1e
commit b31874334d
No known key found for this signature in database
GPG Key ID: 0F00D95A001F4698

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

@ -16,6 +16,7 @@ from ..utils import (
ExtractorError, ExtractorError,
int_or_none, int_or_none,
join_nonempty, join_nonempty,
LazyList,
str_or_none, str_or_none,
traverse_obj, traverse_obj,
try_get, try_get,
@ -455,6 +456,7 @@ class TikTokUserIE(TikTokBaseIE):
'info_dict': { 'info_dict': {
'id': '6935371178089399301', 'id': '6935371178089399301',
'title': 'corgibobaa', 'title': 'corgibobaa',
'thumbnail': r're:https://.+_1080x1080\.webp'
}, },
'expected_warnings': ['Retrying'] 'expected_warnings': ['Retrying']
}, { }, {
@ -463,6 +465,7 @@ class TikTokUserIE(TikTokBaseIE):
'info_dict': { 'info_dict': {
'id': '79005827461758976', 'id': '79005827461758976',
'title': 'meme', 'title': 'meme',
'thumbnail': r're:https://.+_1080x1080\.webp'
}, },
'expected_warnings': ['Retrying'] 'expected_warnings': ['Retrying']
}] }]
@ -486,7 +489,7 @@ class TikTokUserIE(TikTokBaseIE):
cursor = data_json['cursor'] cursor = data_json['cursor']
''' '''
def _entries_api(self, webpage, user_id, username): def _video_entries_api(self, webpage, user_id, username):
query = { query = {
'user_id': user_id, 'user_id': user_id,
'count': 21, 'count': 21,
@ -509,24 +512,31 @@ class TikTokUserIE(TikTokBaseIE):
continue continue
raise raise
break break
for video in post_list.get('aweme_list', []): yield from 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"]}',
}
if not post_list.get('has_more'): if not post_list.get('has_more'):
break break
query['max_cursor'] = post_list['max_cursor'] 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): def _real_extract(self, url):
user_name = self._match_id(url) user_name = self._match_id(url)
webpage = self._download_webpage(url, user_name, headers={ webpage = self._download_webpage(url, user_name, headers={
'User-Agent': 'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)' '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') 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): class TikTokBaseListIE(TikTokBaseIE):

Loading…
Cancel
Save