Новый движок
This commit is contained in:
1 parent
408bd32cce
commit
eec57dbe38
7 files changed
+30
-33
No files matched your search
+12
-13
@@ -3,36 +3,35 @@ from .utils import get_engine, localize
|
||||
|
||||
|
||||
class TorrentPlayer(xbmc.Player):
|
||||
pyrrent_engine = None
|
||||
gorrent_engine = None
|
||||
loop = None
|
||||
paused = False
|
||||
|
||||
def onPlayBackEnded(self):
|
||||
self.pyrrent_engine.close()
|
||||
self.gorrent_engine.close()
|
||||
self.loop.stopped = True
|
||||
xbmc.Player().stop()
|
||||
|
||||
def onPlayBackPaused(self):
|
||||
self.pyrrent_engine.pause()
|
||||
self.gorrent_engine.pause()
|
||||
self.paused = True
|
||||
|
||||
def onPlayBackResumed(self):
|
||||
self.paused = False
|
||||
self.pyrrent_engine.resume()
|
||||
self.gorrent_engine.resume()
|
||||
|
||||
def onPlayBackStopped(self):
|
||||
self.pyrrent_engine.close()
|
||||
self.gorrent_engine.close()
|
||||
self.loop.stopped = True
|
||||
xbmc.Player().stop()
|
||||
|
||||
def play(self, engine, f_index):
|
||||
self.pyrrent_engine = engine
|
||||
self.pyrrent_engine.start()
|
||||
self.pyrrent_engine.activate_file(f_index)
|
||||
self.gorrent_engine = engine
|
||||
self.gorrent_engine.start(f_index)
|
||||
monitor = xbmc.Monitor()
|
||||
pw = xbmcgui.DialogProgress()
|
||||
pw.create(localize(33055), '0 Kbit/s')
|
||||
f_size = self.pyrrent_engine.file_status(f_index).size
|
||||
f_size = self.gorrent_engine.file_status(f_index).size
|
||||
EXPECTED_KBYTES = f_size // 3 // 1024 // 1024
|
||||
if EXPECTED_KBYTES > 768:
|
||||
EXPECTED_KBYTES = 768
|
||||
@@ -40,11 +39,11 @@ class TorrentPlayer(xbmc.Player):
|
||||
xbmc.sleep(500)
|
||||
if monitor.abortRequested() or pw.iscanceled():
|
||||
pw.close()
|
||||
self.pyrrent_engine.close()
|
||||
self.gorrent_engine.close()
|
||||
xbmc.Player().stop()
|
||||
self.loop.stopped = True
|
||||
return False
|
||||
status = self.pyrrent_engine.status()
|
||||
status = self.gorrent_engine.status()
|
||||
d_rate = status.download_rate
|
||||
# xbmc.log('*** DRATE: {}'.format(d_rate), level=xbmc.LOGNOTICE)
|
||||
perc = d_rate // EXPECTED_KBYTES * 100
|
||||
@@ -53,7 +52,7 @@ class TorrentPlayer(xbmc.Player):
|
||||
if perc == 100:
|
||||
pw.close()
|
||||
break
|
||||
fstat = self.pyrrent_engine.file_status(f_index)
|
||||
fstat = self.gorrent_engine.file_status(f_index)
|
||||
listitem = xbmcgui.ListItem('.'.join(fstat.name.split('/')[-1].split('.')[:-1])[:-1], path=fstat.url)
|
||||
xbmc.Player.play(self, fstat.url, listitem)
|
||||
|
||||
@@ -78,7 +77,7 @@ class VideoLoop(object):
|
||||
if self.mediaPlayer.paused:
|
||||
self.statinfo.notification(
|
||||
# '[{}]{}.'.format(('|' * (int(f_status.progress * 100) // 2)).ljust(50, '.'), ' ' * 100),
|
||||
'[{}]'.format(('|' * (int(f_status.progress * 100) // 2)).ljust(50, '.')),
|
||||
'[{}]'.format(('|' * (f_status.progress // 2)).ljust(50, '.')),
|
||||
'S: {} DL: {} KB/s UL: {} KB/s'.format(status.num_seeds,
|
||||
status.download_rate,
|
||||
status.upload_rate),
|
||||
|
||||
@@ -47,7 +47,7 @@ class Searcher(object):
|
||||
parser = HTMLement('body')
|
||||
parser.feed(resp.text)
|
||||
# todo отладка
|
||||
xbmc.log(f'SEARCH BODY:\n{resp.text}')
|
||||
# xbmc.log(f'SEARCH BODY:\n{resp.text}')
|
||||
#
|
||||
return self.process(parser.close())
|
||||
except:
|
||||
|
||||
@@ -48,14 +48,14 @@ class SearchEngine(Searcher):
|
||||
data={'username': user, 'password': password, 'returnto': ''},
|
||||
cookies={}, headers=self.headers, allow_redirects=False)
|
||||
# todo отладка
|
||||
xbmc.log(f'Kinozal LOGIN BODY:\n{resp.text}')
|
||||
# xbmc.log(f'Kinozal LOGIN BODY:\n{resp.text}')
|
||||
#
|
||||
|
||||
if not resp.ok:
|
||||
raise Exception
|
||||
|
||||
# todo отладка
|
||||
xbmc.log(f'LOGIN COOKIE:\n{resp.cookies}')
|
||||
# xbmc.log(f'LOGIN COOKIE:\n{resp.cookies}')
|
||||
#
|
||||
|
||||
cookies = resp.cookies
|
||||
|
||||
@@ -47,7 +47,7 @@ class SearchEngine(Searcher):
|
||||
raise Exception
|
||||
|
||||
# todo отладка
|
||||
xbmc.log(f'RuTracker LOGIN BODY:\n{resp.text}')
|
||||
# xbmc.log(f'RuTracker LOGIN BODY:\n{resp.text}')
|
||||
#
|
||||
|
||||
cookies = resp.cookies
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from codequick.support import addon_data # @UnresolvedImport
|
||||
from codequick.utils import urljoin_partial # @UnresolvedImport
|
||||
from codequick.support import addon_data
|
||||
from codequick.utils import urljoin_partial
|
||||
from ..settings import option
|
||||
import xbmcgui
|
||||
import os
|
||||
from hashlib import sha1
|
||||
from pyrrent2http import Engine # @UnresolvedImport
|
||||
from gorrent2http import Engine
|
||||
from urllib.request import pathname2url
|
||||
|
||||
|
||||
@@ -49,10 +49,10 @@ def get_engine(torrent_uri):
|
||||
else:
|
||||
proxy = None
|
||||
return Engine(uri=file_url(torrent_uri), download_path=storage_download_dir,
|
||||
encryption=1, keep_complete=False, keep_incomplete=False,
|
||||
encryption=1, keep_files=False,
|
||||
dht_routers=["router.bittorrent.com:6881", "router.utorrent.com:6881"], use_random_port=False,
|
||||
listen_port=6881,
|
||||
user_agent='', enable_dht=True, proxy=proxy)
|
||||
user_agent='', enable_dht=True, proxy=proxy, debug_alerts=False)
|
||||
|
||||
|
||||
while not option['storage_dir']:
|
||||
|
||||
Reference in new issue
Block a user