Skip to content

Commit

Permalink
[tiktok] fix extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
soimort committed May 21, 2024
1 parent 97bb0a6 commit bf3d82b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/you_get/extractors/tiktok.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ def tiktok_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
tt_chain_token = r1('tt_chain_token=([^;]+);', set_cookie)
headers['Cookie'] = 'tt_chain_token=%s' % tt_chain_token

data = r1(r'window\[\'SIGI_STATE\'\]=(.*?);window\[\'SIGI_RETRY\'\]', html) or \
r1(r'<script id="SIGI_STATE" type="application/json">(.*?)</script>', html)
data = r1(r'<script id="__UNIVERSAL_DATA_FOR_REHYDRATION__" type="application/json">(.*?)</script>', html)
info = json.loads(data)
downloadAddr = info['ItemModule'][vid]['video']['downloadAddr']
author = info['ItemModule'][vid]['author'] # same as uniqueId
nickname = info['UserModule']['users'][author]['nickname']
itemStruct = info['__DEFAULT_SCOPE__']['webapp.video-detail']['itemInfo']['itemStruct']
downloadAddr = itemStruct['video']['downloadAddr']
author = itemStruct['author']['uniqueId']
nickname = itemStruct['author']['nickname']
title = '%s [%s]' % (nickname or author, vid)

mime, ext, size = url_info(downloadAddr, headers=headers)
Expand Down

0 comments on commit bf3d82b

Please sign in to comment.