# -*- coding: utf-8 -*- #------------------------------------------------------------ import urlparse,urllib2,urllib,re import os, sys from platformcode import config, logger from core import scrapertools from core.item import Item from core import servertools from core import httptools host = 'https://www.xvideos.com' def mainlist(item): logger.info() itemlist = [] itemlist.append( Item(channel=item.channel, title="Nuevos" , action="lista", url=host)) itemlist.append( Item(channel=item.channel, title="Lo mejor" , action="lista", url=host + "/best/")) itemlist.append( Item(channel=item.channel, title="Pornstar" , action="catalogo", url=host + "/pornstars-index")) itemlist.append( Item(channel=item.channel, title="WebCAM" , action="catalogo", url=host + "/webcam-models-index")) itemlist.append( Item(channel=item.channel, title="Canal" , action="catalogo", url=host + "/channels-index/top")) itemlist.append( Item(channel=item.channel, title="Categorias" , action="categorias", url=host + "/tags")) itemlist.append( Item(channel=item.channel, title="Buscar", action="search")) return itemlist def search(item, texto): logger.info() texto = texto.replace(" ", "+") item.url = host + "/?k=%s" % texto try: return lista(item) except: import sys for line in sys.exc_info(): logger.error("%s" % line) return [] def categorias(item): logger.info() itemlist = [] data = httptools.downloadpage(item.url).data data = re.sub(r"\n|\r|\t| |
|
", "", data) patron = '
  • ([^<]+)([^<]+)' matches = re.compile(patron,re.DOTALL).findall(data) for scrapedurl,scrapedtitle,cantidad in matches: scrapedplot = "" scrapedthumbnail = "" scrapedurl = urlparse.urljoin(item.url,scrapedurl) title = scrapedtitle + " (" + cantidad + ")" itemlist.append( Item(channel=item.channel, action="lista", title=title, url=scrapedurl, thumbnail=scrapedthumbnail , plot=scrapedplot) ) return itemlist def catalogo(item): logger.info() itemlist = [] data = httptools.downloadpage(item.url).data data = re.sub(r"\n|\r|\t| |
    |
    ", "", data) patron = '
    Siguiente') if next_page=="": next_page = scrapertools.find_single_match(data, '
  • |
    ", "", data) patron = '
    ([^<]+)') if quality: title = "[COLOR yellow]" + scrapedtime + "[/COLOR] " + "[COLOR red]" + quality + "[/COLOR] " + scrapedtitle plot = "" itemlist.append( Item(channel=item.channel, action="play", title=title, url=scrapedurl, thumbnail=thumbnail, fanart=thumbnail, plot=plot, contentTitle = scrapedtitle)) next_page = scrapertools.find_single_match(data, '
  • Siguiente') if "profile" in item.url: next_page = scrapertools.find_single_match(data, '
  • (\d+)
  • ", "", data) url = scrapertools.find_single_match(data, 'html5player.setVideoHLS\(\'([^\']+)\'\)') itemlist.append(item.clone(action="play", title=url, url=url )) return itemlist