Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import time
- your_api_key = 'AI###########################BA'
- #https://console.cloud.google.com/
- Archive_Filename = "F:\\ProperBackup\\Video\\Youtube2\\youtube-dl-archive_backup.txt" # File filed with 'youtube XXXXXXXX'
- Results_Filename = "F:\\ProperBackup\\Video\\Youtube2\\youtube-dl-archive-verify.txt" # File to dump results to
- num_lines = sum(1 for line in open(Archive_Filename))
- print(f"{num_lines} Videos detected")
- total_videos = 0
- removed_videos = 0
- unlisted_videos = 0
- public_videos = 0
- if num_lines < 9000: #Not a joke, the API limits you to 10,000 requests per day
- rate_limit = 1
- else:
- rate_limit = 9 #Seriously, this script fails if it gets rate limit enforced, so don't tinker.
- for i in range (0,num_lines):
- line = open(Archive_Filename, "r").readlines()[i]
- y, z = line.split()
- url = f'https://www.googleapis.com/youtube/v3/videos?id={z}&key={your_api_key}&part=status'
- url_get = requests.get(url)
- data = url_get.json()
- time.sleep(rate_limit)
- total_videos +=1
- try:
- returned = data['items'][0]['status']['privacyStatus']
- if returned == 'public':
- print(z+" Public")
- public_videos += 1
- elif returned == 'unlisted':
- unlisted_videos += 1
- print(z+" Unlisted")
- f = open(Results_Filename,'a+')
- f.write('\n' + z + ", Unlisted")
- f.close()
- else:
- print(z+" Other," + returned + "###########################")
- except(IndexError, ValueError):
- removed_videos += 1
- gotdata = 'null'
- print(z + " Private or nuked")
- f = open(Results_Filename,'a+')
- f.write('\n' + z + ", Removed")
- f.close()
- pr = round(100*removed_videos/total_videos,2)
- pu = round(100*unlisted_videos/total_videos,2)
- pp = round(100*public_videos/total_videos,2)
- print(f"%P={pp},%U={pu},%R={pr}")
- print(f"P={public_videos},U={unlisted_videos},R={removed_videos}")
- print("Pause")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement