upload video in closest resolution to source
This commit is contained in:
parent
3ab9a32627
commit
73c84ec10d
1 changed files with 22 additions and 6 deletions
|
@ -139,7 +139,8 @@ class Client(object):
|
||||||
self._config = config
|
self._config = config
|
||||||
if not self._config['url'].endswith('/'):
|
if not self._config['url'].endswith('/'):
|
||||||
self._config['url'] = self._config['url'] + '/'
|
self._config['url'] = self._config['url'] + '/'
|
||||||
self.profile = self._config.get('profile', '480p.webm')
|
self.resolutions = self._config.get('resolutions', [480])
|
||||||
|
self.format = self._config.get('format', 'webm')
|
||||||
|
|
||||||
if not offline:
|
if not offline:
|
||||||
self.online()
|
self.online()
|
||||||
|
@ -283,7 +284,8 @@ class Client(object):
|
||||||
self.api = API(self._config['url'], media_cache=self.media_cache())
|
self.api = API(self._config['url'], media_cache=self.media_cache())
|
||||||
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.resolutions = list(reversed(sorted(self.api.site['video']['resolutions'])))
|
||||||
|
self.format = self.api.site['video']['formats'][0]
|
||||||
self.folderdepth = self._config.get('folderdepth', self.api.site['site'].get('folderdepth', 3))
|
self.folderdepth = self._config.get('folderdepth', self.api.site['site'].get('folderdepth', 3))
|
||||||
|
|
||||||
def signin(self):
|
def signin(self):
|
||||||
|
@ -371,6 +373,18 @@ class Client(object):
|
||||||
conn.commit()
|
conn.commit()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def get_resolution(self, info):
|
||||||
|
height = info['video'][0]['height'] if info.get('video') else None
|
||||||
|
for resolution in sorted(self.resolutions):
|
||||||
|
if height and height <= resolution:
|
||||||
|
return resolution
|
||||||
|
return resolution
|
||||||
|
|
||||||
|
def profile(self, info):
|
||||||
|
resolution = self.get_resolution(info)
|
||||||
|
profile = '%sp.%s' % (resolution, self.format)
|
||||||
|
return profile
|
||||||
|
|
||||||
def cmd(self, args):
|
def cmd(self, args):
|
||||||
filename = args[0]
|
filename = args[0]
|
||||||
if len(filename) == 16:
|
if len(filename) == 16:
|
||||||
|
@ -379,7 +393,9 @@ class Client(object):
|
||||||
path = [filename]
|
path = [filename]
|
||||||
for p in path:
|
for p in path:
|
||||||
if os.path.exists(p):
|
if os.path.exists(p):
|
||||||
cmd = encode_cmd(p.decode('utf-8'), self.media_cache(), self.profile, None)
|
info = utils.avinfo(p)
|
||||||
|
profile = self.profile(info)
|
||||||
|
cmd = encode_cmd(p.decode('utf-8'), self.media_cache(), profile, info)
|
||||||
cmd = [' ' in c and u'"%s"' % c or c for c in cmd]
|
cmd = [' ' in c and u'"%s"' % c or c for c in cmd]
|
||||||
print (u' '.join(cmd)).encode('utf-8')
|
print (u' '.join(cmd)).encode('utf-8')
|
||||||
|
|
||||||
|
@ -548,8 +564,8 @@ class Client(object):
|
||||||
if not 'error' in info:
|
if not 'error' in info:
|
||||||
for path in self.path(oshash):
|
for path in self.path(oshash):
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
#print path.encode('utf-8')
|
profile = self.profile(info)
|
||||||
i = encode(path, self.media_cache(), self.profile, info,
|
i = encode(path, self.media_cache(), profile, info,
|
||||||
self.api.site['media'].get('importFrames'))
|
self.api.site['media'].get('importFrames'))
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -680,7 +696,7 @@ class Client(object):
|
||||||
for path in self.path(oshash):
|
for path in self.path(oshash):
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
if not self.api.uploadVideo(path,
|
if not self.api.uploadVideo(path,
|
||||||
data, self.profile, info):
|
data, self.profile(info), info):
|
||||||
print 'video upload failed, giving up, please try again'
|
print 'video upload failed, giving up, please try again'
|
||||||
return
|
return
|
||||||
if 'rightsLevel' in self._config:
|
if 'rightsLevel' in self._config:
|
||||||
|
|
Loading…
Reference in a new issue