Fixed tiktok.py

The JSON formatting of the response changed, corrected.

#TESTING
Successfully downloaded and played a tiktok video
This commit is contained in:
Dan Walker 2020-10-25 06:08:57 -07:00
parent c3a7565610
commit 1666c2709f

View file

@ -14,17 +14,17 @@
class TikTokBaseIE(InfoExtractor): class TikTokBaseIE(InfoExtractor):
def _extract_aweme(self, video_data, webpage, url): def _extract_aweme(self, video_data, webpage, url):
video_info = try_get( video_info = try_get(
video_data, lambda x: x['videoData']['itemInfos'], dict) video_data, lambda x: x['itemInfo']['itemStruct'], dict)
author_info = try_get( author_info = try_get(
video_data, lambda x: x['videoData']['authorInfos'], dict) video_data, lambda x: x['itemInfo']['itemStruct']['author'], dict)
share_info = try_get(video_data, lambda x: x['shareMeta'], dict) share_info = try_get(video_data, lambda x: x['itemInfo']['shareMeta'], dict)
unique_id = str_or_none(author_info.get('uniqueId')) unique_id = str_or_none(author_info.get('uniqueId'))
timestamp = try_get(video_info, lambda x: int(x['createTime']), int) timestamp = try_get(video_info, lambda x: int(x['createTime']), int)
date = datetime.fromtimestamp(timestamp).strftime('%Y%m%d') date = datetime.fromtimestamp(timestamp).strftime('%Y%m%d')
height = try_get(video_info, lambda x: x['video']['videoMeta']['height'], int) height = try_get(video_info, lambda x: x['video']['height'], int)
width = try_get(video_info, lambda x: x['video']['videoMeta']['width'], int) width = try_get(video_info, lambda x: x['video']['width'], int)
thumbnails = [] thumbnails = []
thumbnails.append({ thumbnails.append({
'url': video_info.get('thumbnail') or self._og_search_thumbnail(webpage), 'url': video_info.get('thumbnail') or self._og_search_thumbnail(webpage),
@ -34,7 +34,7 @@ def _extract_aweme(self, video_data, webpage, url):
formats = [] formats = []
formats.append({ formats.append({
'url': try_get(video_info, lambda x: x['video']['urls'][0]), 'url': try_get(video_info, lambda x: x['video']['playAddr']),
'ext': 'mp4', 'ext': 'mp4',
'height': height, 'height': height,
'width': width 'width': width