[tiktok] fix extraction

This commit is contained in:
Mort Yao 2019-04-25 15:35:35 +02:00
parent f6b28b7697
commit 2e5ced0700
No known key found for this signature in database
GPG Key ID: 07DA00CB78203251

View File

@ -6,12 +6,10 @@ from ..common import *
def tiktok_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
html = get_html(url, faker=True)
title = r1(r'<title>(.*?)</title>', html)
title = r1(r'<title.*?>(.*?)</title>', html)
video_id = r1(r'/video/(\d+)', url) or r1(r'musical\?id=(\d+)', html)
title = '%s [%s]' % (title, video_id)
dataText = r1(r'var data = \[(.*)\] ', html) or r1(r'var data = (\{.*\})', html)
data = json.loads(dataText)
source = 'http:' + data['video']['play_addr']['url_list'][0]
source = r1(r'<video .*?src="([^"]+)"', html)
mime, ext, size = url_info(source)
print_info(site_info, title, mime, size)