more options
This commit is contained in:
parent
0de6a5c1c5
commit
bfe27b3848
2 changed files with 49 additions and 33 deletions
|
@ -25,7 +25,7 @@ if __name__ == '__main__':
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
actions = ('scan', 'extract', 'sync', 'clean')
|
actions = ('scan', 'sync', 'upload', 'extract', 'clean')
|
||||||
if not args or args[0] not in actions:
|
if not args or args[0] not in actions:
|
||||||
parser.error('you must specify a valid action. \n\t\tknown actions are: %s' % ', '.join(actions))
|
parser.error('you must specify a valid action. \n\t\tknown actions are: %s' % ', '.join(actions))
|
||||||
|
|
||||||
|
|
|
@ -263,41 +263,57 @@ class Client(object):
|
||||||
if len(post['info']):
|
if len(post['info']):
|
||||||
print 'sending info for new files', len(post['info']), offset, total
|
print 'sending info for new files', len(post['info']), offset, total
|
||||||
r = self.api.update(post)
|
r = self.api.update(post)
|
||||||
|
|
||||||
#send empty list to get updated list of requested info/files/data
|
|
||||||
post = {'info': {}}
|
|
||||||
r = self.api.update(post)
|
|
||||||
|
|
||||||
filenames = {}
|
def upload(self):
|
||||||
for f in files['files']:
|
if not self.user:
|
||||||
filenames[f['oshash']] = f['path']
|
print "you need to login"
|
||||||
|
return
|
||||||
print 'uploading files', len(r['data']['file'])
|
conn, c = self._conn()
|
||||||
if r['data']['file']:
|
|
||||||
for oshash in r['data']['file']:
|
|
||||||
if oshash in filenames:
|
|
||||||
filename = filenames[oshash]
|
|
||||||
self.api.uploadData(os.path.join(prefix, filename), oshash)
|
|
||||||
|
|
||||||
print 'encoding videos', len(r['data']['data'])
|
volumes = {}
|
||||||
if r['data']['data']:
|
for name in self._config['volumes']:
|
||||||
for oshash in r['data']['data']:
|
path = self._config['volumes'][name]
|
||||||
data = {}
|
path = os.path.normpath(path)
|
||||||
if oshash in filenames:
|
|
||||||
filename = filenames[oshash]
|
|
||||||
info = files['info'][oshash]
|
|
||||||
if not self.api.uploadVideo(os.path.join(prefix, filename),
|
|
||||||
data, profile, info):
|
|
||||||
if not self.signin():
|
|
||||||
print "failed to login again"
|
|
||||||
return
|
|
||||||
|
|
||||||
else:
|
volumes[name] = {}
|
||||||
pass
|
volumes[name]['path'] = path
|
||||||
#print oshash, "missing"
|
if os.path.exists(path):
|
||||||
else:
|
volumes[name]['available'] = True
|
||||||
print "updating volume", name, "failed"
|
else:
|
||||||
print r
|
volumes[name]['available'] = False
|
||||||
|
|
||||||
|
profile = self.api.encodingProfile()['data']['profile']
|
||||||
|
for name in volumes:
|
||||||
|
if volumes[name]['available']:
|
||||||
|
prefix = volumes[name]['path']
|
||||||
|
files = self.files(prefix)
|
||||||
|
|
||||||
|
filenames = {}
|
||||||
|
for f in files['files']:
|
||||||
|
filenames[f['oshash']] = f['path']
|
||||||
|
#send empty list to get updated list of requested info/files/data
|
||||||
|
post = {'info': {}}
|
||||||
|
r = self.api.update(post)
|
||||||
|
|
||||||
|
print 'uploading files', len(r['data']['file'])
|
||||||
|
if r['data']['file']:
|
||||||
|
for oshash in r['data']['file']:
|
||||||
|
if oshash in filenames:
|
||||||
|
filename = filenames[oshash]
|
||||||
|
self.api.uploadData(os.path.join(prefix, filename), oshash)
|
||||||
|
|
||||||
|
print 'encoding videos', len(r['data']['data'])
|
||||||
|
if r['data']['data']:
|
||||||
|
for oshash in r['data']['data']:
|
||||||
|
data = {}
|
||||||
|
if oshash in filenames:
|
||||||
|
filename = filenames[oshash]
|
||||||
|
info = files['info'][oshash]
|
||||||
|
if not self.api.uploadVideo(os.path.join(prefix, filename),
|
||||||
|
data, profile, info):
|
||||||
|
if not self.signin():
|
||||||
|
print "failed to login again"
|
||||||
|
return
|
||||||
|
|
||||||
def files(self, prefix):
|
def files(self, prefix):
|
||||||
conn, c = self._conn()
|
conn, c = self._conn()
|
||||||
|
|
Loading…
Reference in a new issue