# -*- coding: utf-8 -*- #------------------------------------------------------------ import re import urlparse from core import httptools from core import scrapertools from core.item import Item from platformcode import logger from platformcode import config host = 'https://www.vporn.com' def mainlist(item): logger.info() itemlist = [] itemlist.append( Item(channel=item.channel, title="Novedades" , action="lista", url=host + "/newest/month/")) itemlist.append( Item(channel=item.channel, title="Mas Vistas" , action="lista", url=host + "/views/month/")) itemlist.append( Item(channel=item.channel, title="Mejor Valoradas" , action="lista", url=host + "/rating/month/")) itemlist.append( Item(channel=item.channel, title="Favoritas" , action="lista", url=host + "/favorites/month/")) itemlist.append( Item(channel=item.channel, title="Mas Votada" , action="lista", url=host + "/votes/month/")) itemlist.append( Item(channel=item.channel, title="Longitud" , action="lista", 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 lista(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 = '
.*?' patron += '.*?' patron += '([^') if next_page!="": next_page = urlparse.urljoin(item.url,next_page) itemlist.append(item.clone(action="catalogo", title="Next page >>", text_color="blue", url=next_page) ) return itemlist def categorias(item): logger.info() itemlist = [] data = httptools.downloadpage(item.url).data data = re.sub(r"\n|\r|\t| |
", "", data) data = scrapertools.find_single_match(data,'
(.*?)
') patron = '
([^"]+)' 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="lista", title=scrapedtitle, url=scrapedurl, thumbnail=scrapedthumbnail, plot=scrapedplot) ) return itemlist def lista(item): logger.info() itemlist = [] data = httptools.downloadpage(item.url).data data = re.sub(r"\n|\r|\t| |
", "", data) patron = '
.*?' patron += '') if next_page!="": next_page = urlparse.urljoin(item.url,next_page) itemlist.append(item.clone(action="lista", title="Next page >>", text_color="blue", url=next_page) ) return itemlist def play(item): logger.info() itemlist = [] data = httptools.downloadpage(item.url).data patron = '