importFrames
This commit is contained in:
parent
616973daae
commit
4e8e4a0cf7
1 changed files with 7 additions and 5 deletions
|
@ -25,7 +25,7 @@ socket.setdefaulttimeout(300)
|
||||||
CHUNK_SIZE = 1024*1024
|
CHUNK_SIZE = 1024*1024
|
||||||
default_media_cache = os.environ.get('oxMEDIA', os.path.expanduser('~/.ox/media'))
|
default_media_cache = os.environ.get('oxMEDIA', os.path.expanduser('~/.ox/media'))
|
||||||
|
|
||||||
def encode(filename, prefix, profile, info=None):
|
def encode(filename, prefix, profile, info=None, extract_frames=True):
|
||||||
if not info:
|
if not info:
|
||||||
info = utils.avinfo(filename)
|
info = utils.avinfo(filename)
|
||||||
if not 'oshash' in info:
|
if not 'oshash' in info:
|
||||||
|
@ -33,7 +33,7 @@ def encode(filename, prefix, profile, info=None):
|
||||||
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']:
|
if info['video'] and extract_frames:
|
||||||
for pos in utils.video_frame_positions(info['duration']):
|
for pos in utils.video_frame_positions(info['duration']):
|
||||||
frame_name = '%s.png' % pos
|
frame_name = '%s.png' % pos
|
||||||
frame_f = os.path.join(cache, frame_name)
|
frame_f = os.path.join(cache, frame_name)
|
||||||
|
@ -292,7 +292,8 @@ class Client(object):
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
info = self.info(oshash)
|
info = self.info(oshash)
|
||||||
#print path.encode('utf-8')
|
#print path.encode('utf-8')
|
||||||
i = encode(path, self.media_cache(), self.profile, info)
|
i = encode(path, self.media_cache(), self.profile, info,
|
||||||
|
self._config['media'].get('importFrames'))
|
||||||
break
|
break
|
||||||
|
|
||||||
def sync(self, args):
|
def sync(self, args):
|
||||||
|
@ -472,13 +473,14 @@ class API(ox.API):
|
||||||
self._resume_file = '/tmp/pandora_client.%s.json' % os.environ.get('USER')
|
self._resume_file = '/tmp/pandora_client.%s.json' % os.environ.get('USER')
|
||||||
|
|
||||||
def uploadVideo(self, filename, data, profile, info=None):
|
def uploadVideo(self, filename, data, profile, info=None):
|
||||||
i = encode(filename, self.media_cache, profile, info)
|
i = encode(filename, self.media_cache, profile, info
|
||||||
|
self._config['media'].get('importFrames'))
|
||||||
if not i:
|
if not i:
|
||||||
print "failed"
|
print "failed"
|
||||||
return
|
return
|
||||||
|
|
||||||
#upload frames
|
#upload frames
|
||||||
if self._config['media']['importPosterFrames']:
|
if self._config['media'].get('importFrames'):
|
||||||
form = ox.MultiPartForm()
|
form = ox.MultiPartForm()
|
||||||
form.add_field('action', 'upload')
|
form.add_field('action', 'upload')
|
||||||
form.add_field('id', i['oshash'])
|
form.add_field('id', i['oshash'])
|
||||||
|
|
Loading…
Reference in a new issue