98 lines
4.1 KiB
Python
98 lines
4.1 KiB
Python
# -*- 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://fapality.com'
|
|
|
|
|
|
def mainlist(item):
|
|
logger.info()
|
|
itemlist = []
|
|
itemlist.append( Item(channel=item.channel, title="Nuevas" , action="lista", url=host + "/newest/"))
|
|
itemlist.append( Item(channel=item.channel, title="Mas Vistas" , action="lista", url=host + "/popular/"))
|
|
itemlist.append( Item(channel=item.channel, title="Mejor valorada" , action="lista", url=host + "/top/"))
|
|
itemlist.append( Item(channel=item.channel, title="Canal" , action="categorias", url=host + "/channels/"))
|
|
itemlist.append( Item(channel=item.channel, title="PornStar" , action="categorias", url=host + "/pornstars/"))
|
|
itemlist.append( Item(channel=item.channel, title="Categorias" , action="categorias", url=host + "/categories/"))
|
|
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 categorias(item):
|
|
logger.info()
|
|
itemlist = []
|
|
data = httptools.downloadpage(item.url).data
|
|
data = re.sub(r"\n|\r|\t| |<br>", "", data)
|
|
patron = '<div class="item"><a href="([^"]+)" title="([^"]+)">.*?'
|
|
patron += '<img src="([^"]+)">.*?'
|
|
patron += '<div class="right">([^"]+)</div>'
|
|
matches = re.compile(patron,re.DOTALL).findall(data)
|
|
for scrapedurl,scrapedtitle,scrapedthumbnail,cantidad in matches:
|
|
scrapedplot = ""
|
|
scrapedtitle = scrapedtitle.replace("movies", "") + " (" + cantidad + ")"
|
|
scrapedurl = urlparse.urljoin(item.url,scrapedurl)
|
|
itemlist.append( Item(channel=item.channel, action="lista", title=scrapedtitle, url=scrapedurl,
|
|
fanart=scrapedthumbnail, thumbnail=scrapedthumbnail, plot=scrapedplot) )
|
|
next_page_url = scrapertools.find_single_match(data,'<li itemprop="url" class="current">.*?<a href="([^"]+)"')
|
|
if next_page_url!="":
|
|
next_page_url = urlparse.urljoin(item.url,next_page_url)
|
|
itemlist.append(item.clone(action="categorias", title="Página Siguiente >>", text_color="blue", url=next_page_url) )
|
|
if "/categories/" in item.url:
|
|
itemlist = sorted(itemlist, key=lambda i: i.title)
|
|
return itemlist
|
|
|
|
|
|
def lista(item):
|
|
logger.info()
|
|
itemlist = []
|
|
data = httptools.downloadpage(item.url).data
|
|
data = re.sub(r"\n|\r|\t| |<br>", "", data)
|
|
patron = '<li class="masonry-item item ".*?'
|
|
patron += '<a href="([^"]+)" class="kt_imgrc popfire" title="([^"]+)" >.*?'
|
|
patron += '<img src="([^"]+)"'
|
|
matches = re.compile(patron,re.DOTALL).findall(data)
|
|
for scrapedurl,scrapedtitle,scrapedthumbnail in matches:
|
|
title = scrapedtitle
|
|
contentTitle = title
|
|
thumbnail = scrapedthumbnail
|
|
plot = ""
|
|
itemlist.append( Item(channel=item.channel, action="play", title=title, url=scrapedurl, thumbnail=thumbnail,
|
|
fanart=thumbnail, plot=plot, contentTitle = contentTitle) )
|
|
next_page_url = scrapertools.find_single_match(data,'<li itemprop="url" class="current">.*?<a href="([^"]+)"')
|
|
if next_page_url!="":
|
|
next_page_url = urlparse.urljoin(item.url,next_page_url)
|
|
itemlist.append(item.clone(action="lista", title="Página Siguiente >>", text_color="blue", url=next_page_url) )
|
|
return itemlist
|
|
|
|
|
|
def play(item):
|
|
logger.info()
|
|
itemlist = []
|
|
data = httptools.downloadpage(item.url).data
|
|
patron = '<source id="video_source_1" src="([^"]+)"'
|
|
matches = re.compile(patron,re.DOTALL).findall(data)
|
|
for scrapedurl in matches:
|
|
url = scrapedurl
|
|
itemlist.append(item.clone(action="play", title=url, contentTitle = item.title, url=url))
|
|
return itemlist
|
|
|