dont fail if not extracting videos, get real folderdepth, dont relogin just give up

This commit is contained in:
j 2013-02-28 20:42:33 +01:00
parent bec480c7cf
commit 0d011e428c

View file

@ -36,17 +36,22 @@ def encode(filename, prefix, profile, info=None, extract_frames=True):
oshash = info['oshash'] oshash = info['oshash']
frames = [] frames = []
cache = os.path.join(prefix, os.path.join(*utils.hash_prefix(oshash))) cache = os.path.join(prefix, os.path.join(*utils.hash_prefix(oshash)))
if info['video'] and extract_frames: if info.get('video'):
for pos in utils.video_frame_positions(info['duration']): if extract_frames:
frame_name = '%s.png' % pos for pos in utils.video_frame_positions(info['duration']):
frame_f = os.path.join(cache, frame_name) frame_name = '%s.png' % pos
if not os.path.exists(frame_f): frame_f = os.path.join(cache, frame_name)
print frame_f if not os.path.exists(frame_f):
extract.frame(filename, frame_f, pos) print frame_f
frames.append(frame_f) extract.frame(filename, frame_f, pos)
video_f = os.path.join(cache, profile) frames.append(frame_f)
if not os.path.exists(video_f): video_f = os.path.join(cache, profile)
extract.video(filename, video_f, profile, info) if not os.path.exists(video_f):
extract.video(filename, video_f, profile, info)
else:
print info
print filename
return None
return { return {
'info': info, 'info': info,
'oshash': oshash, 'oshash': oshash,
@ -181,7 +186,7 @@ class Client(object):
self.api.DEBUG = DEBUG self.api.DEBUG = DEBUG
if self.signin(): if self.signin():
self.profile = "%sp.webm" % max(self.api.site['video']['resolutions']) self.profile = "%sp.webm" % max(self.api.site['video']['resolutions'])
self.folderdepth = self.api.site.get('folderdepth', 3) self.folderdepth = self.api.site['site'].get('folderdepth', 3)
def signin(self): def signin(self):
if 'username' in self._config: if 'username' in self._config:
@ -345,7 +350,8 @@ class Client(object):
and not filename in ('.DS_Store', ) \ and not filename in ('.DS_Store', ) \
and not filename.endswith('~'): and not filename.endswith('~'):
file_path = os.path.join(dirpath, filename) file_path = os.path.join(dirpath, filename)
if os.path.exists(file_path) and os.stat(file_path).st_size>0: if not 'Extras/' in file_path \
and os.path.exists(file_path) and os.stat(file_path).st_size>0:
files.append(file_path) files.append(file_path)
self.scan_file(file_path) self.scan_file(file_path)
@ -536,9 +542,8 @@ class Client(object):
info = self.info(oshash) info = self.info(oshash)
if not self.api.uploadVideo(path, if not self.api.uploadVideo(path,
data, self.profile, info): data, self.profile, info):
if not self.signin(): print 'video upload failed, giving up, please try again'
print "failed to login again" return
return
if 'rightsLevel' in self._config: if 'rightsLevel' in self._config:
r = self.api.find({'query': { r = self.api.find({'query': {
'conditions': [ 'conditions': [