use db to find possible paths for oshash
This commit is contained in:
parent
b6c83219b4
commit
f9970fdcea
1 changed files with 10 additions and 31 deletions
|
@ -310,26 +310,6 @@ class Client(object):
|
||||||
return
|
return
|
||||||
conn, c = self._conn()
|
conn, c = self._conn()
|
||||||
|
|
||||||
volumes = {}
|
|
||||||
for name in self._config['volumes']:
|
|
||||||
path = self._config['volumes'][name]
|
|
||||||
path = os.path.normpath(path)
|
|
||||||
|
|
||||||
volumes[name] = {}
|
|
||||||
volumes[name]['path'] = path
|
|
||||||
if os.path.exists(path):
|
|
||||||
volumes[name]['available'] = True
|
|
||||||
else:
|
|
||||||
volumes[name]['available'] = False
|
|
||||||
|
|
||||||
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
|
#send empty list to get updated list of requested info/files/data
|
||||||
post = {'info': {}}
|
post = {'info': {}}
|
||||||
r = self.api.update(post)
|
r = self.api.update(post)
|
||||||
|
@ -337,19 +317,18 @@ class Client(object):
|
||||||
if r['data']['file']:
|
if r['data']['file']:
|
||||||
print 'uploading %s files' % len(r['data']['file'])
|
print 'uploading %s files' % len(r['data']['file'])
|
||||||
for oshash in r['data']['file']:
|
for oshash in r['data']['file']:
|
||||||
if oshash in filenames:
|
for path in self.path(oshash):
|
||||||
filename = filenames[oshash]
|
if os.path.exists(path):
|
||||||
self.api.uploadData(os.path.join(prefix, filename), oshash)
|
self.api.uploadData(path, oshash)
|
||||||
|
|
||||||
if r['data']['data']:
|
if r['data']['data']:
|
||||||
print 'encoding and uploading %s videos' % len(r['data']['data'])
|
print 'encoding and uploading %s videos' % len(r['data']['data'])
|
||||||
for oshash in r['data']['data']:
|
for oshash in r['data']['data']:
|
||||||
data = {}
|
data = {}
|
||||||
if oshash in filenames:
|
for path in self.path(oshash):
|
||||||
filename = filenames[oshash]
|
if os.path.exists(path):
|
||||||
info = files['info'][oshash]
|
info = self.info(oshash)
|
||||||
if not self.api.uploadVideo(os.path.join(prefix, filename),
|
if not self.api.uploadVideo(path, data, self.profile, info):
|
||||||
data, self.profile, info):
|
|
||||||
if not self.signin():
|
if not self.signin():
|
||||||
print "failed to login again"
|
print "failed to login again"
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue