From 514d11b4b730eb151dcd299626e2f1d20940a05a Mon Sep 17 00:00:00 2001 From: j Date: Mon, 8 Aug 2011 16:14:47 +0200 Subject: [PATCH] api update --- pandora_client/__init__.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/pandora_client/__init__.py b/pandora_client/__init__.py index 9020de3..b703c60 100644 --- a/pandora_client/__init__.py +++ b/pandora_client/__init__.py @@ -419,31 +419,38 @@ 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') - form.add_file('frame', fname, open(frame, 'rb')) + if os.path.exists(frame): + form.add_file('frame', fname, open(frame, 'rb')) r = self._json_request(self.url, form) - - #upload video in chunks - url = self.url + 'upload/' + '?profile=' + str(profile) + '&oshash=' + i['oshash'] - ogg = Firefogg(cj=self._cj, debug=True) - if not ogg.upload(url, i['video'], data): + if os.path.exists(i['video']): + #upload video in chunks + 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: + print "failed" + return False + else: + if DEBUG: + print "done" + else: if DEBUG: print "failed" return False - else: - if DEBUG: - print "done" 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'))