Compare commits
5 commits
0df326eaf8
...
7e72cfd163
| Author | SHA1 | Date | |
|---|---|---|---|
| 7e72cfd163 | |||
| f7c7a6689b | |||
| 2ebc6ffd3a | |||
| 851204c619 | |||
| a2c9309808 |
5 changed files with 20 additions and 10 deletions
|
|
@ -151,7 +151,8 @@ class API(object):
|
||||||
fd.write(chunk)
|
fd.write(chunk)
|
||||||
shutil.move(tmpname, filename)
|
shutil.move(tmpname, filename)
|
||||||
|
|
||||||
def upload_chunks(self, url, filename, data=None):
|
|
||||||
|
def upload_chunks(self, url, filename, data=None, silent=False):
|
||||||
form = MultiPartForm()
|
form = MultiPartForm()
|
||||||
if data:
|
if data:
|
||||||
for key in data:
|
for key in data:
|
||||||
|
|
@ -188,18 +189,22 @@ class API(object):
|
||||||
try:
|
try:
|
||||||
data = self._json_request(uploadUrl, form)
|
data = self._json_request(uploadUrl, form)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
if not slient:
|
||||||
print("\ninterrupted by user.")
|
print("\ninterrupted by user.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
except:
|
except:
|
||||||
|
if not slient:
|
||||||
print("uploading chunk failed, will try again in 5 seconds\r", end='')
|
print("uploading chunk failed, will try again in 5 seconds\r", end='')
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
data = {'result': -1}
|
data = {'result': -1}
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
if data and 'status' in data:
|
if data and 'status' in data:
|
||||||
if data['status']['code'] == 403:
|
if data['status']['code'] == 403:
|
||||||
|
if not slient:
|
||||||
print("login required")
|
print("login required")
|
||||||
return False
|
return False
|
||||||
if data['status']['code'] != 200:
|
if data['status']['code'] != 200:
|
||||||
|
if not slient:
|
||||||
print("request returned error, will try again in 5 seconds")
|
print("request returned error, will try again in 5 seconds")
|
||||||
if self.DEBUG:
|
if self.DEBUG:
|
||||||
print(data)
|
print(data)
|
||||||
|
|
@ -207,6 +212,7 @@ class API(object):
|
||||||
if data and data.get('result') == 1:
|
if data and data.get('result') == 1:
|
||||||
done += len(chunk)
|
done += len(chunk)
|
||||||
if data.get('offset') not in (None, done):
|
if data.get('offset') not in (None, done):
|
||||||
|
if not slient:
|
||||||
print('server offset out of sync, continue from', data['offset'])
|
print('server offset out of sync, continue from', data['offset'])
|
||||||
done = data['offset']
|
done = data['offset']
|
||||||
f.seek(done)
|
f.seek(done)
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@ EXTENSIONS = {
|
||||||
'avi', 'divx', 'dv', 'flv', 'm2t', 'm2ts', 'm4v', 'mkv', 'mov', 'mp4',
|
'avi', 'divx', 'dv', 'flv', 'm2t', 'm2ts', 'm4v', 'mkv', 'mov', 'mp4',
|
||||||
'mpeg', 'mpg', 'mts', 'ogm', 'ogv', 'rm', 'rmvb', 'vob', 'webm', 'wmv', 'asf',
|
'mpeg', 'mpg', 'mts', 'ogm', 'ogv', 'rm', 'rmvb', 'vob', 'webm', 'wmv', 'asf',
|
||||||
'mod', 'tod', # http://en.wikipedia.org/wiki/MOD_and_TOD
|
'mod', 'tod', # http://en.wikipedia.org/wiki/MOD_and_TOD
|
||||||
'mxf', 'ts'
|
'mxf', 'ts',
|
||||||
|
'dat', # VOD files
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -290,8 +290,10 @@ def sanitize_html(html, tags=None, global_attributes=[]):
|
||||||
{
|
{
|
||||||
'name': 'a',
|
'name': 'a',
|
||||||
'required': ['href'],
|
'required': ['href'],
|
||||||
|
'optional': ['target'],
|
||||||
'validation': {
|
'validation': {
|
||||||
'href': valid_url
|
'href': valid_url,
|
||||||
|
'target': '^_blank$',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{'name': 'br'},
|
{'name': 'br'},
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ def get_torrent_info(data=None, file=None):
|
||||||
tinfo[key] = metainfo[key]
|
tinfo[key] = metainfo[key]
|
||||||
tinfo['size'] = file_length
|
tinfo['size'] = file_length
|
||||||
tinfo['hash'] = sha1(bencode(info)).hexdigest()
|
tinfo['hash'] = sha1(bencode(info)).hexdigest()
|
||||||
|
if 'announce' in metainfo:
|
||||||
tinfo['announce'] = metainfo['announce']
|
tinfo['announce'] = metainfo['announce']
|
||||||
if file:
|
if file:
|
||||||
tinfo['timestamp'] = os.stat(file).st_ctime
|
tinfo['timestamp'] = os.stat(file).st_ctime
|
||||||
|
|
|
||||||
2
test.sh
2
test.sh
|
|
@ -1 +1 @@
|
||||||
nosetests --with-doctest ox
|
nosetests3 --with-doctest ox
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue