Skip to content

Commit

Permalink
[tiktok] support short URLs (vt.tiktok.com)
Browse files Browse the repository at this point in the history
  • Loading branch information
soimort committed Aug 2, 2024
1 parent 79aaec4 commit bc0e680
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/you_get/extractors/tiktok.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def tiktok_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
m = re.match('(https?://)?([^/]+)(/.*)', url)
host = m.group(2)
if host != 'www.tiktok.com': # non-canonical URL
if host == 'vt.tiktok.com': # short URL
url = get_location(url)
vid = r1(r'/video/(\d+)', url)
url = 'https://www.tiktok.com/@/video/%s/' % vid
host = 'www.tiktok.com'
Expand Down
8 changes: 5 additions & 3 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ def test_acfun(self):
#)

def test_tiktok(self):
tiktok.download('https://www.tiktok.com/@nmb48_official/video/6850796940293164290', info_only=True)
tiktok.download('https://www.tiktok.com/@/video/6850796940293164290', info_only=True)
tiktok.download('https://t.tiktok.com/i18n/share/video/6850796940293164290/', info_only=True)
tiktok.download('https://www.tiktok.com/@zukky_48/video/7398162058153315605', info_only=True)
tiktok.download('https://www.tiktok.com/@/video/7398162058153315605', info_only=True)
tiktok.download('https://t.tiktok.com/i18n/share/video/7398162058153315605/', info_only=True)
tiktok.download('https://vt.tiktok.com/ZSYKjKt6M/', info_only=True)

def test_twitter(self):
twitter.download('https://twitter.com/elonmusk/status/1530516552084234244', info_only=True)
twitter.download('https://x.com/elonmusk/status/1530516552084234244', info_only=True)

def test_weibo(self):
miaopai.download('https://video.weibo.com/show?fid=1034:4825403706245135', info_only=True)
Expand Down

0 comments on commit bc0e680

Please sign in to comment.