api update

This commit is contained in:
j 2011-08-08 16:14:47 +02:00
parent 16ce1c8aa1
commit 514d11b4b7

View file

@ -419,17 +419,18 @@ class API(object):
#upload frames #upload frames
form = ox.MultiPartForm() form = ox.MultiPartForm()
form.add_field('action', 'upload') form.add_field('action', 'upload')
form.add_field('oshash', str(i['oshash'])) form.add_field('id', str(i['oshash']))
for key in data: for key in data:
form.add_field(str(key), data[key].encode('utf-8')) form.add_field(str(key), data[key].encode('utf-8'))
for frame in i['frames']: for frame in i['frames']:
fname = os.path.basename(frame) fname = os.path.basename(frame)
if isinstance(fname, unicode): fname = fname.encode('utf-8') if isinstance(fname, unicode): fname = fname.encode('utf-8')
if os.path.exists(frame):
form.add_file('frame', fname, open(frame, 'rb')) form.add_file('frame', fname, open(frame, 'rb'))
r = self._json_request(self.url, form) r = self._json_request(self.url, form)
if os.path.exists(i['video']):
#upload video in chunks #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) ogg = Firefogg(cj=self._cj, debug=True)
if not ogg.upload(url, i['video'], data): if not ogg.upload(url, i['video'], data):
if DEBUG: if DEBUG:
@ -438,12 +439,18 @@ class API(object):
else: else:
if DEBUG: if DEBUG:
print "done" print "done"
else:
if DEBUG:
print "failed"
return False
return True return True
def uploadData(self, filename, oshash): def uploadData(self, filename, oshash):
print filename
print os.stat(filename)
form = ox.MultiPartForm() form = ox.MultiPartForm()
form.add_field('action', 'upload') form.add_field('action', 'upload')
form.add_field('oshash', str(oshash)) form.add_field('id', str(oshash))
fname = os.path.basename(filename) fname = os.path.basename(filename)
if isinstance(fname, unicode): fname = fname.encode('utf-8') if isinstance(fname, unicode): fname = fname.encode('utf-8')
form.add_file('file', fname, open(filename, 'rb')) form.add_file('file', fname, open(filename, 'rb'))