viking_unet

new simple tiktok downloader

Jun 23rd, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. import io
  2. import requests
  3.  
  4. video_url = 'https://www.tiktok.com/@ceciliaannborne/video/6817602864228207878'
  5.  
  6. r = requests.get(video_url, headers={"method": "GET", "accept-encoding": "utf-8", "user-agent": 'Mazila'})
  7. content_url = r.text.split("\"contentUrl\":\"")[1].split("\"")[0] # здесь можно сделать проще - заменить регуляркой
  8. print('content_url     =',content_url)
  9.  
  10. with requests.get(content_url, stream=True) as response:
  11.     response.raise_for_status()
  12.     pos = response.content.find(b'vid:')
  13.     bs = io.BytesIO(response.content)
  14.     bs.seek(pos+4)
  15.     vid = bs.read(32).decode('utf-8')
  16.  
  17. print('vid             =',content_url)    
  18. clear_video_url = 'https://api2-16-h2.musical.ly/aweme/v1/play/?video_id={video_id}&vr_type=0&is_play_url=1&source=PackSourceEnum_PUBLISH&media_type=4'
  19.  
  20. print('clear_video_url =', clear_video_url)
  21. response = requests.head(clear_video_url.format(video_id = vid), headers={'user-agent': 'okhttp'}, allow_redirects=True)
  22.  
  23. print('true clear  url =', response.url)
Add Comment
Please, Sign In to add comment