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

pull/1/head
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"?>
<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>
<import addon="xbmc.python" version="2.14.0"/>
<import addon="script.module.libtorrent" />

View File

@ -247,6 +247,11 @@ class Engine:
def activate_file(self, 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):
"""

View File

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