use config for resolution, only upload frames if enabled
This commit is contained in:
parent
e68dd56dda
commit
015e76619a
1 changed files with 21 additions and 15 deletions
|
@ -58,6 +58,7 @@ class Client(object):
|
||||||
else:
|
else:
|
||||||
self._config = config
|
self._config = config
|
||||||
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.signin()
|
self.signin()
|
||||||
|
|
||||||
conn, c = self._conn()
|
conn, c = self._conn()
|
||||||
|
@ -93,6 +94,9 @@ class Client(object):
|
||||||
conn.text_factory = sqlite3.OptimizedUnicode
|
conn.text_factory = sqlite3.OptimizedUnicode
|
||||||
return conn, conn.cursor()
|
return conn, conn.cursor()
|
||||||
|
|
||||||
|
def get_profile(self):
|
||||||
|
return "%sp.webm" % max(self.api._config['video']['resolutions'])
|
||||||
|
|
||||||
def media_cache(self):
|
def media_cache(self):
|
||||||
return os.path.expanduser(self._config.get('media-cache', default_media_cache))
|
return os.path.expanduser(self._config.get('media-cache', default_media_cache))
|
||||||
|
|
||||||
|
@ -124,6 +128,9 @@ class Client(object):
|
||||||
self.user = False
|
self.user = False
|
||||||
print 'login failed'
|
print 'login failed'
|
||||||
return False
|
return False
|
||||||
|
r = self.api.init()
|
||||||
|
if r['status']['code'] == 200:
|
||||||
|
self.api._config = r['data']['site']
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def scan_file(self, path):
|
def scan_file(self, path):
|
||||||
|
@ -195,8 +202,7 @@ class Client(object):
|
||||||
else:
|
else:
|
||||||
volumes[name]['available'] = False
|
volumes[name]['available'] = False
|
||||||
|
|
||||||
profile = self.api.encodingProfile()['data']['profile']
|
profile = self.get_profile()
|
||||||
#profile = '480p.webm'
|
|
||||||
for name in volumes:
|
for name in volumes:
|
||||||
if volumes[name]['available']:
|
if volumes[name]['available']:
|
||||||
prefix = volumes[name]['path']
|
prefix = volumes[name]['path']
|
||||||
|
@ -363,8 +369,9 @@ class API(ox.API):
|
||||||
if not i:
|
if not i:
|
||||||
print "failed"
|
print "failed"
|
||||||
return
|
return
|
||||||
print i
|
|
||||||
#upload frames
|
#upload frames
|
||||||
|
if self._config['media']['importPosterFrames']:
|
||||||
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'])
|
||||||
|
@ -374,12 +381,11 @@ class API(ox.API):
|
||||||
fname = os.path.basename(frame)
|
fname = os.path.basename(frame)
|
||||||
if os.path.exists(frame):
|
if os.path.exists(frame):
|
||||||
form.add_file('frame', fname, open(frame, 'rb'))
|
form.add_file('frame', fname, open(frame, 'rb'))
|
||||||
print self.url
|
|
||||||
r = self._json_request(self.url, form)
|
r = self._json_request(self.url, form)
|
||||||
|
|
||||||
|
#upload video
|
||||||
if os.path.exists(i['video']):
|
if os.path.exists(i['video']):
|
||||||
url = self.url + 'upload/' + '?profile=' + str(profile) + '&id=' + i['oshash']
|
url = self.url + 'upload/' + '?profile=' + str(profile) + '&id=' + i['oshash']
|
||||||
if DEBUG:
|
|
||||||
print "upload video in chunks", url
|
|
||||||
ogg = Firefogg(cj=self._cj, debug=True)
|
ogg = Firefogg(cj=self._cj, debug=True)
|
||||||
if not ogg.upload(url, i['video'], data):
|
if not ogg.upload(url, i['video'], data):
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
|
|
Loading…
Reference in a new issue