KoD 0.5 -riscritti molti canali per cambiamenti nella struttura stessa di kod -altre robe carine
110 lines
4.7 KiB
Python
Executable File
110 lines
4.7 KiB
Python
Executable File
# -*- 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
|
|
|
|
|
|
server = {'1': 'https://www.mangovideo.pw/contents/videos', '7' : 'https://server9.mangovideo.pw/contents/videos/',
|
|
'8' : 'https://s10.mangovideo.pw/contents/videos/', '9' : 'https://server2.mangovideo.pw/contents/videos/',
|
|
'10' : 'https://server217.mangovideo.pw/contents/videos/', '11' : 'https://234.mangovideo.pw/contents/videos/'
|
|
}
|
|
|
|
host = 'http://mangovideo.pw'
|
|
|
|
def mainlist(item):
|
|
logger.info()
|
|
itemlist = []
|
|
itemlist.append( Item(channel=item.channel, title="Nuevos" , action="lista", url=host + "/latest-updates/"))
|
|
itemlist.append( Item(channel=item.channel, title="Mas vistos" , action="lista", url=host + "/most-popular/"))
|
|
itemlist.append( Item(channel=item.channel, title="Mejor valorada" , action="lista", url=host + "/top-rated/"))
|
|
itemlist.append( Item(channel=item.channel, title="Sitios" , action="categorias", url=host + "/sites/"))
|
|
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/%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>|<br/>", "", data)
|
|
patron = '<a class="item" href="([^"]+)" title="([^"]+)".*?'
|
|
patron += '<div class="videos">(\d+) videos</div>'
|
|
matches = re.compile(patron,re.DOTALL).findall(data)
|
|
for scrapedurl,scrapedtitle,cantidad in matches:
|
|
scrapedplot = ""
|
|
scrapedthumbnail = ""
|
|
title = scrapedtitle + " (" + cantidad + ")"
|
|
itemlist.append( Item(channel=item.channel, action="lista", title=title, url=scrapedurl,
|
|
thumbnail=scrapedthumbnail , plot=scrapedplot) )
|
|
|
|
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="categorias", title="Página Siguiente >>", text_color="blue",
|
|
url=next_page) )
|
|
|
|
|
|
return itemlist
|
|
|
|
|
|
def lista(item):
|
|
logger.info()
|
|
itemlist = []
|
|
data = httptools.downloadpage(item.url).data
|
|
data = re.sub(r"\n|\r|\t| |<br>|<br/>", "", data)
|
|
patron = '<div class="item\s+">.*?'
|
|
patron += '<a href="([^"]+)" title="([^"]+)".*?'
|
|
patron += 'data-original="([^"]+)".*?'
|
|
patron += '<div class="duration">([^<]+)</div>'
|
|
matches = re.compile(patron,re.DOTALL).findall(data)
|
|
for scrapedurl,scrapedtitle,scrapedthumbnail,scrapedtime in matches:
|
|
title = "[COLOR yellow]" + scrapedtime + "[/COLOR] " + scrapedtitle
|
|
thumbnail = scrapedthumbnail
|
|
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, '<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):
|
|
itemlist = []
|
|
data = httptools.downloadpage(item.url).data
|
|
data = re.sub(r"\n|\r|\t|amp;|\s{2}| ", "", data)
|
|
scrapedtitle = ""
|
|
patron = 'video_url: \'function/0/https://mangovideo.pw/get_file/(\d+)/\w+/(.*?)/\''
|
|
matches = scrapertools.find_multiple_matches(data, patron)
|
|
for scrapedtitle,url in matches:
|
|
scrapedtitle = server.get(scrapedtitle, scrapedtitle)
|
|
url = scrapedtitle + url
|
|
if not scrapedtitle:
|
|
url = scrapertools.find_single_match(data, '<div class="embed-wrap".*?<iframe src="([^"]+)\?ref=')
|
|
itemlist.append(item.clone(action="play", title="%s", url=url))
|
|
itemlist = servertools.get_servers_itemlist(itemlist, lambda i: i.title % i.server.capitalize())
|
|
|
|
return itemlist
|
|
|