This repository has been archived by the owner on Jan 18, 2021. It is now read-only.
forked from backingUpYouTube/backUpYouTubePyCollection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackUpYouTube.py
65 lines (52 loc) · 2.13 KB
/
backUpYouTube.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import requests,json,sys,re,os
from datetime import datetime
from VideoIDHelper import *
from bs4 import BeautifulSoup
def makeRequest(partialURL,parameter,ID):
pars = {"parameter" : ID}
return requests.get(partialURL, params=pars)
def makeRequestWithoutParameter(URL):
return requests.get(URL)
def backUpAnnotations(ID):
return makeRequestWithoutParameter("http://web.archive.org/save/https://www.youtube.com/annotations_invideo?video_id={}".format(ID))
def snapShotPage(ID):
return makeRequest("http://web.archive.org/save/https://www.youtube.com/watch","v",ID)
def annotationsBackedUp(ID):
return makeRequestWithoutParameter("http://archive.org/wayback/available?url=https://www.youtube.com/annotations_invideo?video_id={}".format(ID))
def snapShotTaken(ID):
return makeRequestWithoutParameter("http://archive.org/wayback/available?url=https://www.youtube.com/watch?v={}".format(ID))
def main():
first = True
argument = ""
print( "Hello today is: " + str(datetime.now().month) + "/" + str(datetime.now().day))
#print( "Remember that we have time until: " + "1/15" + "for Annotations and Credits; and until " + "1/31" +" for Episodes (presumably PST 0:00) " )
print( "Remember that we have time until: " + "1/15" + "for the Annotations (presumably PST 0:00) " )
while first or argument == "":
#argument ="horse"
argument = input("Type in a URL to video or its ID: ")
if argument == "":
print("Program Terminated")
break
else:
vID = idExtractor(argument)
try:
r = snapShotTaken(vID)
#print("Snapshot Taken: " + str(r.status_code))
#print(r.json())
if 'closest' not in r.json()["archived_snapshots"]:
r2=snapShotPage(vID)
print("Snapshot Status Code:{}".format(str(r2.status_code)))
else:
print("Snapshot found!")
r = annotationsBackedUp(vID)
#print("Snapshot Taken: " + str(r.status_code))
if 'closest' not in r.json()["archived_snapshots"]:
r2=backUpAnnotations(vID)
print("Annotations Backup Status Code:{}".format(str(r2.status_code)))
else:
print("Annotations found!")
except Exception as e:
print(e)
print("done")
if __name__== "__main__":
main()