# -*- coding: utf-8 -*- import os import re import unicodedata import urllib import xbmc import xbmcgui from core import httptools from core import scrapertools from core.item import Item from core.scrapertools import decodeHtmlentities as dhe from platformcode import config, logger from platformcode import platformtools ACTION_SHOW_FULLSCREEN = 36 ACTION_GESTURE_SWIPE_LEFT = 511 ACTION_SELECT_ITEM = 7 ACTION_PREVIOUS_MENU = 10 ACTION_MOVE_LEFT = 1 ACTION_MOVE_RIGHT = 2 ACTION_MOVE_DOWN = 4 ACTION_MOVE_UP = 3 OPTION_PANEL = 6 OPTIONS_OK = 5 krypton = False # Proxy para acceder a datos(Este canal usa cloudflare con https) def get_page(url): logger.info() global krypton xbmc_version = xbmc.getInfoLabel("System.BuildVersion") check_xbmc_version = scrapertools.get_match(xbmc_version, '(\d+).') if check_xbmc_version >= 17: krypton = True data = httptools.downloadpage(url).data else: data = httptools.downloadpage("http://ssl-proxy.my-addr.org/myaddrproxy.php/" + url).data return data # Para la busqueda en bing evitando baneos def browser(url): import mechanize # Utilizamos Browser mechanize para saltar problemas con la busqueda en bing br = mechanize.Browser() # Browser options br.set_handle_equiv(False) br.set_handle_gzip(True) br.set_handle_redirect(True) br.set_handle_referer(False) br.set_handle_robots(False) # Follows refresh 0 but not hangs on refresh > 0 br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1) # Want debugging messages? # br.set_debug_http(True) # br.set_debug_redirects(True) # br.set_debug_responses(True) # User-Agent (this is cheating, ok?) br.addheaders = [('User-agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.7.12 (KHTML, like Gecko) Version/7.1.7 Safari/537.85.16')] # br.addheaders =[('Cookie','SRCHD=AF=QBRE; domain=.bing.com; expires=25 de febrero de 2018 13:00:28 GMT+1; MUIDB=3B942052D204686335322894D3086911; domain=www.bing.com;expires=24 de febrero de 2018 13:00:28 GMT+1')] # Open some site, let's pick a random one, the first that pops in mind r = br.open(url) response = r.read() print response if "img,divreturn" in response: r = br.open("http://ssl-proxy.my-addr.org/myaddrproxy.php/" + url) print "prooooxy" response = r.read() return response api_key = "2e2160006592024ba87ccdf78c28f49f" api_fankey = "dffe90fba4d02c199ae7a9e71330c987" def mainlist(item): logger.info() check_bg = item.action if str(check_bg) == "": check_bg = "bglobal" itemlist = [] itemlist.append(Item(channel=item.channel, title="[COLOR yellow][B]Peliculas[/B][/COLOR]", action="peliculas", url="http://pasateatorrent.com/", thumbnail="https://s6.postimg.org/j9amymu1d/dxtorrentpelo.png", fanart="http://imgur.com/uexmGEg.png")) itemlist.append(Item(channel=item.channel, title="[COLOR skyblue][B]Series[/B][/COLOR]", action="peliculas", url="http://pasateatorrent.com//series/", thumbnail="https://s6.postimg.org/6vxsrq4cx/dxtorrentselo.png", fanart="http://imgur.com/vQTyY6r.png")) itemlist.append(Item(channel=item.channel, title="[COLOR green][B]Buscar[/B][/COLOR]", action="", url="", thumbnail="https://s6.postimg.org/hy2vq5yfl/dxtorrentbpelo.png", fanart="http://imgur.com/P9jol7f.png")) itemlist.append( Item(channel=item.channel, title=" " + "[COLOR yellow]Peliculas[/COLOR]", action="search", url="", thumbnail="https://s6.postimg.org/79z4rbogh/dxtorrentpbselo.png", fanart="http://imgur.com/W7iwPvD.png", extra="peliculas" + "|" + check_bg)) itemlist.append( Item(channel=item.channel, title=" " + "[COLOR skyblue]Series[/COLOR]", action="search", url="", thumbnail="https://s6.postimg.org/hy2vq5yfl/dxtorrentbpelo.png", fanart="http://imgur.com/BD86Wdn.png", extra="series" + "|" + check_bg)) return itemlist def search(item, texto): logger.info() texto = texto.replace(" ", "+") check_bg = item.action if item.extra: if item.extra.split("|")[0] == "series": item.url = "http://pasateatorrent.com/series/?s=%s&post_type=Buscar+serie" % (texto) check_sp = "tvshow" else: item.url = "http://pasateatorrent.com/?s=%s&post_type=Buscar+película" % (texto) check_sp = "peliculas" item.extra = "search" + "|" + item.extra.split("|")[1] + "|" + texto + "|" + check_sp try: return peliculas(item) # Se captura la excepciÛn, para no interrumpir al buscador global si un canal falla except: import sys for line in sys.exc_info(): logger.error("%s" % line) else: if item.contentType != "movie": item.url = "http://pasateatorrent.com/series/?s=%s&post_type=Buscar+serie" % (texto) check_sp = "tvshow" else: item.url = "http://pasateatorrent.com/?s=%s&post_type=Buscar+película" % (texto) check_sp = "peliculas" item.extra = "search" + "|" + "bglobal" + "|" + texto + "|" + check_sp try: return peliculas(item) # Se captura la excepciÛn, para no interrumpir al buscador global si un canal falla except: import sys for line in sys.exc_info(): logger.error("%s" % line) def peliculas(item): logger.info() itemlist = [] global krypton check_url = "" # Descarga la página data = get_page(item.url) # data =re.sub("-"," ",data) if "serie" in item.url: data = re.sub(r"&#.*?;", "x", data) if item.extra.split("|")[0] == "search": check_bg = item.action bloque_enlaces = scrapertools.find_single_match(data, '
(.*?)
<\/center>') bloque_enlaces = bloque_enlaces.strip() if item.extra.split("|")[1] != "bglobal" and check_bg != "info": if str(bloque_enlaces) == "
": if item.extra.split("|")[3] == "peliculas": dialog = xbmcgui.Dialog() if dialog.yesno( '[COLOR crimson][B]Sin resultados en[/B][/COLOR]' + '[COLOR gold][B] Pasate[/B][/COLOR]' + '[COLOR floralwhite][B]A[/B][/COLOR]' + '[COLOR yellow][B]Torrent[/B][/COLOR]', '[COLOR cadetblue]¿Quieres hacer una busqueda en Alfa?[/COLOR]', '', "", '[COLOR crimson][B]No,gracias[/B][/COLOR]', '[COLOR yellow][B]Si[/B][/COLOR]'): item.extra = "movie" + "|" + item.extra.split("|")[2] return busqueda(item) else: xbmc.executebuiltin('Action(Back)') xbmc.sleep(500) else: dialog = xbmcgui.Dialog() if dialog.yesno( '[COLOR crimson][B]Sin resultados en[/B][/COLOR]' + '[COLOR slateblue][B] Pasate[/B][/COLOR]' + '[COLOR floralwhite][B]A[/B][/COLOR]' + '[COLOR slateblue][B]Torrent[/B][/COLOR]', '[COLOR cadetblue]¿Quieres hacer una busqueda en Alfa?[/COLOR]', '', "", '[COLOR crimson][B]No,gracias[/B][/COLOR]', '[COLOR yellow][B]Si[/B][/COLOR]'): item.extra = "serie" + "|" + item.extra.split("|")[2] return busqueda(item) else: xbmc.executebuiltin('Action(Back)') xbmc.sleep(500) else: bloque_enlaces = scrapertools.find_single_match(data, '
(.*?)