добавлен поисковик kinozal.tv
parent
b3a8e55bc0
commit
77f369a3f5
8
addon.py
8
addon.py
|
@ -4,7 +4,7 @@ from codequick import Route, Script, Listitem, utils, run # @UnresolvedImport
|
||||||
from codequick.storage import PersistentList # @UnresolvedImport
|
from codequick.storage import PersistentList # @UnresolvedImport
|
||||||
import os.path
|
import os.path
|
||||||
import xbmcgui, xbmc
|
import xbmcgui, xbmc
|
||||||
from resources.lib.searchers import rutor
|
from resources.lib.searchers import rutor, kinozal
|
||||||
from resources.lib.utils import localize, store_torrent_file, get_engine
|
from resources.lib.utils import localize, store_torrent_file, get_engine
|
||||||
from resources.lib.overrrides.session import torrent_file_fetch
|
from resources.lib.overrrides.session import torrent_file_fetch
|
||||||
from resources.lib.player import VideoLoop
|
from resources.lib.player import VideoLoop
|
||||||
|
@ -12,7 +12,8 @@ from resources.lib.player import VideoLoop
|
||||||
video_extensions = ('.mp4', '.avi', '.3gp', '.ogv', '.mkv', '.ts', '.mpg', '.mpeg', '.webm', '.flv', '.vob')
|
video_extensions = ('.mp4', '.avi', '.3gp', '.ogv', '.mkv', '.ts', '.mpg', '.mpeg', '.webm', '.flv', '.vob')
|
||||||
|
|
||||||
search_engines = [
|
search_engines = [
|
||||||
rutor.SearchEngine
|
rutor.SearchEngine,
|
||||||
|
kinozal.SearchEngine
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT = os.path.abspath(os.path.dirname(__file__))
|
ROOT = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
@ -66,7 +67,8 @@ def search(plugin, search_query, thumb=None):
|
||||||
progress = xbmcgui.DialogProgress()
|
progress = xbmcgui.DialogProgress()
|
||||||
found_items = []
|
found_items = []
|
||||||
progress.create(localize(33054))
|
progress.create(localize(33054))
|
||||||
for p, se in zip(range(0, 100, 100 / len(search_engines)), search_engines):
|
search_in = list(filter(lambda x: x.enabled, search_engines))
|
||||||
|
for p, se in zip(range(0, 100, 100 / len(search_in)), search_in):
|
||||||
progress.update(p, line1=se.name)
|
progress.update(p, line1=se.name)
|
||||||
found_items.extend(se().search(search_query))
|
found_items.extend(se().search(search_query))
|
||||||
res_items = []
|
res_items = []
|
||||||
|
|
|
@ -23,6 +23,14 @@ msgctxt "#33001"
|
||||||
msgid "General"
|
msgid "General"
|
||||||
msgstr "General"
|
msgstr "General"
|
||||||
|
|
||||||
|
msgctxt "#33002"
|
||||||
|
msgid "RuTor"
|
||||||
|
msgstr "RuTor"
|
||||||
|
|
||||||
|
msgctxt "#33003"
|
||||||
|
msgid "Kinozal"
|
||||||
|
msgstr "Kinozal"
|
||||||
|
|
||||||
msgctxt "#33011"
|
msgctxt "#33011"
|
||||||
msgid "Storage folder"
|
msgid "Storage folder"
|
||||||
msgstr "Storage folder"
|
msgstr "Storage folder"
|
||||||
|
@ -59,3 +67,22 @@ msgctxt "#33055"
|
||||||
msgid "Waiting for download"
|
msgid "Waiting for download"
|
||||||
msgstr "Waiting for download"
|
msgstr "Waiting for download"
|
||||||
|
|
||||||
|
msgctxt "#33056"
|
||||||
|
msgid "Invalid login or password"
|
||||||
|
msgstr "Invalid login or password"
|
||||||
|
|
||||||
|
msgctxt "#33057"
|
||||||
|
msgid "Enable searcher"
|
||||||
|
msgstr "Enable searcher"
|
||||||
|
|
||||||
|
msgctxt "#33058"
|
||||||
|
msgid "Searcher URL"
|
||||||
|
msgstr "Searcher URL"
|
||||||
|
|
||||||
|
msgctxt "#33059"
|
||||||
|
msgid "Login"
|
||||||
|
msgstr "Login"
|
||||||
|
|
||||||
|
msgctxt "#33060"
|
||||||
|
msgid "Password"
|
||||||
|
msgstr "Password"
|
||||||
|
|
|
@ -23,6 +23,14 @@ msgctxt "#33001"
|
||||||
msgid "General"
|
msgid "General"
|
||||||
msgstr "Основные"
|
msgstr "Основные"
|
||||||
|
|
||||||
|
msgctxt "#33002"
|
||||||
|
msgid "RuTor"
|
||||||
|
msgstr "RuTor"
|
||||||
|
|
||||||
|
msgctxt "#33003"
|
||||||
|
msgid "Kinozal"
|
||||||
|
msgstr "Kinozal"
|
||||||
|
|
||||||
msgctxt "#33011"
|
msgctxt "#33011"
|
||||||
msgid "Storage folder"
|
msgid "Storage folder"
|
||||||
msgstr "Папка хранения"
|
msgstr "Папка хранения"
|
||||||
|
@ -58,3 +66,15 @@ msgstr "Поиск на трекерах"
|
||||||
msgctxt "#33055"
|
msgctxt "#33055"
|
||||||
msgid "Waiting for download"
|
msgid "Waiting for download"
|
||||||
msgstr "Ожидаем начало загрузки"
|
msgstr "Ожидаем начало загрузки"
|
||||||
|
|
||||||
|
msgctxt "#33056"
|
||||||
|
msgid "Invalid login or password"
|
||||||
|
msgstr "Неверный логин или пароль"
|
||||||
|
|
||||||
|
msgctxt "#33057"
|
||||||
|
msgid "Enable searcher"
|
||||||
|
msgstr "Включить поисковик"
|
||||||
|
|
||||||
|
msgctxt "#33058"
|
||||||
|
msgid "Searcher URL"
|
||||||
|
msgstr "URL поисковика"
|
||||||
|
|
|
@ -23,21 +23,26 @@ class Searcher(object):
|
||||||
name = 'BaseClass'
|
name = 'BaseClass'
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.session = session.Session()
|
self.session = session.Session()
|
||||||
|
self.headers = {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 YaBrowser/14.10.2062.12061 Safari/537.36',
|
||||||
|
'Referer': self.base_url
|
||||||
|
}
|
||||||
def prepare(self):
|
def prepare(self):
|
||||||
'''Login or something else if needed'''
|
'''Login or something else if needed'''
|
||||||
|
return True
|
||||||
def search(self, query):
|
def search(self, query):
|
||||||
self.prepare()
|
if self.prepare():
|
||||||
url_constructor = urljoin_partial(self.base_url)
|
try:
|
||||||
s_url = url_constructor(self.search_path.format(urlquick.quote(query)))
|
url_constructor = urljoin_partial(self.base_url)
|
||||||
self.set_headers()
|
s_url = self.normalize_url(url_constructor(self.search_path.format(urlquick.quote(query))))
|
||||||
resp = self.session.get(s_url, cookies=self.cookies, headers=self.headers)
|
resp = self.session.get(s_url, cookies=self.cookies, headers=self.headers)
|
||||||
self.cookies = resp.cookies
|
body = resp.parse('body')
|
||||||
body = resp.parse('body')
|
return self.process(body)
|
||||||
return self.process(body)
|
except:
|
||||||
|
return []
|
||||||
|
else:
|
||||||
|
return []
|
||||||
def process(self, body):
|
def process(self, body):
|
||||||
'''Process element tree'''
|
'''Process element tree'''
|
||||||
def set_headers(self):
|
def normalize_url(self, url):
|
||||||
self.headers = {
|
return url
|
||||||
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 YaBrowser/14.10.2062.12061 Safari/537.36',
|
|
||||||
'Referer': self.base_url
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
# -*- 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['kinozal_url']
|
||||||
|
search_path = '/browse.php?s={}&g=0&c=0&v=0&d=0&w=0&t=1&f=0'
|
||||||
|
name = 'Kinozal.tv'
|
||||||
|
icon = 'searcher_kinozal.png'
|
||||||
|
enabled = option.get_boolean('kinozal_enable') # @UndefinedVariable
|
||||||
|
def prepare(self):
|
||||||
|
if self.cookies:
|
||||||
|
c_uid = self.cookies.get('uid', None)
|
||||||
|
c_pass = self.cookies.get('pass', None)
|
||||||
|
if c_uid and c_pass:
|
||||||
|
return True
|
||||||
|
return self.login()
|
||||||
|
def process(self, body):
|
||||||
|
url_constructor = urljoin_partial(self.base_url)
|
||||||
|
rows = list(filter(lambda x: x.get('class') in ['first bg', 'bg'], body.findall('.//tr[@class]')))
|
||||||
|
for r in rows:
|
||||||
|
link = r.find('.//td[@class="nam"]/a')
|
||||||
|
url_part = link.get('href').strip().split('=')[1]
|
||||||
|
url = url_constructor(u'/download.php?id={}'.format(url_part))
|
||||||
|
title = link.text
|
||||||
|
seeders = int(r.find('.//td[@class="sl_s"]').text.strip())
|
||||||
|
leachers = int(r.find('.//td[@class="sl_p"]').text.strip())
|
||||||
|
size = list(
|
||||||
|
list(filter(lambda x: x.text.strip().endswith((u'ГБ', u'МБ')),
|
||||||
|
r.findall('.//td[@class="s"]'))
|
||||||
|
)[0].text.strip()
|
||||||
|
)[0].strip()
|
||||||
|
yield ResultItem(url, title, size, seeders, leachers, self.icon, self.cookies, self.base_url)
|
||||||
|
def login(self):
|
||||||
|
user = option['kinozal_login']
|
||||||
|
password = option['kinozal_password']
|
||||||
|
try:
|
||||||
|
if not user or not password:
|
||||||
|
raise Exception
|
||||||
|
resp = self.session.post('{}/takelogin.php'.format(self.base_url), data={'username': user, 'password': password, 'returnto': ''},
|
||||||
|
cookies={}, headers=self.headers, allow_redirects=False)
|
||||||
|
if not resp.ok:
|
||||||
|
raise Exception
|
||||||
|
cookies = resp.cookies
|
||||||
|
c_uid = cookies.get('uid', None)
|
||||||
|
c_pass = cookies.get('pass', None)
|
||||||
|
if not c_uid or not c_pass:
|
||||||
|
raise Exception
|
||||||
|
self.cookies = cookies
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
notify('Kinozal.tv', localize(33056), local_image.format('searcher_kinozal.png'))
|
||||||
|
return False
|
||||||
|
def normalize_url(self, url):
|
||||||
|
return url.encode('cp1251')
|
|
@ -1,11 +1,12 @@
|
||||||
from . import Searcher, urljoin_partial, ResultItem
|
from . import Searcher, urljoin_partial, ResultItem
|
||||||
|
from ..settings import option
|
||||||
|
|
||||||
class SearchEngine(Searcher):
|
class SearchEngine(Searcher):
|
||||||
#base_url = 'http://new-tor.top'
|
base_url = option['rutor_url']
|
||||||
base_url = 'http://rutor.info'
|
|
||||||
search_path = '/search/0/0/100/2/{}'
|
search_path = '/search/0/0/100/2/{}'
|
||||||
name = 'RuTor.org'
|
name = 'RuTor.org'
|
||||||
icon = 'searcher_rutor.png'
|
icon = 'searcher_rutor.png'
|
||||||
|
enabled = option.get_boolean('rutor_enable') # @UndefinedVariable
|
||||||
def process(self, body):
|
def process(self, body):
|
||||||
url_constructor = urljoin_partial(self.base_url)
|
url_constructor = urljoin_partial(self.base_url)
|
||||||
rows = list(filter(lambda x: len(x.findall('.//a')) == 3, body.findall('.//tr')))
|
rows = list(filter(lambda x: len(x.findall('.//a')) == 3, body.findall('.//tr')))
|
||||||
|
|
|
@ -13,6 +13,10 @@ if py3:
|
||||||
else:
|
else:
|
||||||
from urllib import pathname2url
|
from urllib import pathname2url
|
||||||
|
|
||||||
|
def notify(heading, message, icon=xbmcgui.NOTIFICATION_INFO):
|
||||||
|
n = xbmcgui.Dialog()
|
||||||
|
n.notification(heading, message, icon, time=5, sound=True)
|
||||||
|
|
||||||
def localize(sid):
|
def localize(sid):
|
||||||
return addon_data.getLocalizedString(sid)
|
return addon_data.getLocalizedString(sid)
|
||||||
def store_torrent_file(file_bytes):
|
def store_torrent_file(file_bytes):
|
||||||
|
|
|
@ -6,4 +6,14 @@
|
||||||
<setting label="33013" type="ipaddress" id="socks_ip" default="127.0.0.1" visible="eq(-1,true)"/>
|
<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="33014" type="number" id="socks_port" default="9050" visible="eq(-2,true)"/>
|
||||||
</category>
|
</category>
|
||||||
|
<category label="33002">
|
||||||
|
<setting label="33057" type="bool" id="rutor_enable" default="true"/>
|
||||||
|
<setting label="33058" type="text" id="rutor_url" default="http://rutor.info" visible="eq(-1,true)"/>
|
||||||
|
</category>
|
||||||
|
<category label="33003">
|
||||||
|
<setting label="33057" type="bool" id="kinozal_enable" default="true"/>
|
||||||
|
<setting label="33058" type="text" id="kinozal_url" default="http://kinozal.tv" visible="eq(-1,true)"/>
|
||||||
|
<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>
|
||||||
</settings>
|
</settings>
|
||||||
|
|
Loading…
Reference in New Issue