specify oshash to upload

This commit is contained in:
j 2012-01-19 16:55:07 +05:30
parent 533c2e2f7f
commit c328b3252c

View file

@ -368,21 +368,27 @@ class Client(object):
return return
conn, c = self._conn() conn, c = self._conn()
#send empty list to get updated list of requested info/files/data if args:
post = {'info': {}} data = args
r = self.api.update(post) files = []
else:
#send empty list to get updated list of requested info/files/data
post = {'info': {}}
r = self.api.update(post)
files = r['data']['file']
datas = r['data']['data']
if r['data']['file']: if files:
print 'uploading %s files' % len(r['data']['file']) print 'uploading %s files' % len(files)
for oshash in r['data']['file']: for oshash in files:
for path in self.path(oshash): for path in self.path(oshash):
if os.path.exists(path): if os.path.exists(path):
self.api.uploadData(path, oshash) self.api.uploadData(path, oshash)
break break
if r['data']['data']: if data:
print 'encoding and uploading %s videos' % len(r['data']['data']) print 'encoding and uploading %s videos' % len(data)
for oshash in r['data']['data']: for oshash in data:
data = {} data = {}
for path in self.path(oshash): for path in self.path(oshash):
if os.path.exists(path): if os.path.exists(path):
@ -500,12 +506,12 @@ class API(ox.API):
fname = fname.encode('utf-8') fname = fname.encode('utf-8')
while chunk: while chunk:
elapsed = time.mktime(time.localtime()) - start elapsed = time.mktime(time.localtime()) - start
remaining = ""
if done: if done:
remaining = int((elapsed / (done/fsize) - elapsed)/60) * 60 * 1000 r = int((elapsed / (done/fsize) - elapsed)/60) * 60 * 1000
remaining = ", %s remaining" % ox.formatDuration(remaining, r = ox.formatDuration(r, milliseconds=False, verbosity=2)
milliseconds=False, verbosity=2) if r:
else: remaining = ", %s remaining" % r
remaining = ""
msg = '%0.2f%% %s of %s done%s' % ( msg = '%0.2f%% %s of %s done%s' % (
100 * done/fsize, ox.formatBytes(done), ox.formatBytes(fsize), remaining) 100 * done/fsize, ox.formatBytes(done), ox.formatBytes(fsize), remaining)
print ''.join([msg, ' ' * (80-len(msg)), '\r']), print ''.join([msg, ' ' * (80-len(msg)), '\r']),