Добавлен поисковик RuTracker. SOCKS-прокси для подключения к трекерам
This commit is contained in:
1 parent
be14440f2f
commit
c4e6d7763e
10 files changed
+109
-18
No files matched your search
@@ -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,14 +11,17 @@ 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:
|
||||
links = r.findall('.//a')
|
||||
url = url_constructor(links[0].get('href').strip())
|
||||
title = links[2].text
|
||||
seeders = int(list(r.findall('.//span[@class="green"]')[0].itertext())[0].strip())
|
||||
leachers = int(list(r.findall('.//span[@class="red"]')[0].itertext())[0].strip())
|
||||
size = list(
|
||||
list(filter(lambda x: len(list(x.itertext())) == 1 and list(x.itertext())[0].strip().endswith(('GB', 'MB')),
|
||||
r.findall('.//td'))
|
||||
)[0].itertext()
|
||||
)[0].strip()
|
||||
yield ResultItem(url, title, size, seeders, leachers, self.icon, self.cookies, self.base_url)
|
||||
try:
|
||||
links = r.findall('.//a')
|
||||
url = url_constructor(links[0].get('href').strip())
|
||||
title = links[2].text
|
||||
seeders = int(list(r.findall('.//span[@class="green"]')[0].itertext())[0].strip())
|
||||
leachers = int(list(r.findall('.//span[@class="red"]')[0].itertext())[0].strip())
|
||||
size = list(
|
||||
list(filter(lambda x: len(list(x.itertext())) == 1 and list(x.itertext())[0].strip().endswith(('GB', 'MB')),
|
||||
r.findall('.//td'))
|
||||
)[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>
|
||||
Reference in new issue
Block a user