def kat_search(): import urllib query = plugin.request.args_dict.pop("query", None) suffix = plugin.request.args_dict.pop("query_suffix", "") if not query: query = plugin.keyboard("", "XBMCtorrent - Kickass Torrent - Search") if query: plugin.redirect(plugin.url_for("kat_page", root="usearch/%s" % urllib.quote("%s %s verified:1" % (query, suffix), safe=""), page=1, **plugin.request.args_dict))
def torrents3d_search(): query = plugin.request.args.get("query") if query: query = query[0] else: query = plugin.keyboard("", "Torrents3D.ru - Search") if query: plugin.redirect(plugin.url_for("torrents3d_resuls", query=query, page=0))
def nyaa_search(): query = plugin.request.args.get("query") if query: query = query[0] else: query = plugin.keyboard("", "XBMCtorrent - NyaaTorrents - Search") if query: plugin.redirect(plugin.url_for("search_result_page", page="search", cats="0_0", filter=0, term=query, offset=1, sort=SORT_DATE, order=SORT_DESCENDING))
def yify_search(): query = plugin.request.args.get("query") if query: query = query[0] else: query = plugin.keyboard("", "XBMCtorrent - YIFY - Search") if query: plugin.redirect(plugin.url_for("yify_search_query", keywords=query, quality="all", set=1, limit=MOVIES_PER_PAGE))
def bitsnoop_search(): import urllib from xbmctorrent.utils import first query = plugin.request.args_dict.pop("query", None) if not query: query = plugin.keyboard("", "XBMCtorrent - Bitsnoop - Search") if query: plugin.redirect(plugin.url_for("bitsnoop_page", root="/search/video/%s/c/d/" % urllib.quote("%s safe:no" % query, safe=""), page=1, **plugin.request.args_dict))
def rutracker_search(catind): query = plugin.request.args.get("query") if query: query = query[0] else: query = plugin.keyboard("", "Rutracker.org - Search") if query: plugin.redirect(plugin.url_for("rutracker_search_page", catind=catind, page=0, search=query))
def extratorrent_search(): query = plugin.request.args_dict.pop("query", None) if not query: query = plugin.keyboard("", "XBMCtorrent - ExtraTorrent - Search") if query: plugin.redirect( plugin.url_for("extratorrent_page_search", type="search", search=query, **plugin.request.args_dict))
def piratebay_search(): import urllib query = plugin.request.args.get("query") if query: query = query[0] else: query = plugin.keyboard("", "XBMCtorrent - The Pirate Bay - Search") if query: plugin.redirect(plugin.url_for("piratebay_page", root="/search/%s" % urllib.quote(query, safe=""), page=0))
def kickass_search(): import urllib query = plugin.request.args.get("query") if query: query = query[0] else: query = plugin.keyboard("", "XBMCtorrent - Kickass Torrent - Search") if query: plugin.redirect(plugin.url_for("kickass_page", root="usearch/%s/" % urllib.quote(query), page=0))
def piratebay_search(): import urllib query = plugin.request.args.get("query") if query: query = query[0] else: query = plugin.keyboard("", "XBMCtorrent - The Pirate Bay - Search") if query: plugin.redirect(plugin.url_for("piratebay_page", root="/search/%s" % urllib.quote(query), page=0))
def ilcorsaronero_search(): import urllib query = plugin.request.args.get("query") if query: query = query[0] else: query = plugin.keyboard("", "XBMCtorrent - ilCorsaronero - Search") if query: plugin.redirect(plugin.url_for("ilcorsaronero_page", root="/argh.php?search=%s" % urllib.quote(query, safe=""), page=0))
def ilcorsaronero_play(uri): import re from bs4 import BeautifulSoup from xbmctorrent.utils import url_get html_data = url_get(uri, headers=HEADERS) soup = BeautifulSoup(html_data, "html5lib") magnet_node = soup.findAll("a", class_="forbtn", href=re.compile("magnet")) plugin.redirect(plugin.url_for("play", uri=magnet_node[0]["href"]))
def rutor_search(): import urllib query = plugin.request.args.get("query") if query: query = query[0] else: query = plugin.keyboard("", "RuTor.org - Search") if query: plugin.redirect(plugin.url_for("rutor_page", catind=0, page=0, query=urllib.quote(query)))
def torrents3d_search(): import urllib query = plugin.request.args.get("query") if query: query = query[0] else: query = plugin.keyboard("", "Torrents3D.ru - Search") if query: plugin.redirect( plugin.url_for("torrents3d_resuls", query=query, page=0))
def btdigg_search(): query = plugin.request.args_dict.pop("query", None) if not query: query = plugin.keyboard("", "XBMCtorrent - BTDigg - Search") if query: plugin.redirect( plugin.url_for("btdigg_page", query=query, sort=SORT_POPULARITY, page=0, **plugin.request.args_dict))
def cpb_search(): query = plugin.request.args_dict.pop("query", None) if not query: query = plugin.keyboard("", "XBMCtorrent - CPasBien - Recherche") if query: plugin.redirect( plugin.url_for("cpb_page", cat="recherche", query=query, sort=SORT_DATE + SORT_DIRECTION_DESC, page=0, **plugin.request.args_dict))
def kickass_search(): import urllib query = plugin.request.args.get("query") if query: query = query[0] else: query = plugin.keyboard("", "XBMCtorrent - Kickass Torrent - Search") if query: plugin.redirect( plugin.url_for("kickass_page", root="usearch/%s/" % urllib.quote(query), page=0))
def eztv_get_show_seasons(show_id): import random from bs4 import BeautifulSoup from itertools import groupby from multiprocessing.pool import ThreadPool from xbmctorrent.utils import first, terminating, url_get from xbmctorrent import tvdb # plugin.set_content("seasons") tvdb_id = first(plugin.request.args.get("tvdb_id")) with terminating(ThreadPool(2)) as pool: def _eztv_get_show(): plugin.log.info("Getting show") response = url_get("http://eztv.it/shows/%s/" % show_id, headers=HEADERS) plugin.log.info("Got show") return BeautifulSoup(response, "html5lib") soup = pool.apply_async(_eztv_get_show) if tvdb_id: tvdb_show = pool.apply_async(tvdb.get_all_meta, [plugin.request.args["tvdb_id"][0]]) soup = soup.get() fanarts = [] if tvdb_id: tvdb_show = tvdb_show.get() fanarts = list([banner for banner in tvdb_show["banners"] if banner["bannertype"] == "fanart"]) random.shuffle(fanarts) for node in soup.findAll("a", "epinfo"): if get_episode_data_from_name(node.text)[0] < 0: plugin.redirect(plugin.url_for("eztv_get_episodes_for_season", show_id=show_id, season=-1, tvdb_id=tvdb_id)) return # This is needed because we need to be able to redirect if no seasons are found. items = [] for i, (season, episodes) in enumerate(groupby(soup.findAll("a", "epinfo"), lambda node: get_episode_data_from_name(node.text)[0])): if tvdb_id: item = tvdb.get_season_list_item(tvdb_show, season) else: item = { "label": "Season %d" % season } item.update({ "path": plugin.url_for("eztv_get_episodes_for_season", show_id=show_id, season=season, tvdb_id=tvdb_id), }) # if fanarts: item.setdefault("properties", {}).update({ "fanart_image": fanarts[i % len(fanarts)]["bannerpath"], }) items.append(item) return items
def rutor_search(): import urllib query = plugin.request.args.get("query") if query: query = query[0] else: query = plugin.keyboard("", "RuTor.org - Search") if query: plugin.redirect( plugin.url_for("rutor_page", catind=0, page=0, query=urllib.quote(query)))
def bitsnoop_search(): import urllib from xbmctorrent.utils import first query = plugin.request.args_dict.pop("query", None) if not query: query = plugin.keyboard("", "XBMCtorrent - Bitsnoop - Search") if query: plugin.redirect( plugin.url_for("bitsnoop_page", root="/search/video/%s/c/d/" % urllib.quote("%s safe:no" % query, safe=""), page=1, **plugin.request.args_dict))
def torrents3d_play(article): import xbmcgui from bs4 import BeautifulSoup from contextlib import closing from urlparse import urljoin from xbmctorrent.magnet import generate_magnet from xbmctorrent.utils import SafeDialogProgress article = int(article) with closing(SafeDialogProgress(delay_close=0)) as dialog: dialog.create(plugin.name) dialog.update(percent=0, line1=u"Получение информации о релизе...", line2="", line3="") url = urljoin(BASE_URL, "article/%d" % article) try: html_data = url_get(url, headers=HEADERS) soup = BeautifulSoup(html_data, "html5lib") torrent_href = soup.find("a", class_="genmed") if not torrent_href: dialog.update(percent=50, line2=u"Требуется авторизация. Авторизация...") if not plugin.get_setting("t3d_login") and not plugin.get_setting("t3d_passwd"): plugin.notify("Проверьте настройки авторизации.", delay=15000) return html_data = _torrents3d_login(url) soup = BeautifulSoup(html_data, "html5lib") torrent_href = soup.find("a", class_="genmed") if not torrent_href: xbmcgui.Dialog().ok(plugin.name, "Авторизация неудалась. Проверьте настройки авторизации.") return dialog.update(percent=100, line2=u"Обработка данных.") from bencode import bdecode title = "[%s] %s" % _torrents3d_cleantitle(soup.find("a", class_="tt-text").text) torrent_data = url_get(torrent_href["href"], headers=HEADERS) metadata = bdecode(torrent_data) plugin.redirect(plugin.url_for("play", uri=generate_magnet(metadata, uenc(title)))) except Exception: plugin.log.error("Cannot get data from remote server") xbmcgui.Dialog().ok(plugin.name, u"Не удалось получить данные от сервера") return
def cpb_search(): query = plugin.request.args_dict.pop("query", None) if not query: query = plugin.keyboard("", "XBMCtorrent - CPasBien - Recherche") if query: plugin.redirect( plugin.url_for( "cpb_page", cat="recherche", query=query, sort=SORT_DATE + SORT_DIRECTION_DESC, page=0, **plugin.request.args_dict ) )
def rutracker_search(catind): import urllib query = plugin.request.args.get("query") if query: query = query[0] else: query = plugin.keyboard("", "Rutracker.org - Search") if query: plugin.redirect( plugin.url_for("rutracker_search_page", catind=catind, page=0, search=query))
def rutor_play(tid, pulsar): from contextlib import closing from bencode import bdecode from urlparse import urljoin from xbmctorrent.magnet import generate_magnet from xbmctorrent.utils import first, SafeDialogProgress from xbmctorrent.acestream import ace_supported with closing(SafeDialogProgress(delay_close=0)) as dialog: dialog.create(plugin.name) dialog.update(percent=0, line1="Получение информации о раздаче...") torrent_url = urljoin(BASE_URL, "download/%s" % tid) try: metadata = bdecode(url_get(torrent_url, headers=HEADERS)) except Exception: import xbmcgui plugin.log.error("Unexpected error: %s" % sys.exc_info()[0]) xbmcgui.Dialog().ok(plugin.name, "Не удалось получить данные от сервера") return dialog.update(percent=100, line1="Готово") if "files" in metadata["info"]: # and ace_supported(): items = [] for index, info in enumerate(metadata["info"]["files"]): name = "/".join(info["path"]) if not _rutor_valid_file(name): continue if plugin.get_setting("torrent_engine", int) == 1 and ace_supported(): path = plugin.url_for("torrent_play", url=torrent_url, index=index, name=name) else: path = plugin.url_for("play_file", uri=generate_magnet(metadata, name), index=index) items.append({"label": name, "path": path}) items = sorted(items, key=lambda x: x["label"]) if len(items) == 1: # start playback if torrent contains only one file plugin.redirect(items[0]["path"]) else: # ask to select which file to play import xbmcgui select_items = [item["label"] for item in items] select = xbmcgui.Dialog().select("Выберите файл для проигрывания", select_items) if select >= 0: plugin.redirect(items[select]["path"]) else: name = metadata["info"].get("name") or " / ".join(first(metadata["info"]["files"])["path"]) or "rutor.org" if plugin.get_setting("torrent_engine", int) == 1 and ace_supported(): path = plugin.url_for("torrent_play", url=torrent_url, index=0, name=name) else: path = plugin.url_for(["play", "play_with_pulsar"][int(pulsar)], uri=generate_magnet(metadata, name)) plugin.redirect(path)
def rutracker_play(tid, pulsar): from contextlib import closing from bencode import bdecode from urlparse import urljoin from xbmctorrent.magnet import generate_magnet from xbmctorrent.utils import first, SafeDialogProgress from xbmctorrent.acestream import ace_supported with closing(SafeDialogProgress(delay_close=0)) as dialog: dialog.create(plugin.name) dialog.update(percent=0, line1="Получение информации о раздаче...") try: data = url_get(urljoin(BASE_URL, "dl.php?t=%s" % tid)) metadata = bdecode(data) except Exception: plugin.log.error("Unexpected error: %s " % format_exc().split('\n')[-2]) xbmcgui.Dialog().ok(plugin.name, "Не удалось получить данные от сервера") return dialog.update(percent=100, line1="Готово") if "files" in metadata["info"]: # and ace_supported(): items = [] for index, info in enumerate(metadata["info"]["files"]): name = "/".join(info["path"]) decname = _rutracker_decode_try(name) if not _rutracker_valid_file(decname): continue name = uenc(decname) if plugin.get_setting("torrent_engine", int) == 1 and ace_supported(): path = plugin.url_for("play_torrent_raw", raw=data, index=index, name=name) else: path = plugin.url_for("play_file", uri=generate_magnet(metadata, name), index=index) items.append({"label": name, "path": path}) if len(items) == 1: # start playback if torrent contains only one file plugin.redirect(items[0]["path"]) else: select_items = [item["label"] for item in items] select = xbmcgui.Dialog().select("Выберите файл для проигрывания", select_items) if select >= 0: plugin.redirect(items[select]["path"]) else: name = metadata["info"].get("name") or " / ".join(first(metadata["info"]["files"])["path"]) or "rutracker.org" if plugin.get_setting("torrent_engine", int) == 1 and ace_supported(): path = plugin.url_for("play_torrent_raw", raw=data, index=0, name=name) else: path = plugin.url_for(["play", "play_with_pulsar"][int(pulsar)], uri=generate_magnet(metadata, name)) plugin.redirect(path)
def torrents3d_play(article): import re, xbmcgui from bs4 import BeautifulSoup from contextlib import closing from urlparse import urljoin from xbmctorrent.magnet import generate_magnet from xbmctorrent.utils import SafeDialogProgress article = int(article) with closing(SafeDialogProgress(delay_close=0)) as dialog: dialog.create(plugin.name) dialog.update(percent=0, line1=u"Получение информации о релизе...", line2="", line3="") url = urljoin(BASE_URL, "article/%d" % article) try: html_data = url_get(url, headers=HEADERS) soup = BeautifulSoup(html_data, "html5lib") torrent_href = soup.find("a", class_="genmed") if not torrent_href: dialog.update(percent=50, line2=u"Требуется авторизация. Авторизация...") if not plugin.get_setting( "t3d_login") and not plugin.get_setting("t3d_passwd"): plugin.notify("Проверьте настройки авторизации.", delay=15000) return html_data = _torrents3d_login(url) soup = BeautifulSoup(html_data, "html5lib") torrent_href = soup.find("a", class_="genmed") if not torrent_href: xbmcgui.Dialog().ok( plugin.name, "Авторизация неудалась. Проверьте настройки авторизации.") return dialog.update(percent=100, line2=u"Обработка данных.") from bencode import bencode, bdecode title = "[%s] %s" % _torrents3d_cleantitle( soup.find("a", class_="tt-text").text) torrent_data = url_get(torrent_href["href"], headers=HEADERS) metadata = bdecode(torrent_data) plugin.redirect( plugin.url_for("play", uri=generate_magnet(metadata, uenc(title)))) except: plugin.log.error("Cannot get data from remote server") xbmcgui.Dialog().ok(plugin.name, u"Не удалось получить данные от сервера") return
def btdigg_search(): query = plugin.request.args_dict.pop("query", None) if not query: query = plugin.keyboard("", "XBMCtorrent - BTDigg - Search") if query: plugin.redirect(plugin.url_for("btdigg_page", query=query, sort=SORT_POPULARITY, page=0, **plugin.request.args_dict))
def btdigg_index(): plugin.redirect(plugin.url_for("btdigg_search"))
def rutor_details(catind, tid): import urllib from bs4 import BeautifulSoup, SoupStrainer from urlparse import urljoin from xbmctorrent.utils import get_quality_from_name from xbmctorrent.search import scrapers as search scraper_name = "" category = ([cat for cat in CATEGORIES if cat[0] == catind] or [("0", u"", "", "")])[0] scraper_name = category[3] plugin.set_content(category[2]) tid = int(tid) try: html_data = url_get(urljoin(BASE_URL, "torrent/%d/" % tid), headers=HEADERS) except: import xbmcgui xbmcgui.Dialog().ok(plugin.name, "Не удалось получить данные от сервера") return soup = BeautifulSoup(html_data, "html5lib") div_download = soup.select("div#download")[0] div_index = soup.select("div#index") if len(div_index) == 0: plugin.redirect(plugin.url_for("rutor_play", tid=tid)) return scrapers = search.Scrapers() details = soup.select("table#details")[0].findAll("tr") seeds = details[4].contents[1].text peers = details[5].contents[1].text size = details[8].contents[1].text size = size[:size.find(" ")] title = _rutor_cleantitle(soup.h1.text) label = "%s | %s (S:%s P:%s)" % (title, size, seeds, peers) item = {"label": label, "info": {"title": title}} if plugin.get_setting("rutor_usesearch", bool): meta = scrapers.scraper(scraper_name, item) else: meta = scrapers.default(item) meta["path"] = plugin.url_for("rutor_play", tid=tid) meta["is_playable"] = False meta.setdefault("stream_info", {}).update(get_quality_from_name(meta['label'])) meta["context_menu"] = [ ("Play with Pulsar", actions.update_view(plugin.url_for("rutor_play_pulsar", tid=tid))) ] del meta["search"] del meta["subdir"] yield meta if len(div_index) > 0: nodes = div_index[0].findAll("tr", class_=["gai", "tum"]) nodes = [node for node in _rutor_filter_nodes(nodes)] for node in nodes: cells = node.findAll("td") seeds, peers = map(lambda x: x.text.strip(), cells[len(cells) - 1].findAll("span")) donwload_node, magnet_node, title_node = cells[1].findAll("a") size = cells[len(cells) - 2].text title = _rutor_cleantitle(title_node.text) tid = int(title_node["href"][9:title_node["href"].find(u"/", 9)]) label = "%s | %s (S:%s P:%s)" % (title, size, seeds, peers) item = scrapers.default({"label": label, "info": {"title": title}}) item.update({ "path": plugin.url_for("rutor_play", tid=tid), "is_playable": False, "thumbnail": meta["thumbnail"], "icon": meta["icon"] }) item["info"].update(meta["info"]) item["properties"].update(meta["properties"]) item.setdefault("stream_info", {}).update(get_quality_from_name(item['label'])) item["context_menu"] = [("Play with Pulsar", actions.update_view( plugin.url_for("rutor_play_pulsar", tid=tid)))] del item["search"] del item["subdir"] yield item
def bitsnoop_index(): plugin.redirect(plugin.url_for("bitsnoop_search"))
def rutor_details(catind, tid): import urllib from bs4 import BeautifulSoup, SoupStrainer from urlparse import urljoin from xbmctorrent.utils import get_quality_from_name from xbmctorrent.search import scrapers as search scraper_name = "" category = ([cat for cat in CATEGORIES if cat[0] == catind] or [("0", u"", "", "")])[0] scraper_name = category[3] plugin.set_content(category[2]) tid = int(tid) try: html_data = url_get(urljoin(BASE_URL, "torrent/%d/" % tid), headers=HEADERS) except: import xbmcgui xbmcgui.Dialog().ok(plugin.name, "Не удалось получить данные от сервера") return soup = BeautifulSoup(html_data, "html5lib") div_download = soup.select("div#download")[0] div_index = soup.select("div#index") if len(div_index) == 0: plugin.redirect(plugin.url_for("rutor_play", tid=tid)) return scrapers = search.Scrapers() details = soup.select("table#details")[0].findAll("tr") seeds = details[4].contents[1].text peers = details[5].contents[1].text size = details[8].contents[1].text size = size[:size.find(" ")] title = _rutor_cleantitle(soup.h1.text) label = "%s | %s (S:%s P:%s)" % (title, size, seeds, peers) item = { "label": label, "info" : { "title" : title } } if plugin.get_setting("rutor_usesearch", bool): meta = scrapers.scraper(scraper_name, item) else: meta = scrapers.default(item) meta["path"] = plugin.url_for("rutor_play", tid=tid) meta["is_playable"] = False meta.setdefault("stream_info", {}).update(get_quality_from_name(meta['label'])) meta["context_menu"] = [("Play with Pulsar", actions.update_view(plugin.url_for("rutor_play_pulsar", tid=tid)))] del meta["search"] del meta["subdir"] yield meta if len(div_index) > 0: nodes = div_index[0].findAll("tr", class_=["gai","tum"]) nodes = [node for node in _rutor_filter_nodes(nodes)] for node in nodes: cells = node.findAll("td") seeds, peers = map(lambda x: x.text.strip(), cells[len(cells)-1].findAll("span")) donwload_node, magnet_node, title_node = cells[1].findAll("a") size = cells[len(cells)-2].text title = _rutor_cleantitle(title_node.text) tid = int(title_node["href"][9:title_node["href"].find(u"/", 9)]) label = "%s | %s (S:%s P:%s)" % (title, size, seeds, peers) item = scrapers.default({ "label" : label, "info" : {"title" : title } }) item.update({ "path" : plugin.url_for("rutor_play", tid=tid), "is_playable" : False, "thumbnail" : meta["thumbnail"], "icon" : meta["icon"] }) item["info"].update(meta["info"]) item["properties"].update(meta["properties"]) item.setdefault("stream_info", {}).update(get_quality_from_name(item['label'])) item["context_menu"] = [("Play with Pulsar", actions.update_view(plugin.url_for("rutor_play_pulsar", tid=tid)))] del item["search"] del item["subdir"] yield item
def extratorrent_search(): query = plugin.request.args_dict.pop("query", None) if not query: query = plugin.keyboard("", "XBMCtorrent - ExtraTorrent - Search") if query: plugin.redirect(plugin.url_for("extratorrent_page_search", type="search", search=query, **plugin.request.args_dict))
def lostfilm_play(showid, season, episode): import re from contextlib import closing from bs4 import BeautifulSoup from xbmctorrent.acestream import ace_supported from xbmctorrent.utils import SafeDialogProgress, get_quality_from_name with closing(SafeDialogProgress(delay_close=0)) as dialog: dialog.create(plugin.name) dialog.update(percent=0, line1="Получение информации о релизе...", line2="", line3="") params = {"c": showid, "s": season, "e": episode} try: search_url = BASE_URL + "v_search.php" html = url_get(search_url, params=params) # catch 'log in first' then login if html.find("log in first") >= 0: dialog.update(percent=10, line2="Требуется авторизация. Авторизация...") if not plugin.get_setting("lostfilm_login") and not plugin.get_setting("lostfilm_passwd"): plugin.notify("Проверьте настройки авторизации.", delay=15000) return if not _lostfilm_login(): xbmcgui.Dialog().ok(plugin.name, "Авторизация неудалась1. Проверьте настройки.") return dialog.update(percent=30, line2="Загрузка.", line3="") html = url_get(search_url, params=params) if html.find("log in first") >= 0: xbmcgui.Dialog().ok(plugin.name, "Авторизация неудалась2. Проверьте настройки.") return except Exception: plugin.log.error("Unexpected error: %s" % sys.exc_info()[0]) xbmcgui.Dialog().ok(plugin.name, "Не удалось получить данные от сервера") return # catch redirect if html.find("location.replace") >= 0: replace_url = html[html.find("(\"") + 2:html.find("\");")] html = url_get(replace_url) dialog.update(percent=50, line2="Обработка данных.") soup = BeautifulSoup(html, "html5lib") divs = soup.find_all("div", class_=re.compile("main")) releases = [d.find("a") for d in divs] quality = plugin.get_setting("lostfilm_qlt", int) or 0 if quality <= 0 or quality > len(releases): select_items = [] for release in releases: lines = release.text.split("\n") select_items.append(lines[-1]) select = xbmcgui.Dialog().select("Выберите желаемое качество", select_items) else: select = quality - 1 if select >= 0: selected = releases[select] torrent_url = selected["href"] if (("-" not in episode and int(episode) == 999) or ("." in season and "-" in episode)): if "." in season: season = season[:season.find(u".")] plugin.add_sort_method("label") show_info = _lostfilm_get_db_info_by_id(showid) _lostfilm_close_dbase() try: from bencode import bdecode torrent_data = url_get(torrent_url) metadata = bdecode(torrent_data) except Exception: plugin.log.error("Cannot get data from remote server") xbmcgui.Dialog().ok(plugin.name, "Не удалось получить данные от сервера") return e = re.compile("(e[\d]+)?e([\d]+)\.", re.I | re.S | re.U) for index, item in enumerate(metadata["info"]["files"]): file_name = " / ".join(item["path"]) r = e.search(file_name) if r: if r.group(1): episode = r.group(1)[1:] else: episode = r.group(2) else: episode = u"" if plugin.get_setting("torrent_engine", int) == 1 and ace_supported(): path = plugin.url_for("torrent_play", url=torrent_url, index=index, name=file_name) else: path = plugin.url_for("play_file", uri=torrent_url, index=index) yield _lostfilm_updateitem_from_info({ "label": file_name, "path": path, "is_playable": True, "info": { "title": file_name, "season": season, "episode": episode }, "stream_info": get_quality_from_name(file_name) }, show_info) else: if plugin.get_setting("torrent_engine", int) == 1 and ace_supported(): path = plugin.url_for("torrent_play", url=torrent_url, index=0, name="LostFilm.Tv") else: path = plugin.url_for("play", uri=torrent_url) plugin.redirect(path)
def lostfilm_play(showid, season, episode): import re, xbmcgui from urlparse import urljoin from contextlib import closing from bs4 import BeautifulSoup from xbmctorrent.acestream import ace_supported from xbmctorrent.magnet import generate_magnet from xbmctorrent.utils import SafeDialogProgress, get_quality_from_name with closing(SafeDialogProgress(delay_close=0)) as dialog: dialog.create(plugin.name) dialog.update(percent=0, line1="Получение информации о релизе...", line2="", line3="") params = { "c" : showid, "s" : season, "e" : episode } try: html = url_get(urljoin(BASE_URL, "nrdr.php"), params=params) # catch 'log in first' then login if html.find("log in first") >= 0: dialog.update(percent=10, line2="Требуется авторизация. Авторизация...") if not plugin.get_setting("lostfilm_login") and not plugin.get_setting("lostfilm_passwd"): plugin.notify("Проверьте настройки авторизации.", delay=15000) return _lostfilm_login() dialog.update(percent=30, line2="Загрузка.", line3="") html = url_get(urljoin(BASE_URL, "nrdr.php"), params=params) if html.find("log in first") >= 0: xbmcgui.Dialog().ok(plugin.name, "Авторизация неудалась. Проверьте настройки.") return except: plugin.log.error("Unexpected error: %s" % sys.exc_info()[0]) xbmcgui.Dialog().ok(plugin.name, "Не удалось получить данные от сервера") return dialog.update(percent=50, line2="Обработка данных.") soup = BeautifulSoup(html, "html5lib", from_encoding="windows-1251") releases = soup.findAll("a", href=re.compile("tracktor.in"), style=re.compile("bold")) select_items = [] for release in releases: span = release.find_next("span") select_items.append(span.contents[0]) select = xbmcgui.Dialog().select("Выберите желаемое качество", select_items) if select >= 0: selected = releases[select] torrent_url = selected["href"] if ((not "-" in episode and int(episode) == 99) or ("." in season and "-" in episode)) and ace_supported(): if "." in season: season = season[:season.find(u".")] show_info = _lostfilm_get_db_info(showid) plugin.add_sort_method("label") try: from bencode import bencode, bdecode torrent_data = url_get(torrent_url, headers=HEADERS) metadata = bdecode(torrent_data) except: plugin.log.error("Cannot get data from remote server") xbmcgui.Dialog().ok(plugin.name, "Не удалось получить данные от сервера") return e = re.compile("(e[\d]+)?e([\d]+)\.", re.I|re.S|re.U) for index, item in enumerate(metadata["info"]["files"]): file_name = " / ".join(item["path"]) print file_name r = e.search(file_name) if r: if r.group(1): episode = r.group(1)[1:] else: episode = r.group(2) else: episode = u"" yield _lostfilm_updateitem_from_info({ "label" : file_name, "path" : plugin.url_for("torrent_play", url=torrent_url, index=index, name=file_name), "is_playable" : True, "info" : { "title" : file_name, "season" : season, "episode" : episode }, "stream_info" : get_quality_from_name(file_name) }, show_info) _lostfilm_close_dbase() else: plugin.redirect(plugin.url_for("play", uri=torrent_url))