Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from itertools import count
- from TikTokAPI import TikTokAPI
- import requests
- import os
- import re
- cookie = {
- "s_v_web_id": "verify_kwyhf5bg_baGBaGqG_irRM_40aM_BMEB_sssRkLG6HgDa",
- "tt_webid": "1%7CFAfwfCuIt7hyY0wcHd1w16HzJopHHQ8W8-Lr3FhqigU%7C1639025425%7Cf3552a7e094df332a022eec25deecdf634570f1785da38f1e0be9881d5952973"
- }
- api = TikTokAPI(cookie=cookie)
- response = api.getVideosByHashTag("prank", count=35)
- ep = 1
- try:
- d = open("day.txt", 'r', encoding='utf-8')
- day = int(d.read())
- except:
- day = 1
- d = open("day.txt", 'w', encoding='utf-8')
- d.write("1")
- x = 1
- while True:
- content = response.get('itemList')[x]
- x = x + 1
- id = open("id.txt", 'r', encoding='utf-8')
- ids = id.read()
- if content.get('id') in ids:
- continue
- else:
- pass
- hastag1 = "prank"
- if hastag1 in content.get('desc'):
- videoinfo = content.get('video')
- videotime = videoinfo.get('duration')
- if int(videotime) >= 58:
- continue
- id = open("id.txt",'a', encoding='utf-8')
- id.write(f"{str(content.get('id'))}\n")
- id.close()
- print(u"\u001b[32;1m Successfully downloaded video: " + content.get('id'))
- authorbody = content.get('author')
- # Below is if the method used if you have the full tiktok object
- getlink = requests.get(
- f"https://api.reiyuura.me/api/dl/tiktok?url=https://www.tiktok.com/@{authorbody.get('uniqueId')}/video/{content.get('id')}")
- link = getlink.json()
- video_bytes = requests.get(link['result']['nowm'])
- f = open("settings.txt", 'r', encoding='utf-8')
- ep = int(f.read())
- if ep > 20:
- ep = 0
- day += 1
- d = open("day.txt", 'r', encoding='utf-8')
- os.mkdir(f"Day {day}")
- d.close()
- f = open("settings.txt", "w")
- f.write(str(ep))
- f.close()
- with open(f"Day {day}/Ep {ep} .mp4", "wb") as out:
- out.write(video_bytes.content)
- out.close()
- def downloadVideo(uniqueId, id):
- getlink = requests.get(
- f"https://api.reiyuura.me/api/dl/tiktok?url=https://www.tiktok.com/@{uniqueId}/video/{id}")
- link = getlink.json()
- video_bytes = requests.get(link['result']['nowm'])
- with open(f"Miniature Real Food Cooking ASMR Ep {ep} .mp4", "wb") as out:
- out.write(video_bytes.content)
- out.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement