Обработка паузы

master
inpos 2016-03-27 15:27:14 +03:00
parent 0f5c8de27b
commit e23e447a1b
3 changed files with 10 additions and 1 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.module.pyrrent2http" name="pyrrent2http" version="0.9.3" provider-name="inpos"> <addon id="script.module.pyrrent2http" name="pyrrent2http" version="0.9.4" provider-name="inpos">
<requires> <requires>
<import addon="xbmc.python" version="2.14.0"/> <import addon="xbmc.python" version="2.14.0"/>
<import addon="script.module.libtorrent" /> <import addon="script.module.libtorrent" />

View File

@ -247,6 +247,11 @@ class Engine:
def activate_file(self, index): def activate_file(self, index):
self.pyrrent2http.TorrentFS.file(index) self.pyrrent2http.TorrentFS.file(index)
def pause(self):
self.pyrrent2http.pause = True
def resume(self):
self.pyrrent2http.pause = False
def check_torrent_error(self, status=None): def check_torrent_error(self, status=None):
""" """

View File

@ -412,6 +412,9 @@ def HttpHandlerFactory():
buf = bytearray(chunk) buf = bytearray(chunk)
try: try:
if f.Read(buf) < 1: break if f.Read(buf) < 1: break
while self.server.root_obj.pause:
time.sleep(0.1)
continue
self.wfile.write(buf) self.wfile.write(buf)
except: except:
break break
@ -461,6 +464,7 @@ def HttpHandlerFactory():
return HttpHandler return HttpHandler
class Pyrrent2http(object): class Pyrrent2http(object):
pause = False
def __init__(self, uri = '', bindAddress = 'localhost:5001', downloadPath = '.', def __init__(self, uri = '', bindAddress = 'localhost:5001', downloadPath = '.',
idleTimeout = -1, keepComplete = False, idleTimeout = -1, keepComplete = False,
keepIncomplete = False, keepFiles = False, showAllStats = False, keepIncomplete = False, keepFiles = False, showAllStats = False,