Skip to content

Commit 90a914b

Browse files
Feroze NainaFeroze Naina
Feroze Naina
authored and
Feroze Naina
committedApr 16, 2011
Fixed README
1 parent afb7257 commit 90a914b

File tree

2 files changed

+13
-26
lines changed

2 files changed

+13
-26
lines changed
 

‎README

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
DailyMotion Uploader built on py
2+
Built by Feroze Naina for PiTiVi
3+
4+
5+
Uses json, urllib2, poster

‎dailymotion.py

+8-26
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
BASE='https://api.dailymotion.com/'
3+
BASE='https://api.dailymotion.com/json'
44
KEY='13fe53372252ffbcf7fc'
55
SECRET='1312afbc7a53a2f3c01fcf951878a05babd8bf4d'
66
USER='feroztest'
@@ -37,23 +37,19 @@
3737
UURL='?access_token='+access_token
3838

3939

40-
##Currently uses basic API. Switch to advanced api file.upload
41-
#req = urllib2.Request(BASE+'file/upload'+UURL)
42-
#result=json.load(urllib2.urlopen(req))
43-
#upload_url = result['upload_url']
4440

45-
#print upload_url
41+
4642

4743
#advanced api
4844
job=json.dumps({"call":"file.upload","args":None})
4945

5046
data = urlencode(values)
51-
req = urllib2.Request('https://api.dailymotion.com/json'+UURL, job, {'content-type': 'application/json'})
47+
req = urllib2.Request(BASE+UURL, job, {'content-type': 'application/json'})
5248
response = urllib2.urlopen(req)
5349

5450
result=json.load(response)
5551
temp= result['result']
56-
#temp = json.dump(result['result'])
52+
5753
upload_url= temp['upload_url']
5854

5955

@@ -77,26 +73,12 @@
7773
v_url = result['url'] #video URL returned
7874

7975

80-
##Create video object -> Returns id
81-
##Doesn't work. Need to use file.upload
82-
#values = {'url' : v_url,
83-
# }
84-
#
85-
#data = urlencode(values)
86-
#req = urllib2.Request(BASE+"videos"+UURL, data)
87-
#response = urllib2.urlopen(req)
88-
#
89-
#
90-
#
91-
#result=json.load(response)
92-
#id=result['id']
93-
#
94-
#print id
76+
9577

9678
job=json.dumps({"call":"video.create","args":{"url":v_url}})
9779

9880
data = urlencode(values)
99-
req = urllib2.Request('https://api.dailymotion.com/json'+UURL, job, {'content-type': 'application/json'})
81+
req = urllib2.Request(BASE+UURL, job, {'content-type': 'application/json'})
10082
response = urllib2.urlopen(req)
10183

10284

@@ -111,8 +93,8 @@
11193
job=json.dumps({"call":"video.edit","args":{"id":id,"title":"samples","tags":"pitivi","channel":"comedy"}})
11294

11395
data = urlencode(values)
114-
req = urllib2.Request('https://api.dailymotion.com/json'+UURL, job, {'content-type': 'application/json'})
96+
req = urllib2.Request(BASE+UURL, job, {'content-type': 'application/json'})
11597
response = urllib2.urlopen(req)
11698

11799

118-
print response.read()
100+
print "Upload successful - http://dailymotion.com/video/"+id

0 commit comments

Comments
 (0)
Please sign in to comment.