[tiktok] improve regexp

This commit is contained in:
Mort Yao 2022-04-29 23:23:59 +02:00
parent e2217bedd2
commit 95d6d2e570
No known key found for this signature in database
GPG Key ID: 07DA00CB78203251

View File

@ -6,10 +6,10 @@ from ..common import *
def tiktok_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
while True:
m = re.match('https://([^/]+)(/.*)', url)
host = m.group(1)
m = re.match('(https?://)?([^/]+)(/.*)', url)
host = m.group(2)
if host == 'www.tiktok.com': # canonical URL reached
url = m.group(2).split('?')[0]
url = m.group(3).split('?')[0]
vid = url.split('/')[3] # should be a string of numbers
break
else: