# -*- coding: utf-8 -*- import math import os import re import unicodedata import urllib from core import httptools from core import scrapertools from core import tmdb from core.item import Item from core.scrapertools import decodeHtmlentities as dhe from platformcode import config, logger from channelselector import get_thumb 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]Películas[/B][/COLOR]", action="peliculas", url="http://www.miltorrents.com", thumbnail=get_thumb('movies', auto=True), fanart="http://imgur.com/y4nJyZh.jpg")) title = "[COLOR firebrick][B]Buscar[/B][/COLOR]" + " " + "[COLOR yellow][B]Peliculas[/B][/COLOR]" itemlist.append(Item(channel=item.channel, title=" " + title, action="search", url="", thumbnail=get_thumb('search', auto=True), fanart="http://imgur.com/gwjawWV.jpg", extra="peliculas" + "|" + check_bg)) itemlist.append(Item(channel=item.channel, title="[COLOR slategray][B]Series[/B][/COLOR]", action="peliculas", url="http://www.miltorrents.com/series", thumbnail=get_thumb('tvshows', auto=True), fanart="http://imgur.com/LwS32zX.jpg")) title = "[COLOR firebrick][B]Buscar[/B][/COLOR]" + " " + "[COLOR slategray][B]Series[/B][/COLOR]" itemlist.append(Item(channel=item.channel, title=" " + title, action="search", url="", thumbnail=get_thumb('search', auto=True), fanart="http://imgur.com/ecPmzDj.jpg", extra="series" + "|" + check_bg)) return itemlist def search(item, texto): logger.info() texto = texto.replace(" ", "+") if item.extra: if item.extra.split("|")[0] == "series": item.url = "http://www.miltorrents.com/series/?pTit=%s&pOrd=FE" % (texto) else: item.url = "http://www.miltorrents.com/?pTit=%s&pOrd=FE" % (texto) item.extra = "search" + "|" + item.extra.split("|")[1] + "|" + texto 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) return [] else: if item.contentType != "movie": item.url = "http://www.miltorrents.com/series/?pTit=%s&pOrd=FE" % (texto) check_sp = "tvshow" else: item.url = "http://www.miltorrents.com/?pTit=%s&pOrd=FE" % (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) return [] def peliculas(item): logger.info() itemlist = [] data = httptools.downloadpage(item.url).data data = re.sub(r"Independance", "Independence", data) if "serie" in item.url: patron = '
(.*?)<\/div>.*?(.*?)([^<]+)\((\d\d\d\d)\)' matches = re.compile(patron, re.DOTALL).findall(data) for p_rating, url, thumbnail, title, year in matches: try: rating = scrapertools.get_match(p_rating, '
(.*?)= 5 and int(check_rating) < 8: rating = "[COLOR springgreen][B]" + rating + "[/B][/COLOR]" elif int(check_rating) >= 8 and int(check_rating) < 10: rating = "[COLOR yellow][B]" + rating + "[/B][/COLOR]" elif int(check_rating) == 10: rating = "[COLOR orangered][B]" + rating + "[/B][/COLOR]" else: rating = "[COLOR crimson][B]" + rating + "[/B][/COLOR]" except: rating = "[COLOR crimson][B]" + rating + "[/B][/COLOR]" if "10." in rating: rating = re.sub(r'10\.\d+', '10', rating) title_f = "[COLOR gold][B]" + title + "[/B][/COLOR]" + " " + rating trailer = title_fan + " " + "trailer" trailer = urllib.quote(trailer) extra = trailer + "|" + title_fan + "|" + year + "|" + "pelicula" itemlist.append(Item(channel=item.channel, title=title_f, url=url, action="findvideos", thumbnail=thumbnail, fanart="http://imgur.com/Oi1mlFn.jpg", extra=extra, folder=True, contentTitle= title, infoLabels={'year':year})) tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) ## Paginación patronvideos = '