Advertisement
Eccat

Untitled

Dec 11th, 2021
1,161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.46 KB | None | 0 0
  1. from itertools import count
  2.  
  3. from TikTokAPI import TikTokAPI
  4. import requests
  5. import os
  6. import re
  7.  
  8. cookie = {
  9.     "s_v_web_id": "verify_kwyhf5bg_baGBaGqG_irRM_40aM_BMEB_sssRkLG6HgDa",
  10.     "tt_webid": "1%7CFAfwfCuIt7hyY0wcHd1w16HzJopHHQ8W8-Lr3FhqigU%7C1639025425%7Cf3552a7e094df332a022eec25deecdf634570f1785da38f1e0be9881d5952973"
  11. }
  12. api = TikTokAPI(cookie=cookie)
  13. response = api.getVideosByHashTag("prank", count=35)
  14. ep = 1
  15.  
  16. try:
  17.     d = open("day.txt", 'r', encoding='utf-8')
  18.     day = int(d.read())
  19. except:
  20.     day = 1
  21.     d = open("day.txt", 'w', encoding='utf-8')
  22.     d.write("1")
  23.  
  24. x = 1
  25.  
  26. while True:
  27.     content = response.get('itemList')[x]
  28.     x = x + 1
  29.     id = open("id.txt", 'r', encoding='utf-8')
  30.     ids = id.read()
  31.     if content.get('id') in ids:
  32.         continue
  33.     else:
  34.         pass
  35.     hastag1 = "prank"
  36.     if hastag1 in content.get('desc'):
  37.         videoinfo = content.get('video')
  38.         videotime = videoinfo.get('duration')
  39.         if int(videotime) >= 58:
  40.             continue
  41.         id = open("id.txt",'a', encoding='utf-8')
  42.         id.write(f"{str(content.get('id'))}\n")
  43.         id.close()
  44.         print(u"\u001b[32;1m Successfully downloaded video: " + content.get('id'))
  45.         authorbody = content.get('author')
  46.         # Below is if the method used if you have the full tiktok object
  47.         getlink = requests.get(
  48.             f"https://api.reiyuura.me/api/dl/tiktok?url=https://www.tiktok.com/@{authorbody.get('uniqueId')}/video/{content.get('id')}")
  49.         link = getlink.json()
  50.  
  51.         video_bytes = requests.get(link['result']['nowm'])
  52.         f = open("settings.txt", 'r', encoding='utf-8')
  53.         ep = int(f.read())
  54.  
  55.         if ep > 20:
  56.             ep = 0
  57.             day += 1
  58.             d = open("day.txt", 'r', encoding='utf-8')
  59.             os.mkdir(f"Day {day}")
  60.             d.close()
  61.             f = open("settings.txt", "w")
  62.  
  63.             f.write(str(ep))
  64.             f.close()
  65.  
  66.         with open(f"Day {day}/Ep {ep} .mp4", "wb") as out:
  67.             out.write(video_bytes.content)
  68.             out.close()
  69.  
  70.  
  71.  
  72. def downloadVideo(uniqueId, id):
  73.     getlink = requests.get(
  74.         f"https://api.reiyuura.me/api/dl/tiktok?url=https://www.tiktok.com/@{uniqueId}/video/{id}")
  75.     link = getlink.json()
  76.     video_bytes = requests.get(link['result']['nowm'])
  77.     with open(f"Miniature Real Food Cooking  ASMR Ep {ep} .mp4", "wb") as out:
  78.         out.write(video_bytes.content)
  79.         out.close()
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement