api update
This commit is contained in:
parent
16ce1c8aa1
commit
514d11b4b7
1 changed files with 18 additions and 11 deletions
|
@ -419,17 +419,18 @@ class API(object):
|
|||
#upload frames
|
||||
form = ox.MultiPartForm()
|
||||
form.add_field('action', 'upload')
|
||||
form.add_field('oshash', str(i['oshash']))
|
||||
form.add_field('id', str(i['oshash']))
|
||||
for key in data:
|
||||
form.add_field(str(key), data[key].encode('utf-8'))
|
||||
for frame in i['frames']:
|
||||
fname = os.path.basename(frame)
|
||||
if isinstance(fname, unicode): fname = fname.encode('utf-8')
|
||||
if os.path.exists(frame):
|
||||
form.add_file('frame', fname, open(frame, 'rb'))
|
||||
r = self._json_request(self.url, form)
|
||||
|
||||
if os.path.exists(i['video']):
|
||||
#upload video in chunks
|
||||
url = self.url + 'upload/' + '?profile=' + str(profile) + '&oshash=' + i['oshash']
|
||||
url = self.url + 'upload/' + '?profile=' + str(profile) + '&id=' + i['oshash']
|
||||
ogg = Firefogg(cj=self._cj, debug=True)
|
||||
if not ogg.upload(url, i['video'], data):
|
||||
if DEBUG:
|
||||
|
@ -438,12 +439,18 @@ class API(object):
|
|||
else:
|
||||
if DEBUG:
|
||||
print "done"
|
||||
else:
|
||||
if DEBUG:
|
||||
print "failed"
|
||||
return False
|
||||
return True
|
||||
|
||||
def uploadData(self, filename, oshash):
|
||||
print filename
|
||||
print os.stat(filename)
|
||||
form = ox.MultiPartForm()
|
||||
form.add_field('action', 'upload')
|
||||
form.add_field('oshash', str(oshash))
|
||||
form.add_field('id', str(oshash))
|
||||
fname = os.path.basename(filename)
|
||||
if isinstance(fname, unicode): fname = fname.encode('utf-8')
|
||||
form.add_file('file', fname, open(filename, 'rb'))
|
||||
|
|
Loading…
Reference in a new issue