forked from pratikone/videoVenom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
videoVimeo.py
61 lines (49 loc) · 1.69 KB
/
videoVimeo.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
import threading
import vimeo
import webbrowser
import oauth2Server
import sys
caller = None
KEY="3baa464c8b42baf01019bacfef971e9e939a42c0"
SECRET="8vNFwEfVmT+nu6okpSmzkFXuUTvjJPyUTIySqyEPYlbQsr+C2OAPhY+uunbY3RE0P9tFVrwxpKbznbErzpcuue6UMhTdn70bJKQVl4OAgHFGif2pVq/aspdxE/5neJjJ"
def requestOAuth() :
oauth2Server.callback = processResoponse
t = threading.Thread(target=oauth2Server.run, args = ())
t.start()
v = vimeo.VimeoClient(
key=KEY,
secret=SECRET)
vimeo_authorization_url = v.auth_url(['public', 'private','upload'], 'http://localhost:8081','')
webbrowser.open(vimeo_authorization_url)
def processResoponse(CODE_FROM_URL) :
"""This section completes the authentication for the user."""
v = vimeo.VimeoClient(
key=KEY,
secret=SECRET)
# You should retrieve the "code" from the URL string Vimeo redirected to. Here that's named CODE_FROM_URL
try:
token, user, scope = v.exchange_code(CODE_FROM_URL, 'http://localhost:8081')
print token
print scope
except vimeo.auth.GrantFailed:
print "tokening failed"
print caller
caller.vimeoObj = token
# Store
def upload(vimeoObj, VidLocation, titleVid, description, tag, count = 1) :
if count == 5 :
print "Retring in upload failed"
return
v = vimeo.VimeoClient(token=vimeoObj,
key=KEY,
secret=SECRET)
try :
video_uri = v.upload(VidLocation)
v.patch(video_uri, data={'name': titleVid, 'description': description })
print "upload complete"
except :
print "Upload failed. Retrying..."
upload(vimeoObj, VidLocation, titleVid, description, tag, count + 1)
if __name__ == "__main__":
caller = "ABC"
requestOAuth()