# -*- coding: utf-8 -*- #------------------------------------------------------------ import urlparse,urllib2,urllib,re import os, sys from core import jsontools as json from core import scrapertools from core import servertools from core.item import Item from platformcode import config, logger from core import httptools from core import tmdb host = 'https://www.vporn.com' def mainlist(item): logger.info() itemlist = [] itemlist.append( Item(channel=item.channel, title="Novedades" , action="peliculas", url=host + "/newest/month/")) itemlist.append( Item(channel=item.channel, title="Mas Vistas" , action="peliculas", url=host + "/views/month/")) itemlist.append( Item(channel=item.channel, title="Mejor Valoradas" , action="peliculas", url=host + "/rating/month/")) itemlist.append( Item(channel=item.channel, title="Favoritas" , action="peliculas", url=host + "/favorites/month/")) itemlist.append( Item(channel=item.channel, title="Mas Votada" , action="peliculas", url=host + "/votes/month/")) itemlist.append( Item(channel=item.channel, title="Longitud" , action="peliculas", url=host + "/longest/month/")) itemlist.append( Item(channel=item.channel, title="PornStar" , action="catalogo", url=host + "/pornstars/")) itemlist.append( Item(channel=item.channel, title="Categorias" , action="categorias", url=host)) itemlist.append( Item(channel=item.channel, title="Buscar", action="search")) return itemlist def search(item, texto): logger.info() texto = texto.replace(" ", "+") item.url = host + "/search?q=%s" % texto try: return peliculas(item) except: import sys for line in sys.exc_info(): logger.error("%s" % line) return [] def catalogo(item): logger.info() itemlist = [] data = httptools.downloadpage(item.url).data data = re.sub(r"\n|\r|\t| |
", "", data) patron = '
.*?.*?([^ (\d+) Videos' matches = re.compile(patron,re.DOTALL).findall(data) for scrapedurl,scrapedthumbnail,scrapedtitle,cantidad in matches: scrapedplot = "" scrapedtitle = scrapedtitle + " (" + cantidad + ")" scrapedurl = host + scrapedurl itemlist.append( Item(channel=item.channel, action="peliculas", title=scrapedtitle , url=scrapedurl , thumbnail=scrapedthumbnail , plot=scrapedplot , folder=True) ) next_page_url = scrapertools.find_single_match(data,'([^"]+)' matches = re.compile(patron,re.DOTALL).findall(data) for scrapedurl,scrapedtitle in matches: scrapedplot = "" scrapedthumbnail = "" scrapedurl = host + scrapedurl itemlist.append( Item(channel=item.channel, action="peliculas", title=scrapedtitle , url=scrapedurl , thumbnail=scrapedthumbnail , plot=scrapedplot , folder=True) ) return itemlist def peliculas(item): logger.info() itemlist = [] data = scrapertools.cachePage(item.url) data = re.sub(r"\n|\r|\t| |
", "", data) patron = '
.*?(.*?).*?([^') if next_page_url!="": next_page_url = urlparse.urljoin(item.url,next_page_url) itemlist.append( Item(channel=item.channel , action="peliculas" , title="Next page >>" , text_color="blue", url=next_page_url , folder=True) ) return itemlist def play(item): logger.info() itemlist = [] data = scrapertools.cachePage(item.url) patron = '