Новый движок

master v3.3.3
Роман Бородин 2022-03-20 00:15:29 +03:00
parent 408bd32cce
commit eec57dbe38
7 changed files with 30 additions and 33 deletions

View File

@ -91,16 +91,16 @@ def search(plugin, search_query, thumb=None):
res_items = [] res_items = []
for i in sorted(found_items, key=lambda x: x.seeders, reverse=True): for i in sorted(found_items, key=lambda x: x.seeders, reverse=True):
if '2160p' in i.title: if '2160p' in i.title:
hd = '[2160p/{}] '.format(i.size) hd = f'{{2160p/{i.size}}} '
elif '1080p' in i.title: elif '1080p' in i.title:
hd = '[1080p/{}] '.format(i.size) hd = f'{{1080p/{i.size}}} '
elif '720p' in i.title: elif '720p' in i.title:
hd = '[720p/{}] '.format(i.size) hd = f'{{720p/{i.size}}} '
else: else:
hd = '' hd = ''
item = Listitem.from_dict( item = Listitem.from_dict(
open_torrent, open_torrent,
'{}{} {} ({}/{})'.format(hd, i.title, i.size, i.seeders, i.leachers), f'{hd}{i.title} {i.size} ({i.seeders}/{i.leachers})',
params={'url': i.url, 'cookies': i.cookies, 'referer': i.referer} params={'url': i.url, 'cookies': i.cookies, 'referer': i.referer}
) )
if thumb: if thumb:
@ -129,7 +129,9 @@ def open_torrent(plugin, url='--back--', cookies={}, referer='', path=''):
if not tf: if not tf:
yield False yield False
t_full_path = store_torrent_file(tf) t_full_path = store_torrent_file(tf)
e = get_engine(t_full_path) e = get_engine(t_full_path)
files = sorted(list(filter( files = sorted(list(filter(
lambda x: x.name.startswith(path) and x.name.lower().endswith( lambda x: x.name.startswith(path) and x.name.lower().endswith(
video_extensions), e.list_from_info(media_types=['video']))), video_extensions), e.list_from_info(media_types=['video']))),
@ -151,7 +153,7 @@ def open_torrent(plugin, url='--back--', cookies={}, referer='', path=''):
p = f.name[len(path):].lstrip('/').split('/') p = f.name[len(path):].lstrip('/').split('/')
if len(p) == 1: if len(p) == 1:
item = Listitem.from_dict(play_file, item = Listitem.from_dict(play_file,
'{} ({:.3f} GB)'.format(p[0], f.size / 1024.0 / 1024.0 / 1024.0), f'{p[0]} ({f.size / 1024.0 / 1024.0 / 1024.0:.3f} GB)',
params={'t_full_path': t_full_path, 'f_index': f.index} params={'t_full_path': t_full_path, 'f_index': f.index}
) )
item.art.local_thumb('video.png') item.art.local_thumb('video.png')
@ -169,12 +171,8 @@ def play_file(plugin, t_full_path, f_index):
vl.start(f_index) vl.start(f_index)
return False return False
except: except:
# todo
import traceback import traceback
xbmc.log(f'PLAY exception: {traceback.format_exc()}') xbmc.log(f'PLAY exception: {traceback.format_exc()}')
#
return False return False

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.torrenter3" name="Torrenter3" provider-name="inpos" version="3.3.2"> <addon id="plugin.video.torrenter3" name="Torrenter3" provider-name="inpos" version="3.3.3">
<requires> <requires>
<import addon="xbmc.python" version="3.0.0"/> <import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.pyrrent2http" version="1.1.1"/> <import addon="script.module.gorrent2http" version="1.2.0"/>
<import addon="script.module.codequick" version="1.0.2"/> <import addon="script.module.codequick" version="1.0.2"/>
<import addon="script.module.htmlement" version="1.0.0"/> <import addon="script.module.htmlement" version="1.0.0"/>
<import addon="script.module.requests" version="2.22.0"/> <import addon="script.module.requests" version="2.22.0"/>

View File

@ -3,36 +3,35 @@ from .utils import get_engine, localize
class TorrentPlayer(xbmc.Player): class TorrentPlayer(xbmc.Player):
pyrrent_engine = None gorrent_engine = None
loop = None loop = None
paused = False paused = False
def onPlayBackEnded(self): def onPlayBackEnded(self):
self.pyrrent_engine.close() self.gorrent_engine.close()
self.loop.stopped = True self.loop.stopped = True
xbmc.Player().stop() xbmc.Player().stop()
def onPlayBackPaused(self): def onPlayBackPaused(self):
self.pyrrent_engine.pause() self.gorrent_engine.pause()
self.paused = True self.paused = True
def onPlayBackResumed(self): def onPlayBackResumed(self):
self.paused = False self.paused = False
self.pyrrent_engine.resume() self.gorrent_engine.resume()
def onPlayBackStopped(self): def onPlayBackStopped(self):
self.pyrrent_engine.close() self.gorrent_engine.close()
self.loop.stopped = True self.loop.stopped = True
xbmc.Player().stop() xbmc.Player().stop()
def play(self, engine, f_index): def play(self, engine, f_index):
self.pyrrent_engine = engine self.gorrent_engine = engine
self.pyrrent_engine.start() self.gorrent_engine.start(f_index)
self.pyrrent_engine.activate_file(f_index)
monitor = xbmc.Monitor() monitor = xbmc.Monitor()
pw = xbmcgui.DialogProgress() pw = xbmcgui.DialogProgress()
pw.create(localize(33055), '0 Kbit/s') 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 EXPECTED_KBYTES = f_size // 3 // 1024 // 1024
if EXPECTED_KBYTES > 768: if EXPECTED_KBYTES > 768:
EXPECTED_KBYTES = 768 EXPECTED_KBYTES = 768
@ -40,11 +39,11 @@ class TorrentPlayer(xbmc.Player):
xbmc.sleep(500) xbmc.sleep(500)
if monitor.abortRequested() or pw.iscanceled(): if monitor.abortRequested() or pw.iscanceled():
pw.close() pw.close()
self.pyrrent_engine.close() self.gorrent_engine.close()
xbmc.Player().stop() xbmc.Player().stop()
self.loop.stopped = True self.loop.stopped = True
return False return False
status = self.pyrrent_engine.status() status = self.gorrent_engine.status()
d_rate = status.download_rate d_rate = status.download_rate
# xbmc.log('*** DRATE: {}'.format(d_rate), level=xbmc.LOGNOTICE) # xbmc.log('*** DRATE: {}'.format(d_rate), level=xbmc.LOGNOTICE)
perc = d_rate // EXPECTED_KBYTES * 100 perc = d_rate // EXPECTED_KBYTES * 100
@ -53,7 +52,7 @@ class TorrentPlayer(xbmc.Player):
if perc == 100: if perc == 100:
pw.close() pw.close()
break 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) listitem = xbmcgui.ListItem('.'.join(fstat.name.split('/')[-1].split('.')[:-1])[:-1], path=fstat.url)
xbmc.Player.play(self, fstat.url, listitem) xbmc.Player.play(self, fstat.url, listitem)
@ -78,7 +77,7 @@ class VideoLoop(object):
if self.mediaPlayer.paused: if self.mediaPlayer.paused:
self.statinfo.notification( self.statinfo.notification(
# '[{}]{}.'.format(('|' * (int(f_status.progress * 100) // 2)).ljust(50, '.'), ' ' * 100), # '[{}]{}.'.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, 'S: {} DL: {} KB/s UL: {} KB/s'.format(status.num_seeds,
status.download_rate, status.download_rate,
status.upload_rate), status.upload_rate),

View File

@ -47,7 +47,7 @@ class Searcher(object):
parser = HTMLement('body') parser = HTMLement('body')
parser.feed(resp.text) parser.feed(resp.text)
# todo отладка # todo отладка
xbmc.log(f'SEARCH BODY:\n{resp.text}') # xbmc.log(f'SEARCH BODY:\n{resp.text}')
# #
return self.process(parser.close()) return self.process(parser.close())
except: except:

View File

@ -48,14 +48,14 @@ class SearchEngine(Searcher):
data={'username': user, 'password': password, 'returnto': ''}, data={'username': user, 'password': password, 'returnto': ''},
cookies={}, headers=self.headers, allow_redirects=False) cookies={}, headers=self.headers, allow_redirects=False)
# todo отладка # todo отладка
xbmc.log(f'Kinozal LOGIN BODY:\n{resp.text}') # xbmc.log(f'Kinozal LOGIN BODY:\n{resp.text}')
# #
if not resp.ok: if not resp.ok:
raise Exception raise Exception
# todo отладка # todo отладка
xbmc.log(f'LOGIN COOKIE:\n{resp.cookies}') # xbmc.log(f'LOGIN COOKIE:\n{resp.cookies}')
# #
cookies = resp.cookies cookies = resp.cookies

View File

@ -47,7 +47,7 @@ class SearchEngine(Searcher):
raise Exception raise Exception
# todo отладка # todo отладка
xbmc.log(f'RuTracker LOGIN BODY:\n{resp.text}') # xbmc.log(f'RuTracker LOGIN BODY:\n{resp.text}')
# #
cookies = resp.cookies cookies = resp.cookies

View File

@ -1,10 +1,10 @@
from codequick.support import addon_data # @UnresolvedImport from codequick.support import addon_data
from codequick.utils import urljoin_partial # @UnresolvedImport from codequick.utils import urljoin_partial
from ..settings import option from ..settings import option
import xbmcgui import xbmcgui
import os import os
from hashlib import sha1 from hashlib import sha1
from pyrrent2http import Engine # @UnresolvedImport from gorrent2http import Engine
from urllib.request import pathname2url from urllib.request import pathname2url
@ -49,10 +49,10 @@ def get_engine(torrent_uri):
else: else:
proxy = None proxy = None
return Engine(uri=file_url(torrent_uri), download_path=storage_download_dir, 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, dht_routers=["router.bittorrent.com:6881", "router.utorrent.com:6881"], use_random_port=False,
listen_port=6881, 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']: while not option['storage_dir']: