def listageneros(params,url,category):
	xbmc.output("[meristation.py] listaporgenero")
	
	# --------------------------------------------------------
	# Descarga la página
	# --------------------------------------------------------
	data = scrapertools.cachePage(url)
	#xbmc.output(data)

	# --------------------------------------------------------
	# Extrae las categorias (carpetas)
	# --------------------------------------------------------
	patron = '<option  value="([^"]+)">([^<]+)</option>'
	matches = re.compile(patron,re.DOTALL).findall(data)
	if DEBUG: scrapertools.printMatches(matches)

	for match in matches:
		scrapedtitle = match[1].replace("&nbsp;","").strip()
		scrapedurl = urlparse.urljoin(url,match[0])
		scrapedthumbnail = ""
		scrapedplot = ""
		if (DEBUG): xbmc.output("title=["+scrapedtitle+"], url=["+scrapedurl+"], thumbnail=["+scrapedthumbnail+"]")

		# Añade al listado de XBMC
		#addvideo( scrapedtitle , scrapedurl , category )
		xbmctools.addnewfolder( CHANNELCODE , "letraresults" , CHANNELNAME , scrapedtitle , scrapedurl , scrapedthumbnail, scrapedplot )

	# Label (top-right)...
	xbmcplugin.setPluginCategory( handle=pluginhandle, category=category )

	# Disable sorting...
	xbmcplugin.addSortMethod( handle=pluginhandle, sortMethod=xbmcplugin.SORT_METHOD_NONE )

	# End of directory...
	xbmcplugin.endOfDirectory( handle=pluginhandle, succeeded=True )
Example #2
0
def error(texto):
    try:
        xbmc.output(texto)
    except:
        validchars = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!#$%&'()-@[]^_`{}~."
        stripped = ''.join(c for c in texto if c in validchars)
        xbmc.output("(stripped) " + stripped)
Example #3
0
def categorias(params, url, category):
    xbmc.output("[goear.py] listcategorias")

    # Descarga la página
    data = scrapertools.cachePage(url)
    #xbmc.output(data)

    # Extrae las entradas (carpetas)
    patronvideos = '<div class="cate-tipos"><a href="([^"]+)">([^<]+)</a></div>'
    matches = re.compile(patronvideos, re.DOTALL).findall(data)
    scrapertools.printMatches(matches)

    for match in matches:
        scrapedtitle = match[1]
        scrapedurl = urlparse.urljoin(url, match[0])
        if (DEBUG):
            xbmc.output("title=[" + scrapedtitle + "], url=[" + scrapedurl +
                        "]")

        # Añade al listado de XBMC
        addnewfolder("categoryresults", scrapedtitle, scrapedurl)

    patronvideos = '<div class="flechas" style="float:right;"><a href="([^"]+)"><strong>Siguiente  »</strong></a></div></div>'

    # Cierra el directorio
    xbmcplugin.setPluginCategory(handle=int(sys.argv[1]), category=category)
    xbmcplugin.addSortMethod(handle=int(sys.argv[1]),
                             sortMethod=xbmcplugin.SORT_METHOD_NONE)
    xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=True)
Example #4
0
def mainlist(params, url, category):
    xbmc.output("[favoritos.py] mainlist")

    # Crea un listado con las entradas de favoritos
    ficheros = os.listdir(BOOKMARK_PATH)
    for fichero in ficheros:

        try:
            # Lee el bookmark
            titulo, thumbnail, plot, server, url = readbookmark(fichero)

            # Crea la entrada
            # En la categoría va el nombre del fichero para poder borrarlo
            xbmctools.addnewvideo(CHANNELNAME, "play",
                                  os.path.join(BOOKMARK_PATH, fichero), server,
                                  titulo, url, thumbnail, plot)
        except:
            pass

    # 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)
Example #5
0
def play(params,url,category):
	xbmc.output("[totlolchannel.py] play")

	title = urllib.unquote_plus( params.get("title") )
	thumbnail = urllib.unquote_plus( params.get("thumbnail") )
	plot = urllib.unquote_plus( params.get("plot") )
	server = urllib.unquote_plus( params.get("server") )

	# Abre dialogo
	dialogWait = xbmcgui.DialogProgress()
	dialogWait.create( xbmc.getLocalizedString( 30702 ), title , plot )

	# Busca el id del vídeo
	# La URL tiene el id de vídeo de youtube: http://www.totlol.com/watch/Bxu3jfqpItE/Pocoyo-Dance/0/
	patron = 'http\:\/\/www.totlol.com\/watch\/([^\/]+)/'
	matches = re.compile(patron,re.DOTALL).findall(url)
	scrapertools.printMatches(matches)

	if len(matches)>0:
		video_id = matches[0]
		url = youtube.geturl(video_id)
		listitem = xbmcgui.ListItem( title, iconImage="DefaultVideo.png", thumbnailImage=thumbnail )
		listitem.setInfo( "video", { "Title": title, "Plot": plot } )

	# Cierra dialogo
	dialogWait.close()
	del dialogWait

	# Play video with the proper core
	xbmc.Player().play( url, listitem )
Example #6
0
def log(msg):
	loglevel = 1
	try:
		if (loglevel == 1):
		    xbmc.output("[%s]: %s\n" % ("MAV",msg))
	except:
		pass
def download_subtitles (url):

    tmp_sub_dir= SUB_PATH #Carpeta temporal
    fullpath = os.path.join( config.get_data_path(), 'subtitulo.srt' )
    if os.path.exists(fullpath):   #Borro subtitulo anterior
        try:
          os.remove(fullpath)
        except IOError:
          xbmc.output("Error al eliminar el archivo subtitulo.srt "+fullpath)
          raise	
    for root, dirs, files in os.walk(tmp_sub_dir): #Borro archivos de la carpeta temporal
        for f in files:
            f = unicode(f,'utf8')
            os.unlink(os.path.join(root, f)) 
        for d in dirs:
            from shutil import rmtree						
            shutil.rmtree(os.path.join(root, d))
    #Mensaje de información
    mensaje = xbmcgui.DialogProgress()
    linea1 = 'Extrayendo archivo de subtítulos...'
    linea2 = 'Seleccione uno de la lista'
    linea3 = 'que aparecerá a continuación'
    mensaje.create(linea1 , linea2 , linea3)
    time.sleep(3)
    mensaje.close()	
    try:
        req = urllib2.Request(url)
        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
        opener = urllib2.build_opener(SmartRedirectHandler())
        content = opener.open(req)
    except ImportError, inst:
        status,location = inst	
        response = urllib.urlopen(location)
        content =response.read()
Example #8
0
def log(msg, err=False):
    if err:
        xbmc.log(addon.getAddonInfo('name') + ': ' + msg.encode('utf-8'), 
                 xbmc.LOGERROR)    
    else:
        xbmc.output(addon.getAddonInfo('name') + ': ' + msg.encode('utf-8'), 
                    xbmc.LOGDEBUG)    
def detail(params,url,category):
	xbmc.output("[newcineonline.py] detail")

	title = urllib.unquote_plus( params.get("title") )
	thumbnail = urllib.unquote_plus( params.get("thumbnail") )

	# Descarga la página
	data = scrapertools.cachePage(url)
	#xbmc.output(data)
	
	# La siguiente página
	patronvideos  = '<embed src\="http\:\/\/wwwstatic.megavideo.com\/mv\_player\.swf\?image=[^\&]+\&amp\;v\=([^"]+)"'
	matches = re.compile(patronvideos,re.DOTALL).findall(data)
	scrapertools.printMatches(matches)
	if len(matches)>0:
		xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Megavideo" , title + " - [Megavideo]" , matches[0], thumbnail , "" )

	# ------------------------------------------------------------------------------------
	# Busca los enlaces a los videos
	# ------------------------------------------------------------------------------------
	listavideos = servertools.findvideos(data)
	
	for video in listavideos:
		xbmctools.addnewvideo( CHANNELNAME , "play" , category , video[2] , title +" - "+video[0], video[1], thumbnail , "" )
	# ------------------------------------------------------------------------------------

	# 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("[tumejortv.py] detail")

	title = urllib.unquote_plus( params.get("title") )
	thumbnail = urllib.unquote_plus( params.get("thumbnail") )
	plot = ""

	# Descarga la página
	data = scrapertools.cachePage(url)
	#xbmc.output(data)

	patron = '<div id="blogitem">[^<]+<p>([^<]+)</p>'
	matches = re.compile(patron,re.DOTALL).findall(data)
	if len(matches)>0:
		plot = matches[0]

	listavideos = servertools.findvideos(data)
	
	for video in listavideos:
		xbmctools.addnewvideo( CHANNELNAME , "play" , CHANNELNAME , video[2] , title + " (" + video[2] + ")" , video[1] , thumbnail, plot )

	# Label (top-right)...
	xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=category )
	xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
	xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def ListadoTotal(params,url,category):
	xbmc.output("[peliculas24h.py] ListadoTotal")

	# Descarga la p�gina
	data = scrapertools.cachePage(url)
	#xbmc.output(data)

	# Patron de las entradas
	patron = "<a dir='ltr' href='([^']+)'>(.*?)</a>"
	matches = re.compile(patron,re.DOTALL).findall(data)
	scrapertools.printMatches(matches)

	# A�ade las entradas encontradas
	for match in matches:
		# Atributos
		scrapedtitle = match[1]
		scrapedurl = match[0]
		scrapedthumbnail = ""
		scrapedplot = ""
		if (DEBUG): xbmc.output("title=["+scrapedtitle+"], url=["+scrapedurl+"], thumbnail=["+scrapedthumbnail+"]")

		# A�ade al listado de XBMC
		xbmctools.addnewfolder( CHANNELNAME , "detail" , category , scrapedtitle , scrapedurl , scrapedthumbnail, scrapedplot )

	# Asigna el t�tulo, desactiva la ordenaci�n, y cierra el directorio
	xbmcplugin.setPluginCategory( handle=pluginhandle, category=category )
	xbmcplugin.addSortMethod( handle=pluginhandle, sortMethod=xbmcplugin.SORT_METHOD_NONE )
	xbmcplugin.endOfDirectory( handle=pluginhandle, succeeded=True )
def listcategorias(params,url,category):
        xbmc.output("[peliculas.py] listcategorias")

        xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Acci�n"    ,"http://www.peliculasid.com/accion-1.html","","")
        xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Animaci�n"    ,"http://www.peliculasid.com/animacion-1.html","","")
        xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Aventura"    ,"http://www.peliculasid.com/aventura-1.html","","")
        xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Ciencia Ficci�n"    ,"http://www.peliculasid.com/ciencia_ficcion-1.html","","")
        xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Cine Indio"    ,"http://www.peliculasid.com/cine_indio-1.html","","")
        xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Comedia"    ,"http://www.peliculasid.com/comedia-1.html","","")
        xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Crimen"    ,"http://www.peliculasid.com/crimen-1.html","","")
        xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Documentales y mas"    ,"http://www.peliculasid.com/documentales-1.html","","")
        xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Drama"    ,"http://www.peliculasid.com/drama-1.html","","")
        xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Fantasia"    ,"http://www.peliculasid.com/fantasia-1.html","","")
        xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Horror"    ,"http://www.peliculasid.com/horror-1.html","","")
        xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Misterio"    ,"http://www.peliculasid.com/misterio-1.html","","")
        xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Romance"    ,"http://www.peliculasid.com/romance-1.html","","")
        xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Thriller"    ,"http://www.peliculasid.com/thriller-1.html","","")
        
        # 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 performsearch(texto):
	xbmc.output("[peliculasyonkis.py] performsearch")
	url = "http://www.peliculasyonkis.com/buscarPelicula.php?s="+texto

	# Descarga la página
	data = scrapertools.cachePage(url)

	# Extrae las entradas (carpetas)
	patronvideos  = '<li> <a href="([^"]+)" title="([^"]+)"><img.*?src="([^"]+)"'
	matches = re.compile(patronvideos,re.DOTALL).findall(data)
	scrapertools.printMatches(matches)
	
	resultados = []

	for match in matches:
		# Atributos
		scrapedtitle = match[1]
		scrapedurl = match[0]
		scrapedthumbnail = match[2]
		scrapedplot = ""
		if (DEBUG): xbmc.output("title=["+scrapedtitle+"], url=["+scrapedurl+"], thumbnail=["+scrapedthumbnail+"]")

		# Añade al listado de XBMC
		resultados.append( [CHANNELNAME , "detailfolder" , "buscador" , scrapedtitle , scrapedurl , scrapedthumbnail, scrapedplot ] )
		
	return resultados
Example #14
0
def mainlist(params, url, category):
    xbmc.output("[cineblog01.py] mainlist")

    # Añade al listado de XBMC
    xbmctools.addnewfolder(CHANNELNAME, "listvideos", category,
                           "Film - Novità", "http://cineblog01.com/film/", "",
                           "")
    xbmctools.addnewfolder(CHANNELNAME, "pelisalfa", category,
                           "Film - Per Lettera", "", "", "")
    xbmctools.addnewfolder(CHANNELNAME, "searchmovie", category,
                           "   Cerca Film", "", "", "")
    xbmctools.addnewfolder(CHANNELNAME, "listserie", category, "Serie",
                           "http://cineblog01.info/serietv/", "", "")
    xbmctools.addnewfolder(CHANNELNAME, "listanime", category, "Anime",
                           "http://cineblog01.info/anime/", "", "")

    # 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)
Example #15
0
def paises(params,url,category):
	xbmc.output("[delicast.py] paises")

	# --------------------------------------------------------
	# Descarga la página
	# --------------------------------------------------------
	data = scrapertools.cachePage(url)
	#xbmc.output(data)

	# --------------------------------------------------------
	# Extrae los paises
	# --------------------------------------------------------
	patron = '<a class=v href=([^>]+)>([^<]+)</a>'
	matches = re.compile(patron,re.DOTALL).findall(data)
	if DEBUG: scrapertools.printMatches(matches)

	for match in matches:
		scrapedtitle = match[1].strip()
		scrapedurl = match[0]
		scrapedthumbnail = ""
		scrapedplot = ""
		if (DEBUG): xbmc.output("title=["+scrapedtitle+"], url=["+scrapedurl+"], thumbnail=["+scrapedthumbnail+"]")

		# Añade al listado de XBMC
		xbmctools.addnewfolder( CHANNELCODE , "videos" , CHANNELNAME , scrapedtitle , scrapedurl , scrapedthumbnail, scrapedplot )

	# Cierra el directorio
	xbmcplugin.setPluginCategory( handle=pluginhandle, category=category )
	xbmcplugin.addSortMethod( handle=pluginhandle, sortMethod=xbmcplugin.SORT_METHOD_NONE )
	xbmcplugin.endOfDirectory( handle=pluginhandle, succeeded=True )
Example #16
0
def listageneros(params,url,category):
	xbmc.output("[meristation.py] listaporgenero")
	
	# --------------------------------------------------------
	# Descarga la página
	# --------------------------------------------------------
	data = scrapertools.cachePage(url)
	#xbmc.output(data)

	# --------------------------------------------------------
	# Extrae las categorias (carpetas)
	# --------------------------------------------------------
	patron = '<option  value="([^"]+)">([^<]+)</option>'
	matches = re.compile(patron,re.DOTALL).findall(data)
	if DEBUG: scrapertools.printMatches(matches)

	for match in matches:
		scrapedtitle = match[1].replace("&nbsp;","").strip()
		scrapedurl = urlparse.urljoin(url,match[0])
		scrapedthumbnail = ""
		scrapedplot = ""
		if (DEBUG): xbmc.output("title=["+scrapedtitle+"], url=["+scrapedurl+"], thumbnail=["+scrapedthumbnail+"]")

		# Añade al listado de XBMC
		#addvideo( scrapedtitle , scrapedurl , category )
		xbmctools.addnewfolder( CHANNELCODE , "letraresults" , CHANNELNAME , scrapedtitle , scrapedurl , scrapedthumbnail, scrapedplot )

	# Label (top-right)...
	xbmcplugin.setPluginCategory( handle=pluginhandle, category=category )

	# Disable sorting...
	xbmcplugin.addSortMethod( handle=pluginhandle, sortMethod=xbmcplugin.SORT_METHOD_NONE )

	# End of directory...
	xbmcplugin.endOfDirectory( handle=pluginhandle, succeeded=True )
def searchresults(params,url,category):
	xbmc.output("[peliculasyonkis.py] searchresults")

	if xbmctools.getPluginSetting("forceview")=="true":
		xbmc.executebuiltin("Container.SetViewMode(53)")  #53=icons

	# Descarga la página
	data = scrapertools.cachePage(url)
	#xbmc.output(data)

	# Extrae las entradas (carpetas)
	#<li> <a href="http://www.peliculasyonkis.com/pelicula/las-edades-de-lulu-1990/" title="Las edades de Lulú (1990)"><img width="77" height="110" src="http://images.peliculasyonkis.com/thumbs/las-edades-de-lulu-1990.jpg" alt="Las edades de Lulú (1990)" align="right" />
	
	patronvideos  = '<li> <a href="([^"]+)" title="([^"]+)"><img.*?src="([^"]+)"'
	matches = re.compile(patronvideos,re.DOTALL).findall(data)
	scrapertools.printMatches(matches)

	for match in matches:
		scrapedtitle = match[1]
		scrapedurl = match[0]
		scrapedthumbnail = match[2]
		scrapedplot = ""
		if (DEBUG): xbmc.output("title=["+scrapedtitle+"], url=["+scrapedurl+"], thumbnail=["+scrapedthumbnail+"]")
		xbmctools.addnewvideo( CHANNELNAME , "detail" , category , "Megavideo" , scrapedtitle , scrapedurl , scrapedthumbnail , scrapedplot )

	# 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 mainlist(params, url, category):
    xbmc.output("[veocine.py] mainlist")

    # Añade al listado de XBMC
    xbmctools.addnewfolder(CHANNELNAME, "videolist", "", "Peliculas", "http://www.veocine.es/peliculas.html", "", "")
    xbmctools.addnewfolder(
        CHANNELNAME, "videolist", "", "Documentales", "http://www.veocine.es/documentales.html", "", ""
    )
    xbmctools.addnewfolder(
        CHANNELNAME, "videolist", "", "Peliculas infantiles", "http://www.veocine.es/infantil.html", "", ""
    )
    xbmctools.addnewfolder(
        CHANNELNAME, "videolist", "", "Peliculas VOS", "http://www.veocine.es/peliculavos.html", "", ""
    )
    xbmctools.addnewfolder(CHANNELNAME, "videolist", "", "Anime", "http://www.veocine.es/anime.html", "", "")

    if xbmctools.getPluginSetting("singlechannel") == "true":
        xbmctools.addSingleChannelOptions(params, url, category)

        # 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)
Example #19
0
def mainlist(params, url, category):
    xbmc.output("[descargados.py] mainlist")

    downloadpath = xbmcplugin.getSetting("downloadpath")
    xbmc.output("[descargados.py] downloadpath=" + downloadpath)

    # Añade al listado de XBMC
    ficheros = os.listdir(downloadpath)
    for fichero in ficheros:
        url = os.path.join(downloadpath, fichero)
        listitem = xbmcgui.ListItem(fichero, iconImage="DefaultVideo.png")
        xbmcplugin.addDirectoryItem(handle=pluginhandle,
                                    url=url,
                                    listitem=listitem,
                                    isFolder=False)

    # 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)
Example #20
0
    def getFiles(self, script_files, version):
        """ fetch the files """
        xbmc.output("Update().getFiles() version=%s" % version)
        success = False
        try:
            totalFiles = len(script_files)
            for cnt, url in enumerate(script_files):
                items = os.path.split(url)
                path = os.path.join(self.local_dir, items[0]).replace(
                    version + '/', '').replace(version, '').replace('/', '\\')
                file = items[1].replace('%20', ' ')
                pct = int((float(cnt) / totalFiles) * 100)
                self.dialog.update(pct, "%s %s" % (
                    self._(1007),
                    url,
                ), "%s %s" % (
                    self._(1008),
                    path,
                ), "%s %s" % (
                    self._(1009),
                    file,
                ))
                if (self.dialog.iscanceled()): raise
                if (not os.path.isdir(path)): os.makedirs(path)
                src = "%s%s" % (self.tags_url, url)
                dest = os.path.join(path, file)
                #				print src, dest
                urllib.urlretrieve(src, dest)

            success = True
        except:
            raise
        return success
def play(params,url,category):
	xbmc.output("[kideos.py] play")

	title = urllib.unquote_plus( params.get("title") )
	thumbnail = urllib.unquote_plus( params.get("thumbnail") )
	xbmc.output("[kideos.py] play thumbnail="+thumbnail)
	plot = urllib.unquote_plus( params.get("plot") )
	server = urllib.unquote_plus( params.get("server") )

	# Abre dialogo
	dialogWait = xbmcgui.DialogProgress()
	dialogWait.create( xbmc.getLocalizedString( 30901 ), title , plot )

	# Carga la página de detalle
	data = scrapertools.cachePage(url)
	addvideopage(data,params,url,category)

	# Busca el id del vídeo
	patron = '<param name\="flashVars" value\="videoId\=([^"]+)"'
	matches = re.compile(patron,re.DOTALL).findall(data)
	scrapertools.printMatches(matches)		

	if len(matches)>0:
		video_id = matches[0]
		url = youtube.geturl(video_id)
		listitem = xbmcgui.ListItem( title, iconImage="DefaultVideo.png", thumbnailImage=thumbnail )
		listitem.setInfo( "video", { "Title": title, "Plot": plot } )

	# Cierra dialogo
	dialogWait.close()
	del dialogWait

	# Play video with the proper core
	xbmc.Player().play( url, listitem )
Example #22
0
def downloadpage(url):
    xbmc.output("[scrapertools.py] downloadpage - " + url)

    inicio = time.clock()
    req = urllib2.Request(url)
    req.add_header(
        'User-Agent',
        'Mozilla/5.0 (Windows; U; Windows NT 6.0; es-ES; rv:1.9.0.14) Gecko/2009082707 Firefox/3.0.14'
    )
    #if referer!="":
    #	xbmc.output("[scrapertools.py] Referer=" + referer)
    #	req.add_header('Referer', referer)
    try:
        response = urllib2.urlopen(req)
    except:
        req = urllib2.Request(url.replace(" ", "%20"))
        req.add_header(
            'User-Agent',
            'Mozilla/5.0 (Windows; U; Windows NT 6.0; es-ES; rv:1.9.0.14) Gecko/2009082707 Firefox/3.0.14'
        )

        response = urllib2.urlopen(req)
    data = response.read()
    response.close()
    fin = time.clock()
    xbmc.output("[scrapertools.py] Descargado en %d segundos " %
                (fin - inicio + 1))
    return data
Example #23
0
def downloadFile(url):
    if __settings__.getSetting('download_path') == '':
        try:
            dl_path = xbmcgui.Dialog().browse(0, __language__(30017),'files', '', False, False)
            __settings__.setSetting(id='download_path', value=dl_path)
            if not os.path.exists(dl_path):
                os.mkdir(dl_path)
        except:pass
    name =''
    extl = url.split('/')
    for i in extl:
        name=i
    file_path = xbmc.makeLegalFilename(os.path.join(__settings__.getSetting('download_path'), name))
    if os.path.isfile(file_path):
        return None
    try:
        urllib.urlretrieve(url, file_path, report_hook)
        if enable_debug:
            xbmc.output('Picture ' + str(url) + ' downloaded to ' + repr(file_path))
        return file_path
    except IOError:
        return None
        
    except  Exception,e:
        print e
        pass
Example #24
0
def cachePagePost(url, data):

    xbmc.output("[scrapertools.py] cachePagePost - " + url)
    inicio = time.clock()
    req = urllib2.Request(url, data)
    req.add_header(
        'User-Agent',
        'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3'
    )

    try:
        response = urllib2.urlopen(req)
    except:
        req = urllib2.Request(url.replace(" ", "%20"), data)
        req.add_header(
            'User-Agent',
            'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3'
        )
        response = urllib2.urlopen(req)
    data = response.read()
    response.close()
    fin = time.clock()
    xbmc.output("Descargado en %d segundos " % (fin - inicio + 1))
    '''
		outfile = open(localFileName,"w")
		outfile.write(data)
		outfile.flush()
		outfile.close()
		xbmc.output("Grabado a " + localFileName)
	'''
    return data
def listarelacionados(params,url,category):
	xbmc.output("[series21.py] listaractores")
	
	url1 = "http://www.series21.com"
	#patronvideos = '<div><a href="([^"]+)">([^<]+)</a><br'
	data = urllib.unquote_plus(params.get("extradata"))
	matches = buscarelacionados(data) 
	patronvideos = '<b>Serie:</b>(.*?)<.*?<b>Temporada:</b>(.*?)<a'
	serie = re.compile(patronvideos,re.DOTALL).findall(data)
	for match in serie:
		plot  = 'Serie : '+ match[0]+'\n'
		plot += 'Temporada : '+match[1]
	opciones = []
	URL = []
	for i in matches:
		if i[0] == "><a href=":
			opciones.append(i[2])
			URL.append(i[1])
		else:
			opciones.append("**"+i[2]+"**")
		
	dia = xbmcgui.Dialog()
	seleccion = dia.select("Selecciona uno ", opciones)
	xbmc.output("seleccion=%d" % seleccion)
	if seleccion == -1 :return
	elif "(Viendo ahora)" in opciones[seleccion]:return
	else:
		params["title"] = opciones[seleccion]
		params["plot"] = plot 
		ListarVideos(params,URL[seleccion],category)
	return
Example #26
0
def getlowurl(code):
    xbmc.output("[megavideo.py] Usa modo normal")

    code = getcode(code)

    req = urllib2.Request("http://www.megavideo.com/xml/videolink.php?v=" +
                          code)
    req.add_header(
        'User-Agent',
        'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14'
    )
    req.add_header('Referer', 'http://www.megavideo.com/')
    page = urllib2.urlopen(req)
    response = page.read()
    page.close()
    errort = re.compile(' errortext="(.+?)"').findall(response)
    movielink = ""
    if len(errort) <= 0:
        s = re.compile(' s="(.+?)"').findall(response)
        k1 = re.compile(' k1="(.+?)"').findall(response)
        k2 = re.compile(' k2="(.+?)"').findall(response)
        un = re.compile(' un="(.+?)"').findall(response)
        movielink = "http://www" + s[0] + ".megavideo.com/files/" + decrypt(
            un[0], k1[0], k2[0]) + "/?.flv"
        #addLink(name, movielink+'?.flv','')

    return movielink
def buscaporanyo(params,url,category):
	xbmc.output("[peliculasyonkis.py] buscaporanyo")

	anyoactual = 2010
	anyoinic   = 1977
	opciones = []
	for i in range(34):
		opciones.append(str(anyoactual))
		anyoactual = anyoactual - 1           
	dia = xbmcgui.Dialog()
	seleccion = dia.select("Listar desde el Año: ", opciones)
	xbmc.output("seleccion=%d" % seleccion)
	if seleccion == -1 :return
	if seleccion == 0:
		url = "http://www.peliculasyonkis.com/estreno/"+opciones[seleccion]+"/"+opciones[seleccion]+"/0/"
		listvideos(params,url,category)
		return

	anyoactual = 2010
	desde      = opciones[seleccion]
	rangonuevo = seleccion + 1
	opciones2 = []
	for j in range(rangonuevo):
		opciones2.append(str(anyoactual))
		anyoactual = anyoactual - 1
	dia2 = xbmcgui.Dialog()
	seleccion2 = dia2.select("Listar hasta el año:",opciones2)
	if seleccion == -1 :
		url = "http://www.peliculasyonkis.com/estreno/"+desde+"/"+desde+"/0/"
		listvideos(params,url,category)
		return
	url = "http://www.peliculasyonkis.com/estreno/"+desde+"/"+opciones2[seleccion2]+"/0/"
	listvideos(params,url,category)
	return
def detail(params,url,category):
	xbmc.output("[peliculasyonkis.py] detail")

	title = urllib.unquote_plus( params.get("title") )
	thumbnail = urllib.unquote_plus( params.get("thumbnail") )
	plot = unicode( xbmc.getInfoLabel( "ListItem.Plot" ), "utf-8" )

	# Descarga la página
	data = scrapertools.cachePage(url)
	#xbmc.output(data)

	# ------------------------------------------------------------------------------------
	# Busca los enlaces a los videos
	# ------------------------------------------------------------------------------------
	patronvideos  = 'href="http://www.peliculasyonkis.com/player/visor_pymeno2.*?id=([^&]+)&al=[^"]+"'
	matches = re.compile(patronvideos,re.DOTALL).findall(data)
	if len(matches)>0:
		scrapertools.printMatches(matches)
	
	
		id = matches[0]
		xbmc.output("[peliculasyonkis.py]  id="+id)
		dec = Yonkis.DecryptYonkis()
		url = dec.decryptID(dec.unescape(id))
		if ":" in url:
			match = url.split(":")
			url = choiceOne(match)
			if url == "": return
		print 'codigo :%s' %url
	else:
		xbmctools.alertnodisponible()
		return
	
	
	xbmctools.playvideo(CHANNELNAME,"Megavideo",url,category,title,thumbnail,plot)
Example #29
0
def getplaylistvideos(url, startindex, maxresults):
    xbmc.output("[youtube.py] getplaylistvideos")
    # Extrae el ID de la playlist
    patron = 'http://.*?/([^/]+)/$'
    matches = re.compile(patron, re.DOTALL).findall(url + "/")
    idplaylist = matches[0]
    print idplaylist

    # Obtiene el feed segun el API de YouTube
    url = "http://gdata.youtube.com/feeds/api/playlists/%s?start-index=%d&max-results=%d" % (
        idplaylist, startindex, maxresults)
    xbmc.output("[youtube.py] url=" + url)
    yt_service = gdata.youtube.service.YouTubeService()
    playlist_video_feed = yt_service.GetYouTubePlaylistVideoFeed(uri=url)

    itemlist = []
    for entry in playlist_video_feed.entry:
        item = Item(
            title=entry.title.text,
            url=entry.media.player.url,
            thumbnail=entry.media.thumbnail[len(entry.media.thumbnail) -
                                            1].url,
            plot=entry.media.description.text)
        itemlist.append(item)

    return itemlist
Example #30
0
def error(texto):
    try:
        xbmc.output(texto)
    except:
        validchars = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!#$%&'()-@[]^_`{}~."
        stripped = "".join(c for c in texto if c in validchars)
        xbmc.output("(stripped) " + stripped)
def listcategorias(params,url,category):
	xbmc.output("[yotix.py] listcategorias")

	# ------------------------------------------------------
	# Descarga la página
	# ------------------------------------------------------
	data = scrapertools.cachePage(url)
	#xbmc.output(data)

	# ------------------------------------------------------
	# Extrae las entradas de la home como carpetas
	# ------------------------------------------------------
	patron  = '<a href="(/categoria/[^"]+)">([^<]+)</a>'

	matches = re.compile(patron,re.DOTALL).findall(data)
	if DEBUG: scrapertools.printMatches(matches)

	for match in matches:
		# Atributos
		scrapedtitle = match[1]
		scrapedurl = urlparse.urljoin(url,match[0])
		scrapedthumbnail = ""
		scrapedplot = ""
		if (DEBUG): xbmc.output("title=["+scrapedtitle+"], url=["+scrapedurl+"], thumbnail=["+scrapedthumbnail+"]")

		# Añade al listado de XBMC
		xbmctools.addnewfolder( CHANNELNAME , "videolist" , category , scrapedtitle , scrapedurl , scrapedthumbnail, scrapedplot )

	# Label (top-right)...
	xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=category )
	xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
	xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def performsearch(texto):
	xbmc.output("[tutvsite.py] performsearch")
	url = "http://www.tu.tv/buscar/?str="+texto

	# Descarga la página
	data = scrapertools.cachePage(url)

	# Extrae las entradas (carpetas)
	patronvideos  = '<div class="fila clearfix">[^<]+<div.*?</div>[^<]+<a href="([^"]+)"[^<]+<img src="([^"]+)".*?<span id="txtN">(.*?)</span>.*?<span class="tmp">([^<]+)</span.*?<span id="txtN">(.*?)</span>'
	matches = re.compile(patronvideos,re.DOTALL).findall(data)
	scrapertools.printMatches(matches)
	
	resultados = []

	for match in matches:
		# Titulo
		try:
			scrapedtitle = unicode( match[2], "utf-8" ).encode("iso-8859-1")
		except:
			scrapedtitle = match[2]
		scrapedtitle = scrapedtitle.replace("<b>","")
		scrapedtitle = scrapedtitle.replace("</b>","")
		scrapedtitle = scrapedtitle.strip()
		scrapedurl = urlparse.urljoin(url,match[0])
		scrapedthumbnail = urlparse.urljoin(url,match[1])
		scrapedplot = match[4].strip()

		if (DEBUG): xbmc.output("title=["+scrapedtitle+"], url=["+scrapedurl+"], thumbnail=["+scrapedthumbnail+"]")

		# Añade al listado de XBMC
		resultados.append( [CHANNELNAME , "playfolder" , "buscador" , scrapedtitle , scrapedurl , scrapedthumbnail, scrapedplot ] )
		
	return resultados
def performsearch(texto):
	xbmc.output("[yotix.py] performsearch")
	url = "http://yotix.tv/?s="+texto

	# Descarga la página
	data = scrapertools.cachePage(url)

	# Extrae las entradas (carpetas)
	patronvideos  = '<div class="galleryitem">[^<]+'
	patronvideos += '<h1><a title="([^"]+)"[^<]+</a></h1>[^<]+'
	patronvideos += '<a href="([^"]+)"><img src="([^"]+)"'
	matches = re.compile(patronvideos,re.DOTALL).findall(data)
	scrapertools.printMatches(matches)
	
	resultados = []

	for match in matches:
		# Atributos
		scrapedtitle = match[0].replace("&#8211;","-")
		scrapedurl = match[1]
		scrapedthumbnail = match[2]
		scrapedplot = ""

		if (DEBUG): xbmc.output("title=["+scrapedtitle+"], url=["+scrapedurl+"], thumbnail=["+scrapedthumbnail+"]")

		# Añade al listado de XBMC
		resultados.append( [CHANNELNAME , "listmirrors" , "buscador" , scrapedtitle , scrapedurl , scrapedthumbnail, scrapedplot ] )
		
	return resultados
Example #34
0
   def getShows( self ):
      self.mysend("ListRecordedTV:\n")
      showsLine = self.myreceive()
      xbmc.output ("Show: " + showsLine)
      shows = self.getArgumentsList(showsLine)

      return shows
def mainlist(params,url,category):
	xbmc.output("[argia.py] mainlist")
	
	###
	### MAIN MENU
	###
	# Full Video List
	xbmctools.addnewfolder( CHANNELCODE , "videolist" , CHANNELNAME , "Denak" , "http://www.argia.com/multimedia?p=1" , "" , "" )
	# Recommended
	xbmctools.addnewfolder( CHANNELCODE , "recommended" , CHANNELNAME , "Gomendatuak" , VIDEOURL , "" , "" )
	# Most Viewed (this week)
	xbmctools.addnewfolder( CHANNELCODE , "mostviewed" , CHANNELNAME , "Asteko ikusienak" , VIDEOURL , "" , "" )
	# Videos (sin categoria)
	xbmctools.addnewfolder( CHANNELCODE , "videolist" , CHANNELNAME , "Bideoak" , "http://www.argia.com/multimedia/bideoak?p=1" , "" , "" )
	# Actos
	xbmctools.addnewfolder( CHANNELCODE , "videolist" , CHANNELNAME , "Ekitaldiak" , "http://www.argia.com/multimedia/ekitaldiak?p=1" , "" , "" )
	# Cortometrajes
	xbmctools.addnewfolder( CHANNELCODE , "videolist" , CHANNELNAME , "Film laburrak" , "http://www.argia.com/multimedia/laburrak?p=1" , "" , "" )
	
	# 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 )
Example #36
0
def addnewvideo(canal,
                accion,
                category,
                server,
                title,
                url,
                thumbnail,
                plot,
                Serie=""):
    try:
        xbmc.output('[xbmctools.py] addnewvideo( "' + canal + '" , "' +
                    accion + '" , "' + category + '" , "' + server + '" , "' +
                    title + '" , "' + url + '" , "' + thumbnail + '" , "' +
                    plot + '")" , "' + Serie + '")"')
    except:
        xbmc.output('[xbmctools.py] addnewvideo(<unicode>)')
    listitem = xbmcgui.ListItem(title,
                                iconImage="DefaultVideo.png",
                                thumbnailImage=thumbnail)
    listitem.setInfo("video", {"Title": title, "Plot": plot, "Studio": canal})
    #listitem.setProperty('fanart_image',os.path.join(IMAGES_PATH, "cinetube.png"))
    itemurl = '%s?channel=%s&action=%s&category=%s&title=%s&url=%s&thumbnail=%s&plot=%s&server=%s&Serie=%s' % (
        sys.argv[0], canal, accion, urllib.quote_plus(category),
        urllib.quote_plus(title), urllib.quote_plus(url),
        urllib.quote_plus(thumbnail), urllib.quote_plus(plot), server, Serie)
    #xbmc.output("[xbmctools.py] itemurl=%s" % itemurl)
    xbmcplugin.addDirectoryItem(handle=pluginhandle,
                                url=itemurl,
                                listitem=listitem,
                                isFolder=False)
Example #37
0
def geturls(id, data):
    reglink = re.compile(r'fmt_stream_map=([^\&]+)\&')
    match = reglink.search(data)
    print 'Encontrado : %s' % str(match)
    if match is not None:
        reglink = match.group(1)
        reglink = urllib.unquote_plus(reglink)
        print 'los links : %s' % reglink
        reglinks = reglink.split(",")
        opciones = []
        links = []
        format = []
        for link in reglinks:
            try:
                fmt = link.replace("|http", "*http").split('*')
                opciones.append("Calidad %s" % AVAILABLE_FORMATS2[fmt[0]])
                links.append(fmt[1])
                format.append(fmt[0])
            except:
                pass

        dia = xbmcgui.Dialog()
        seleccion = dia.select("Elige una Calidad", opciones)
        xbmc.output("seleccion=%d calidad : (%s) %s " %
                    (seleccion, format[seleccion],
                     AVAILABLE_FORMATS2[format[seleccion]]))
        if seleccion == -1:
            return "Esc"
        return links[seleccion]
    else:
        alertaNone()
    return "Esc"
def log(module, msg):
    xbmc.output("### [%s-%s] - %s" % (
        __scriptname__,
        module,
        msg,
    ),
                level=xbmc.LOGDEBUG)
Example #39
0
def categorias(params,url,category):
	xbmc.output("[goear.py] listcategorias")

	# Descarga la página
	data = scrapertools.cachePage(url)
	#xbmc.output(data)

	# Extrae las entradas (carpetas)
	patronvideos  = '<div class="cate-tipos"><a href="([^"]+)">([^<]+)</a></div>'
	matches = re.compile(patronvideos,re.DOTALL).findall(data)
	scrapertools.printMatches(matches)

	for match in matches:
		scrapedtitle = match[1]
		scrapedurl = urlparse.urljoin(url,match[0])
		if (DEBUG): xbmc.output("title=["+scrapedtitle+"], url=["+scrapedurl+"]")

		# Añade al listado de XBMC
		addnewfolder( "categoryresults" , scrapedtitle , scrapedurl )
	
	patronvideos  = '<div class="flechas" style="float:right;"><a href="([^"]+)"><strong>Siguiente  »</strong></a></div></div>'

	# Cierra el directorio
	xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=category )
	xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
	xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def listcategorias(params,url,category):
	xbmc.output("[filmeonlinebr.py] listcategorias")


	xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Aзгo"    ,"http://www.filmesonlinebr.com/search/label/A%C3%A7%C3%A3o","","")
	xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Aventura"    ,"http://www.filmesonlinebr.com/search/label/Aventura","","")
	xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Comйdia Romвntica"    ,"http://www.filmesonlinebr.com/search/label/Com%C3%A9dia%20Rom%C3%A2ntica","","")
	xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Comйdia"    ,"http://www.filmesonlinebr.com/search/label/Com%C3%A9dia","","")
	xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Documentбrio"    ,"http://www.filmesonlinebr.com/search/label/Document%C3%A1rio","","")
	xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Drama"    ,"http://www.filmesonlinebr.com/search/label/Drama","","")
	xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Ficзгo Cientнfica"    ,"http://www.filmesonlinebr.com/search/label/Fic%C3%A7%C3%A3o%20Cient%C3%ADfica","","")
	xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Guerra"    ,"http://www.filmesonlinebr.com/search/label/Guerra","","")
	xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Lanзamentos 2010"    ,"http://www.filmesonlinebr.com/search/label/Lan%C3%A7amentos%202010","","")
	xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Musical e Shows"    ,"http://www.filmesonlinebr.com/search/label/Musical","","")
	xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Filmes Brasileiros"    ,"http://www.filmesonlinebr.com/search/label/Nacional","","")
	xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Policial"    ,"http://www.filmesonlinebr.com/search/label/Policial","","")
	xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Romance"    ,"http://www.filmesonlinebr.com/search/label/Romance","","")
	xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Suspense"    ,"http://www.filmesonlinebr.com/search/label/Suspense","","")
	xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Terror"    ,"http://www.filmesonlinebr.com/search/label/Terror","","")
	
    # 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 )
Example #41
0
 def _parse_strings_file(self, language_path):
     """ adds localized strings to self.strings dictionary """
     try:
         # load and parse strings.xml file
         doc = xml.dom.minidom.parse(language_path)
         # make sure this is a valid <strings> xml file
         root = doc.documentElement
         if (not root or root.tagName != "strings"): raise
         # parse and resolve each <string id="#"> tag
         strings = root.getElementsByTagName("string")
         for string in strings:
             # convert id attribute to an integer
             string_id = int(string.getAttribute("id"))
             # if a valid id add it to self.strings dictionary
             if (string_id not in self.strings and string.hasChildNodes()):
                 self.strings[string_id] = string.firstChild.nodeValue
     except:
         # print the error message to the log and debug window
         xbmc.output("ERROR: Language file %s can't be parsed!" %
                     (language_path, ))
     # clean-up document object
     try:
         doc.unlink()
     except:
         pass
def cachePagePost(url,data):

	xbmc.output("[scrapertools.py] cachePagePost - " + url)
	inicio = time.clock()
	req = urllib2.Request(url,data)
	req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')

	try:
		response = urllib2.urlopen(req)
	except:
		req = urllib2.Request(url.replace(" ","%20"),data)
		req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
		response = urllib2.urlopen(req)
	data=response.read()
	response.close()
	fin = time.clock()
	xbmc.output("Descargado en %d segundos " % (fin-inicio+1))

	'''
		outfile = open(localFileName,"w")
		outfile.write(data)
		outfile.flush()
		outfile.close()
		xbmc.output("Grabado a " + localFileName)
	'''
	return data
Example #43
0
	def _addSlashAtEnd(self, path):
		# disabled for now as plugins on Windows uses non-system slashes?
		if not path.endswith(os.path.sep):
			#path += os.path.sep
			xbmc.output('[movielib] path %s was not translated to %s' % (path, path + os.path.sep))
			
		return path
Example #44
0
 def issueUpdate(self, version):
     xbmc.output("> Update().issueUpdate() version=%s" % version)
     path = os.path.join(self.local_backup_dir, 'resources\\lib\\update.py')
     command = 'XBMC.RunScript(%s,%s,%s)' % (
         path, self.script.replace('%20', ' '), version)
     xbmc.executebuiltin(command)
     xbmc.output("< Update().issueUpdate() done")
def errorlist(params,url,category):
	xbmc.output("[descargadoslist.py] errorlist")

	# Crea el directorio de la lista de descargas con error si no existe
	try:
		os.mkdir(DOWNLOAD_PATH)
	except:
		pass
	try:
		os.mkdir(ERROR_PATH)
	except:
		pass

	# Crea un listado con las entradas de favoritos
	xbmc.output("[downloadall.py] ERROR_PATH="+ERROR_PATH)
	ficheros = os.listdir(ERROR_PATH)
	for fichero in ficheros:
		xbmc.output("[downloadall.py] fichero="+fichero)
		try:
			# Lee el bookmark
			titulo,thumbnail,plot,server,url = readbookmarkfile(fichero,ERROR_PATH)

			# Crea la entrada
			# En la categoría va el nombre del fichero para poder borrarlo
			xbmctools.addnewvideo( CHANNELNAME , "playerror" , os.path.join( ERROR_PATH, fichero ) , server , titulo , url , thumbnail, plot )
		except:
			pass
			xbmc.output("[downloadall.py] error al leer bookmark")
			for line in sys.exc_info():
				xbmc.output( "%s" % line , xbmc.LOGERROR )

	# Label (top-right)...
	xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=category )
	xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
	xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
Example #46
0
def get_play(url, name):
    xbmc.output('>>> get_play(%s, %s)' % (url, name))
    #use_wma = True
    #use_mp3 = True

    playList = xbmc.PlayList(xbmc.PLAYLIST_MUSIC)
    playList.clear()

    #	if use_wma:
    #wma_url = url.replace('port_playmp3','port_playwma')
    wma0 = getURL(url)
    if wma0 != None:
        wma1 = re.compile('<param name="URL" value="(.*?)">').findall(wma0)
        if len(wma1) > 0:

            #xbmc.Player().play(wma1[0].replace('&amp;','&'))

            wma2 = getURL(wma1[0].replace('&amp;', '&'))
            if wma2 != None:
                wma3 = re.compile('<ref href = "(.*?)"/>').findall(wma2)
                if len(wma3) > 0:
                    x = 1
                    stacked_url = ''
                    for wma_purl in reversed(wma3):
                        item = xbmcgui.ListItem('%s [WMA Server %s])' %
                                                (name, x),
                                                iconImage=play_thumb,
                                                thumbnailImage=play_thumb)
                        item.setInfo(type='music',
                                     infoLabels={
                                         'title': name,
                                         'artist': '101.RU'
                                     })
                        playList.add(wma_purl, item)
                    xbmc.Player().play(playList)
Example #47
0
def addnewfolderextra(canal,
                      accion,
                      category,
                      title,
                      url,
                      thumbnail,
                      plot,
                      extradata,
                      Serie=""):
    #xbmc.output("pluginhandle=%d" % pluginhandle)
    try:
        xbmc.output('[xbmctools.py] addnewfolder( "' + canal + '" , "' +
                    accion + '" , "' + category + '" , "' + title + '" , "' +
                    url + '" , "' + thumbnail + '" , "' + plot + '")" , "' +
                    Serie + '")"')
    except:
        xbmc.output('[xbmctools.py] addnewfolder(<unicode>)')
    listitem = xbmcgui.ListItem(title,
                                iconImage="DefaultFolder.png",
                                thumbnailImage=thumbnail)
    listitem.setInfo("video", {"Title": title, "Plot": plot, "Studio": canal})
    itemurl = '%s?channel=%s&action=%s&category=%s&title=%s&url=%s&thumbnail=%s&plot=%s&extradata=%s&Serie=%s' % (
        sys.argv[0], canal, accion, urllib.quote_plus(category),
        urllib.quote_plus(title), urllib.quote_plus(url),
        urllib.quote_plus(thumbnail), urllib.quote_plus(plot),
        urllib.quote_plus(extradata), Serie)
    #xbmc.output("[xbmctools.py] itemurl=%s" % itemurl)
    xbmcplugin.addDirectoryItem(handle=pluginhandle,
                                url=itemurl,
                                listitem=listitem,
                                isFolder=True)
def play(params,url,category):
	xbmc.output("[terratv.py] play")

	title = unicode( xbmc.getInfoLabel( "ListItem.Title" ), "utf-8" )
	thumbnail = urllib.unquote_plus( params.get("thumbnail") )
	plot = unicode( xbmc.getInfoLabel( "ListItem.Plot" ), "utf-8" )
	server = "Directo"
	xbmc.output("[terratv.py] thumbnail="+thumbnail)

	# Abre dialogo
	dialogWait = xbmcgui.DialogProgress()
	dialogWait.create( 'Descargando datos del vídeo...', title )

	# --------------------------------------------------------
	# Descarga pagina detalle
	# --------------------------------------------------------
	data = scrapertools.cachePage(url)
	patron = "'(http\:\/\/www\.terra\.tv\/templates\/getVideo\.aspx[^']+)'"
	matches = re.compile(patron,re.DOTALL).findall(data)
	scrapertools.printMatches(matches)
	url = matches[0]
	xbmc.output("url="+url)

	req = urllib2.Request(url)
	req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
	response = urllib2.urlopen(req)
	data=response.read()
	response.close()
	xbmc.output("data="+data)

	patron = '<ref href="([^"]+)"'
	matches = re.compile(patron,re.DOTALL).findall(data)

	if len(matches)==0:
		patron = '<video src="([^"]+)"'
		matches = re.compile(patron,re.DOTALL).findall(data)

	url = matches[0]
	xbmc.output("url="+url)
	
	# --------------------------------------------------------
	# Amplia el argumento
	# --------------------------------------------------------
	patron = '<div id="encuesta">\s*<div class="cab">.*?</div>(.*?)</div>'
	matches = re.compile(patron,re.DOTALL).findall(data)
	scrapertools.printMatches(matches)
	if len(matches)>0:
		plot = "%s" % matches[0]
		plot = plot.replace("<p>","")
		plot = plot.replace("</p>"," ")
		plot = plot.replace("<strong>","")
		plot = plot.replace("</strong>","")
		plot = plot.replace("<br />"," ")
		plot = plot.strip()
	
	# Cierra dialogo
	dialogWait.close()
	del dialogWait

	xbmctools.playvideo(CHANNELNAME,server,url,category,title,thumbnail,plot)
Example #49
0
    def onClick( self, controlId ):
      xbmc.output("controlId: %s" % (controlId) ,level=xbmc.LOGDEBUG )
      if ( controlId == CONTROL_END ):
        self.exit_script()
        
      if ( controlId == CONTROL_NEXT ):      
        self.screen_next(self.screen)

      if ( controlId == 1502 ): #Confirm Installation
        self.getControl( 1099 ).setVisible( self.getControl( 1502 ).isSelected() )
              
      if ( controlId == 1503 ): #Password
        self.password = self.keyboard(_(505), True )
        self.getControl( 1503 ).setLabel( self.hide_pass(self.password) )
        if __settings__.getSetting( "enable_custom_password" ) == "true" :
          self.getControl( 1502 ).setVisible((self.password == self.password_confirmed) and self.password_confirmed != "")
          self.getControl( 1099 ).setVisible((self.password == self.password_confirmed) and self.password_confirmed != "" and self.getControl( 1502 ).isSelected())
      if ( controlId == 1504 ): #Confirm Password
        self.password_confirmed = self.keyboard(_(506), True )
        self.getControl( 1504 ).setLabel( self.hide_pass(self.password_confirmed) )
        if __settings__.getSetting( "enable_custom_password" ) == "true" :
          self.getControl( 1502 ).setVisible((self.password == self.password_confirmed) and self.password != "")
          self.getControl( 1099 ).setVisible((self.password == self.password_confirmed) and self.password != "" and self.getControl( 1502 ).isSelected())
      
      if ( controlId == 1401 ):
        self.slider()
def play(params,url,category):
	xbmc.output("[argia.py] play")
	
	# Page downloading
	data = scrapertools.cachePage(url)
	
	##
	## PARSE VIDEO DATA
	##
	'''
s1.addVariable('file','/multimedia/docs/bideoak/dantzaTradizioa.flv');
	'''
	#pattern = 'file=(.*?).flv'
	pattern = "s1\.addVariable\('file','([^']+)'\)"
	matches = re.compile(pattern,re.DOTALL).findall(data)
	scrapertools.printMatches(matches)
	
	try:
		url = MAINURL+matches[0]
	except:
		url = ""
	
	title = unicode( xbmc.getInfoLabel( "ListItem.Title" ), "utf-8" )
	thumbnail = urllib.unquote_plus( params.get("thumbnail") )
	plot = unicode( xbmc.getInfoLabel( "ListItem.Plot" ), "utf-8" )
	server = "Directo"

	xbmctools.playvideo(CHANNELCODE,server,url,category,title,thumbnail,plot)
Example #51
0
def GetApi():
    try:
        return appManager.GetInstance()
    except Exception, e:
        xbmc.output("CAUGHT ERROR" + str(e))
        if os.path.isfile(authUrlFile):
            os.remove(authUrlFile)
        return None
Example #52
0
def download(url):
	xbmc.output("[downloadtools.py] download: url="+url)

	# Saca el fichero de la URL
	nombrefichero =  urllib.unquote_plus( url.split("/")[-1] )
	xbmc.output("[downloadtools.py] download: nombrefichero="+nombrefichero)

	downloadfile(url,nombrefichero)
Example #53
0
def mainlist(params, url, category):
    xbmc.output("[configuracion.py] mainlist")

    # Verifica ruta de descargas
    downloadpath = downloadtools.getDownloadPath()
    downloadlistpath = downloadtools.getDownloadListPath()

    xbmcplugin.openSettings(sys.argv[0])
    def _addSlashAtEnd(self, path):
        # disabled for now as plugins on Windows uses non-system slashes?
        if not path.endswith(os.path.sep):
            #path += os.path.sep
            xbmc.output('[movielib] path %s was not translated to %s' %
                        (path, path + os.path.sep))

        return path
Example #55
0
def mainlist(params, url, category):
    xbmc.output("[plus.py] mainlist")

    url = "http://www.plus.es/tv/canales.html"

    # --------------------------------------------------------
    # Descarga la página
    # --------------------------------------------------------
    data = scrapertools.cachePage(url)
    #xbmc.output(data)

    # --------------------------------------------------------
    # Extrae los programas
    # --------------------------------------------------------
    '''
	<li class="canales estirar">
	<h2><a href="index.html?idlist=PLTVCN">Cine </a></h2>
	<a href="index.html?idlist=PLTVCN"><img alt="imagen Cine " src="/images/plustv/categorias/PLTVCN.jpg"/></a>
	<ul>
		<li><span><a title="Taller Canal+: Jaume Balagueró y Paco Plaza" href="index.html?idlist=PLTVCN&amp;idvid=834262&amp;pos=0">Taller Canal+: Jaume Balagueró y Paco Plaza</a></span></li><li><span><a title="Canal+ en Hollywood: globos de oro 2009" href="index.html?idlist=PLTVCN&amp;idvid=817622&amp;pos=1">Canal+ en Hollywood: globos de oro 2009</a></span></li>
		<li class="sinPlay"><a title="ver mas" href="emisiones.html?id=PLTVCN">Más ...</a></li>
	</ul>
	'''
    patron = '<li class="canales estirar[^"]*">[^<]+'
    patron += '<h2><a href="([^"]+)">([^<]+)</a></h2>[^<]+'
    patron += '<a href="[^"]+"><img alt="[^"]+" src="([^"]+)"/></a>'
    matches = re.compile(patron, re.DOTALL).findall(data)
    if DEBUG: scrapertools.printMatches(matches)

    for match in matches:
        scrapedtitle = match[1]
        try:
            scrapedtitle = unicode(scrapedtitle, "utf-8").encode("iso-8859-1")
        except:
            pass
        scrapedurl = urlparse.urljoin(url, match[0]).replace(
            "index.html?idlist", "emisiones.html?id")
        scrapedthumbnail = urlparse.urljoin(url, match[2])
        scrapedplot = ""
        if (DEBUG):
            xbmc.output("title=[" + scrapedtitle + "], url=[" + scrapedurl +
                        "], thumbnail=[" + scrapedthumbnail + "]")

        # Añade al listado de XBMC
        #addfolder( scrapedtitle , scrapedurl , "videolist" )
        xbmctools.addnewfolder(CHANNELCODE, "videolist", CHANNELNAME,
                               scrapedtitle, scrapedurl, scrapedthumbnail,
                               scrapedplot)

    # Label (top-right)...
    xbmcplugin.setPluginCategory(handle=pluginhandle, category=category)

    # Disable sorting...
    xbmcplugin.addSortMethod(handle=pluginhandle,
                             sortMethod=xbmcplugin.SORT_METHOD_NONE)

    # End of directory...
    xbmcplugin.endOfDirectory(handle=pluginhandle, succeeded=True)
Example #56
0
def error(texto):
	if REMOTE_DBG:
		print(texto,xbmc.LOGERROR)
	else:
		try:
			import xbmc
			xbmc.output(texto,xbmc.LOGERROR)
		except:
			print(texto)
Example #57
0
def play(params,url,category):
	xbmc.output("[meristation.py] play")

	title = unicode( xbmc.getInfoLabel( "ListItem.Title" ), "utf-8" )
	thumbnail = urllib.unquote_plus( params.get("thumbnail") )
	plot = unicode( xbmc.getInfoLabel( "ListItem.Plot" ), "utf-8" )
	server = "Directo"

	# URL de detalle
	# http://www.meristation.com/v3/des_videos.php?pic=WII&idj=cw49944ba621067&COD=cw4a8d04e8e355d
	# URL con el vídeo
	# http://www.meristation.com/v3/des_videos.php?id=cw4a8d04e8e355d&c=1&pic=WII&idj=cw49944ba621067
	# URL descargar vídeo
	# http://www.meristation.com/v3/des_videos.php?id=cw4a8d04e8e355d&c=1&pic=WII&idj=cw49944ba621067
	# XML
	# http://www.meristation.com/v3/video_player.php?vid=cw48fc48c0d0da9&res=alta&format=xml&version=1.5.002

	# Extrae el código del vídeo
	xbmc.output("[meristation.py] url="+url)
	patron  = 'http\://www.meristation.com/v3/des_videos.php.*?\&COD\=([^$]+)$'
	matches = re.compile(patron,re.DOTALL).findall(url)
	scrapertools.printMatches(matches)
	
	if len(matches)==0:
		patron  = 'id\=([^\&]+)\&'
		matches = re.compile(patron,re.DOTALL).findall(url)
		scrapertools.printMatches(matches)

	if len(matches)==0:
		patron  = 'http\://www.meristation.com/v3/des_videos.php.*?\&id\=([^$]+)$'
		matches = re.compile(patron,re.DOTALL).findall(url)
		scrapertools.printMatches(matches)
	
	if len(matches)==0:
		xbmctools.alertnodisponible()
		return

	# Descarga la página
	xbmc.output("[meristation.py] vid="+matches[0])
	url = 'http://www.meristation.com/v3/video_player.php?id='+matches[0]+'&format=xml'
	xbmc.output("[meristation.py] url="+url)
	data = scrapertools.downloadpagewithcookies(url)
	xbmc.output(data[:200])

	# Extrae las entradas (carpetas)
	patron  = '<location>([^<]+)</location>'
	matches = re.compile(patron,re.DOTALL).findall(data)
	scrapertools.printMatches(matches)

	if len(matches)==0:
		return
	
	url = matches[0]
	url = url.replace(" ","%20")
	
	xbmctools.playvideo(CHANNELCODE,server,url,category,title,thumbnail,plot)
Example #58
0
def downloadfile(url,nombrefichero):
	xbmc.output("[downloadtools.py] downloadfile: url="+url)
	
	# Ese es el fichero local
	rutalocal = os.path.join( xbmcplugin.getSetting("downloadpath") , nombrefichero )
	#xbmc.output("[downloadtools.py] rutalocal="+rutalocal)

	progreso.create( 'Pelisalacarta' , "Descargando vídeo..." , url , rutalocal )

	# Timeout del socket a 60 segundos
	socket.setdefaulttimeout(10)
	
	h=urllib2.HTTPHandler(debuglevel=0)
	request = urllib2.Request(url)

	'''
	#request.add_header('Host','www.canalplus.fr')
	request.add_header('Referer', 'http://www.canalplus.fr/flash/loader/loader_canalplus_V0_1.swf')
	request.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9) Gecko/2008052906 Firefox/3.0')
	request.add_header('Accept','text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
	request.add_header('Accept-Language','fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3')
	request.add_header('Accept-Charset','ISO-8859-1,utf-8;q=0.7,*;q=0.7')
	#request.add_header('Accept-Encoding','gzip,deflate')
	request.add_header('Keep-Alive','300')
	request.add_header('Connection','keep-alive')
	#request.add_header('Content-type','application/x-www-form-urlencoded')
	#request.add_header('Content-length',len(urllib.urlencode(params)))
	'''
	opener = urllib2.build_opener(h)
	urllib2.install_opener(opener)
	connexion = opener.open(request)
	taille = int(connexion.headers["Content-Length"])
	xbmc.log("Content-Length=%s" % taille)
	f=open(nombrefichero,"wb")
	ultimo = 0
	blocksize = 100*1024
	for i in range(1,taille,blocksize):
		ultimo = i
		f.write(connexion.read(blocksize))
		try:
			percent = int(i*100/taille)
			totalmb = float(float(taille)/(1024*1024))
			descargadosmb = float(float(i)/(1024*1024))
			progreso.update( percent , "Descargados %.2fMB de %.2fMB (%d%%)" % ( descargadosmb , totalmb , percent ) )
			if progreso.iscanceled():
				f.close()
				return -1
		except:
			xbmc.log(xbmc.output(sys.exc_info()[0],xbmc.LOGERROR))

	# Acaba
	bloque = connexion.read(taille - ultimo)
	f.write(bloque)
	#f.write(connexion.read(int(connexion.headers["Content-Length"])))
	# open(filename,"wb").write(connexion.read(int(connexion.headers["Content-Length"])))
	f.close()