# -*- coding: iso-8859-1 -*-
#------------------------------------------------------------
# pelisalacarta - XBMC Plugin
# Canal para newcineonline
#
http://blog.tvalacarta.info/plugin-xbmc/pelisalacarta/
#------------------------------------------------------------
import urlparse,urllib2,urllib,re
import os
import sys
import xbmc
import xbmcgui
import xbmcplugin
import scrapertools
import megavideo
import servertools
import binascii
import xbmctools
CHANNELNAME = "newcineonline"
# Esto permite su ejecución en modo emulado
try:
pluginhandle = int( sys.argv[ 1 ] )
except:
pluginhandle = ""
xbmc.output("[newcineonline.py] init")
DEBUG = True
def mainlist(params,url,category):
xbmc.output("[newcineonline.py] mainlist")
# Añade al listado de XBMC
addfolder("Akcja", "
http://www.ifilmy.net/film.php?cat_id=34" ,"list")
addfolder("Animacja", "
http://www.ifilmy.net/film.php?cat_id=5" ,"list")
# Label (top-right)...
xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=category )
# Disable sorting...
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
# End of directory...
xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def list(params,url,category):
data = scrapertools.cachePage(url)
# Extrae las entradas (carpetas)
patronvideos = "<a title='([^']+)' href='([^']+)'><img alt='([^']+)' src='([^']+)'"
# Descarga la página
matches = re.compile(patronvideos,re.DOTALL).findall(data)
scrapertools.printMatches(matches)
for match in matches:
# Titulo
scrapedtitle = match[0]
# URL
scrapedurl = urlparse.urljoin(url,match[1])
# Thumbnail
scrapedthumbnail = match[3]
# procesa el resto
scrapeddescription = ""
# Depuracion
if (DEBUG):
xbmc.output("scrapedtitle="+scrapedtitle)
xbmc.output("scrapedurl="+scrapedurl)
xbmc.output("scrapedthumbnail="+scrapedthumbnail)
# Añade al listado de XBMC
addfolder( scrapedtitle , scrapedurl , "detail" )
#xbmctools.addnewfolder( CHANNELNAME , "detail" , CHANNELNAME , scrapedtitle , scrapedurl , scrapedthumbnail , scrapeddescription )
# ------------------------------------------------------------------------------------
# Busca los enlaces a los mirrors, o a los capítulos de las series...
# ------------------------------------------------------------------------------------
# Label (top-right)...
xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=category )
# Disable sorting...
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
# End of directory...
xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
# Descarga la página
data = scrapertools.cachePage(url)
#xbmc.output(data)
patronvideos = "<a href='(film.php?[^']+)'>([^<]+)</a>"
matches = re.compile(patronvideos,re.DOTALL).findall(data)
scrapertools.printMatches(matches)
for match in matches:
addfolder( "strona "+match[1] , "
http://www.ifilmy.net/"+match[0] , "list")
# Label (top-right)...
xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=category )
# Disable sorting...
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
# End of directory...
xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def detail(params,url,category):
xbmc.output("[newcineonline.py] detail")
# Label (top-right)...
xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=category )
# Disable sorting...
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
# End of directory...
xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
# La siguiente página
patronvideos = '<embed src\="([^"]+)"'
matches = re.compile(patronvideos,re.DOTALL).findall(data)
scrapertools.printMatches(matches)
if len(matches)>0:
addvideo( "Ver vídeo" , matches[0] , category , "Megavideo" )
# ------------------------------------------------------------------------------------
# Busca los enlaces a los mirrors, o a los capítulos de las series...
# ------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------
# Busca los enlaces a los videos
# ------------------------------------------------------------------------------------
listavideos = servertools.findvideos(data)
for video in listavideos:
addvideo( video[0] , video[1] , category , video[2] )
# ------------------------------------------------------------------------------------
# Label (top-right)...
xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=category )
# Disable sorting...
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
# End of directory...
xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def play(params,url,category):
xbmc.output("[newcineonline.py] play")
title = unicode( xbmc.getInfoLabel( "ListItem.Title" ), "utf-8" )
thumbnail = xbmc.getInfoImage( "ListItem.Thumb" )
plot = unicode( xbmc.getInfoLabel( "ListItem.Plot" ), "utf-8" )
server = params["server"]
xbmc.output("[newcineonline.py] thumbnail="+thumbnail)
xbmc.output("[newcineonline.py] server="+server)
xbmctools.playvideo(CHANNELNAME,server,url,category,title,thumbnail,plot)
def addfolder(nombre,url,accion):
xbmc.output('[newcineonline.py] addfolder( "'+nombre+'" , "' + url + '" , "'+accion+'")"')
listitem = xbmcgui.ListItem( nombre , iconImage="DefaultFolder.png")
itemurl = '%s?channel=newcineonline&action=%s&category=%s&url=%s' % ( sys.argv[ 0 ] , accion , urllib.quote_plus(nombre) , urllib.quote_plus(url) )
xbmcplugin.addDirectoryItem( handle = int(sys.argv[ 1 ]), url = itemurl , listitem=listitem, isFolder=True)
def addvideo(nombre,url,category,server):
xbmc.output('[newcineonline.py] addvideo( "'+nombre+'" , "' + url + '" , "'+server+'")"')
listitem = xbmcgui.ListItem( nombre, iconImage="DefaultVideo.png" )
listitem.setInfo( "video", { "Title" : nombre, "Plot" : nombre } )
itemurl = '%s?channel=newcineonline&action=play&category=%s&url=%s&server=%s' % ( sys.argv[ 0 ] , category , urllib.quote_plus(url) , server )
xbmcplugin.addDirectoryItem( handle=int(sys.argv[ 1 ]), url=itemurl, listitem=listitem, isFolder=False)
def addthumbnailfolder( scrapedtitle , scrapedurl , scrapedthumbnail , accion ):
xbmc.output('[newcineonline.py] addthumbnailfolder( "'+scrapedtitle+'" , "' + scrapedurl + '" , "'+scrapedthumbnail+'" , "'+accion+'")"')
listitem = xbmcgui.ListItem( scrapedtitle, iconImage="DefaultFolder.png", thumbnailImage=scrapedthumbnail )
itemurl = '%s?channel=newcineonline&action=%s&category=%s&url=%s' % ( sys.argv[ 0 ] , accion , urllib.quote_plus( scrapedtitle ) , urllib.quote_plus( scrapedurl ) )
xbmcplugin.addDirectoryItem( handle = int(sys.argv[ 1 ]), url = itemurl , listitem=listitem, isFolder=True)