Добавлен поисковик RuTracker. SOCKS-прокси для подключения к трекерам
parent
be14440f2f
commit
c4e6d7763e
6
addon.py
6
addon.py
|
@ -4,7 +4,7 @@ from codequick import Route, Script, Listitem, utils, run # @UnresolvedImport
|
|||
from codequick.storage import PersistentList # @UnresolvedImport
|
||||
import os.path
|
||||
import xbmcgui, xbmc
|
||||
from resources.lib.searchers import rutor, kinozal
|
||||
from resources.lib.searchers import rutor, kinozal, rutracker
|
||||
from resources.lib.utils import localize, store_torrent_file, get_engine
|
||||
from resources.lib.overrrides.session import torrent_file_fetch
|
||||
from resources.lib.player import VideoLoop
|
||||
|
@ -13,7 +13,8 @@ video_extensions = ('.mp4', '.avi', '.3gp', '.ogv', '.mkv', '.ts', '.mpg', '.mpe
|
|||
|
||||
search_engines = [
|
||||
rutor.SearchEngine,
|
||||
kinozal.SearchEngine
|
||||
kinozal.SearchEngine,
|
||||
rutracker.SearchEngine
|
||||
]
|
||||
|
||||
ROOT = os.path.abspath(os.path.dirname(__file__))
|
||||
|
@ -71,6 +72,7 @@ def search(plugin, search_query, thumb=None):
|
|||
for p, se in zip(range(0, 100, 100 / len(search_in)), search_in):
|
||||
progress.update(p, line1=se.name)
|
||||
found_items.extend(se().search(search_query))
|
||||
open('/tmp/t.t', 'w').write(repr(list(map(lambda x: x.url, found_items))))
|
||||
res_items = []
|
||||
for i in sorted(found_items, key=lambda x: x.seeders, reverse=True):
|
||||
if '2160p' in i.title: hd = '[2160p/{}] '.format(i.size)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<addon id="plugin.video.torrenter3" name="Torrenter3" provider-name="inpos" version="3.1.2">
|
||||
<addon id="plugin.video.torrenter3" name="Torrenter3" provider-name="inpos" version="3.2.0">
|
||||
<requires>
|
||||
<import addon="xbmc.python" version="2.25.0"/>
|
||||
<import addon="script.module.pyrrent2http"/>
|
||||
|
@ -22,8 +22,9 @@
|
|||
<email>roman@ukamnya.ru</email>
|
||||
<platform>all</platform>
|
||||
<language>en_GB ru_RU</language>
|
||||
<news>- 3.1.0: add searcher kinozal.tv</news>
|
||||
<news>- 3.0.1: first rewrited version</news>
|
||||
<news>- 3.2.0: Add searcher rutracker.org. Add socks-proxy for trackers</news>
|
||||
<news>- 3.1.0: Add searcher kinozal.tv</news>
|
||||
<news>- 3.0.1: First rewrited version</news>
|
||||
<reuselanguageinvoker>true</reuselanguageinvoker>
|
||||
</extension>
|
||||
</addon>
|
||||
|
|
|
@ -31,6 +31,10 @@ msgctxt "#33003"
|
|||
msgid "Kinozal"
|
||||
msgstr "Kinozal"
|
||||
|
||||
msgctxt "#33004"
|
||||
msgid "RuTracker"
|
||||
msgstr "RuTracker"
|
||||
|
||||
msgctxt "#33011"
|
||||
msgid "Storage folder"
|
||||
msgstr "Storage folder"
|
||||
|
@ -47,6 +51,10 @@ msgctxt "#33014"
|
|||
msgid "SOCKS port"
|
||||
msgstr "SOCKS port"
|
||||
|
||||
msgctxt "#33015"
|
||||
msgid "Use SOCKS proxy for trackers"
|
||||
msgstr "Use SOCKS proxy for trackers"
|
||||
|
||||
msgctxt "#33051"
|
||||
msgid "Please specify storage folder in Settings!"
|
||||
msgstr "Please specify storage folder in Settings"
|
||||
|
|
|
@ -31,6 +31,10 @@ msgctxt "#33003"
|
|||
msgid "Kinozal"
|
||||
msgstr "Kinozal"
|
||||
|
||||
msgctxt "#33004"
|
||||
msgid "RuTracker"
|
||||
msgstr "RuTracker"
|
||||
|
||||
msgctxt "#33011"
|
||||
msgid "Storage folder"
|
||||
msgstr "Папка хранения"
|
||||
|
@ -47,6 +51,10 @@ msgctxt "#33014"
|
|||
msgid "SOCKS port"
|
||||
msgstr "Порт SOCKS"
|
||||
|
||||
msgctxt "#33015"
|
||||
msgid "Use SOCKS proxy for trackers"
|
||||
msgstr "Использовать SOCKS-прокси для подключения к трекерам"
|
||||
|
||||
msgctxt "#33051"
|
||||
msgid "Please specify storage folder in Settings!"
|
||||
msgstr "Укажите папку хранения"
|
||||
|
|
|
@ -49,7 +49,7 @@ class SearchEngine(Searcher):
|
|||
self.cookies = cookies
|
||||
return True
|
||||
except:
|
||||
notify('Kinozal.tv', localize(33056), local_image.format('searcher_kinozal.png'))
|
||||
notify(self.name, localize(33056), local_image.format(self.icon))
|
||||
return False
|
||||
def normalize_url(self, url):
|
||||
return url.encode('cp1251')
|
||||
|
|
|
@ -11,6 +11,7 @@ class SearchEngine(Searcher):
|
|||
url_constructor = urljoin_partial(self.base_url)
|
||||
rows = list(filter(lambda x: len(x.findall('.//a')) == 3, body.findall('.//tr')))
|
||||
for r in rows:
|
||||
try:
|
||||
links = r.findall('.//a')
|
||||
url = url_constructor(links[0].get('href').strip())
|
||||
title = links[2].text
|
||||
|
@ -22,3 +23,5 @@ class SearchEngine(Searcher):
|
|||
)[0].itertext()
|
||||
)[0].strip()
|
||||
yield ResultItem(url, title, size, seeders, leachers, self.icon, self.cookies, self.base_url)
|
||||
except:
|
||||
continue
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from . import Searcher, urljoin_partial, ResultItem
|
||||
from ..settings import option
|
||||
from ..utils import notify, localize
|
||||
from codequick.listing import local_image # @UnresolvedImport
|
||||
|
||||
class SearchEngine(Searcher):
|
||||
base_url = option['rutracker_url']
|
||||
search_path = '/forum/tracker.php?nm={}'
|
||||
name = 'RuTracker.org'
|
||||
icon = 'searcher_rutracker.png'
|
||||
enabled = option.get_boolean('rutracker_enable') # @UndefinedVariable
|
||||
def prepare(self):
|
||||
if self.cookies:
|
||||
bb_session = self.cookies.get('bb_session', None)
|
||||
if bb_session:
|
||||
return True
|
||||
return self.login()
|
||||
def process(self, body):
|
||||
url_constructor = urljoin_partial(self.base_url)
|
||||
rows = body.findall('.//div[@id="search-results"]/table/tbody/tr')
|
||||
for r in rows:
|
||||
link = list(filter(lambda x: 't-title' in x.attrib['class'], r.findall('.//td')))[0].find('.//a')
|
||||
url_part = link.get('href').strip().split('=')[1]
|
||||
url = url_constructor(u'/forum/dl.php?t={}'.format(url_part))
|
||||
title = link.text
|
||||
seeders_el = r.find('.//*[@class="seedmed"]')
|
||||
seeders = int(seeders_el.text.strip() if seeders_el is not None else 0)
|
||||
leachers = int(list(filter(lambda x: 'leechmed' in x.attrib['class'], r.findall('.//td')))[0].text.strip())
|
||||
size = ' '.join(list(filter(lambda x: 't-title' in x.attrib['class'], r.findall('.//td')))[0].find('.//a').text.strip().split(' ')[:2])
|
||||
yield ResultItem(url, title, size, seeders, leachers, self.icon, self.cookies, self.base_url)
|
||||
def login(self):
|
||||
user = option['rutracker_login']
|
||||
password = option['rutracker_password']
|
||||
try:
|
||||
if not user or not password:
|
||||
raise Exception
|
||||
resp = self.session.post('{}/forum/login.php'.format(self.base_url), data={'login_username': user,
|
||||
'login_password': password,
|
||||
'login': '%C2%F5%EE%E4',
|
||||
'redirect': 'index.php'},
|
||||
cookies={}, headers=self.headers, allow_redirects=False)
|
||||
if not resp.ok:
|
||||
raise Exception
|
||||
cookies = resp.cookies
|
||||
bb_session = cookies.get('bb_session', None)
|
||||
if not bb_session:
|
||||
raise Exception
|
||||
self.cookies = cookies
|
||||
return True
|
||||
except:
|
||||
notify(self.name, localize(33056), local_image.format(self.icon))
|
||||
return False
|
||||
def normalize_url(self, url):
|
||||
return url.encode('cp1251')
|
|
@ -39,10 +39,17 @@ def file_url(path):
|
|||
return path
|
||||
|
||||
def get_engine(torrent_uri):
|
||||
if option.get_boolean('use_socks_for_trackers'): # @UndefinedVariable
|
||||
proxy = {
|
||||
'host': option['socks_ip'],
|
||||
'port': int(option['socks_port'])
|
||||
}
|
||||
else:
|
||||
proxy = None
|
||||
return Engine(uri=file_url(torrent_uri), download_path=storage_download_dir,
|
||||
encryption=1, keep_complete=False, keep_incomplete=False,
|
||||
dht_routers=["router.bittorrent.com:6881", "router.utorrent.com:6881"], use_random_port=False, listen_port=6881,
|
||||
user_agent='', enable_dht=True)
|
||||
user_agent='', enable_dht=True, proxy=proxy)
|
||||
while not option['storage_dir']:
|
||||
dialog = xbmcgui.Dialog()
|
||||
dialog.ok(localize(33000), localize(33051))
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 46 KiB |
|
@ -5,6 +5,7 @@
|
|||
<setting label="33012" type="bool" id="use_socks" default="false"/>
|
||||
<setting label="33013" type="ipaddress" id="socks_ip" default="127.0.0.1" visible="eq(-1,true)"/>
|
||||
<setting label="33014" type="number" id="socks_port" default="9050" visible="eq(-2,true)"/>
|
||||
<setting label="33015" type="bool" id="use_socks_for_trackers" default="false" visible="eq(-3,true)"/>
|
||||
</category>
|
||||
<category label="33002">
|
||||
<setting label="33057" type="bool" id="rutor_enable" default="true"/>
|
||||
|
@ -16,4 +17,10 @@
|
|||
<setting label="33059" type="text" id="kinozal_login" default="" visible="eq(-2,true)"/>
|
||||
<setting label="33060" type="text" id="kinozal_password" default="" option="hidden" visible="eq(-3,true)" enable="!eq(-1,)"/>
|
||||
</category>
|
||||
<category label="33004">
|
||||
<setting label="33057" type="bool" id="rutracker_enable" default="true"/>
|
||||
<setting label="33058" type="text" id="rutracker_url" default="https://rutracker.org" visible="eq(-1,true)"/>
|
||||
<setting label="33059" type="text" id="rutracker_login" default="" visible="eq(-2,true)"/>
|
||||
<setting label="33060" type="text" id="rutracker_password" default="" option="hidden" visible="eq(-3,true)" enable="!eq(-1,)"/>
|
||||
</category>
|
||||
</settings>
|
||||
|
|
Loading…
Reference in New Issue