KoD 0.5 -riscritti molti canali per cambiamenti nella struttura stessa di kod -altre robe carine
114 lines
4.6 KiB
Python
114 lines
4.6 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://www.analdin.com/es'
|
|
|
|
|
|
def mainlist(item):
|
|
logger.info()
|
|
itemlist = []
|
|
itemlist.append( Item(channel=item.channel, title="Nuevas" , action="lista", url=host + "/más-reciente/"))
|
|
itemlist.append( Item(channel=item.channel, title="Mas Vistas" , action="lista", url=host + "/más-visto/"))
|
|
itemlist.append( Item(channel=item.channel, title="Mejor valorada" , action="lista", url=host + "/mejor-valorado/"))
|
|
itemlist.append( Item(channel=item.channel, title="Canal" , action="catalogo", url=host))
|
|
itemlist.append( Item(channel=item.channel, title="Categorias" , action="categorias", url=host + "/categorías/"))
|
|
itemlist.append( Item(channel=item.channel, title="Buscar", action="search"))
|
|
return itemlist
|
|
|
|
|
|
def search(item, texto):
|
|
logger.info()
|
|
texto = texto.replace(" ", "+")
|
|
item.url = host + "/?s=%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 = scrapertools.find_single_match(data,'<strong class="popup-title">Canales</strong>(.*?)<strong>Models</strong>')
|
|
data = re.sub(r"\n|\r|\t| |<br>", "", data)
|
|
patron = '<li><a class="item" href="([^"]+)" title="([^"]+)">'
|
|
matches = re.compile(patron,re.DOTALL).findall(data)
|
|
for scrapedurl,scrapedtitle in matches:
|
|
scrapedplot = ""
|
|
scrapedthumbnail = ""
|
|
itemlist.append( Item(channel=item.channel, action="lista", title=scrapedtitle, url=scrapedurl,
|
|
thumbnail=scrapedthumbnail, plot=scrapedplot) )
|
|
next_page = scrapertools.find_single_match(data,'<li class="arrow"><a rel="next" href="([^"]+)">»</a>')
|
|
if next_page!="":
|
|
next_page = urlparse.urljoin(item.url,next_page)
|
|
itemlist.append(item.clone(action="catalogo", title="Página Siguiente >>", 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| |<br>", "", data)
|
|
patron = '<a class="item" href="([^"]+)" title="([^"]+)">.*?'
|
|
patron += 'src="([^"]+)".*?'
|
|
patron += '<div class="videos">([^"]+)</div>'
|
|
matches = re.compile(patron,re.DOTALL).findall(data)
|
|
for scrapedurl,scrapedtitle,scrapedthumbnail,cantidad in matches:
|
|
scrapedplot = ""
|
|
scrapedtitle = scrapedtitle + " (" + 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) )
|
|
return sorted(itemlist, key=lambda i: i.title)
|
|
|
|
|
|
def lista(item):
|
|
logger.info()
|
|
itemlist = []
|
|
data = httptools.downloadpage(item.url).data
|
|
data = re.sub(r"\n|\r|\t| |<br>", "", data)
|
|
patron = '<a class="popup-video-link" href="([^"]+)".*?'
|
|
patron += 'thumb="([^"]+)".*?'
|
|
patron += '<div class="duration">(.*?)</div>.*?'
|
|
patron += '<strong class="title">\s*([^"]+)</strong>'
|
|
matches = re.compile(patron,re.DOTALL).findall(data)
|
|
for scrapedurl,scrapedthumbnail,scrapedtime,scrapedtitle in matches:
|
|
url = urlparse.urljoin(item.url,scrapedurl)
|
|
title = "[COLOR yellow]" + scrapedtime + "[/COLOR] " + scrapedtitle
|
|
thumbnail = scrapedthumbnail
|
|
plot = ""
|
|
itemlist.append( Item(channel=item.channel, action="play", title=title, url=url, thumbnail=thumbnail, plot=plot,
|
|
fanart=thumbnail, contentTitle = title))
|
|
next_page = scrapertools.find_single_match(data,'<li class="next"><a href="([^"]+)"')
|
|
if next_page!="":
|
|
next_page = urlparse.urljoin(item.url,next_page)
|
|
itemlist.append( Item(channel=item.channel, action="lista", title="Página Siguiente >>", text_color="blue",
|
|
url=next_page) )
|
|
return itemlist
|
|
|
|
|
|
def play(item):
|
|
logger.info()
|
|
itemlist = []
|
|
data = httptools.downloadpage(item.url).data
|
|
patron = 'video_url: \'([^\']+)\''
|
|
matches = re.compile(patron,re.DOTALL).findall(data)
|
|
for scrapedurl in matches:
|
|
url = scrapedurl
|
|
itemlist.append(item.clone(action="play", title=url, url=url))
|
|
return itemlist
|
|
|