Ejemplo n.º 1
0
def extraevideos(patronvideos, data, category, title, thumbnail, plot,
                 servidor):
    logger.info("patron=" + patronvideos)
    matches = re.compile(patronvideos, re.DOTALL).findall(data)
    scrapertools.printMatches(matches)

    if len(matches) > 0:
        # A�ade al listado de XBMC
        if servidor == "Directo":

            xbmctools.addnewvideo(CHANNELNAME, "play", category, "Directo",
                                  title, matches[0], thumbnail, plot)

        elif servidor == "Veoh":

            veohurl = servertools.findurl(matches[0], "veoh")
            logger.info(" veohurl = " + veohurl)

            if len(veohurl) > 0:
                if veohurl == "http://./default.asp":
                    advertencia = xbmcgui.Dialog()
                    resultado = advertencia.ok(
                        'The Documental video', title, 'not exist in Veoh',
                        'visit the web www.documentariestv.net for report this'
                    )
                    return
                logger.info(" newmatches = " + veohurl)
                xbmctools.addnewvideo(CHANNELNAME, "play", category, "Directo",
                                      title, veohurl, thumbnail, plot)
            else:
                advertencia = xbmcgui.Dialog()
                resultado = advertencia.ok('The Documental video', title,
                                           'not exist in Veoh')
                return

        elif servidor == "Google":
            url = "http://www.flashvideodownloader.org/download.php?u=http://video.google.com/videoplay?docid=" + matches[
                0]
            logger.info(" Url = " + url)
            data = scrapertools.cachePage(url)
            newpatron = '</script><div.*?<a href="(.*?)" title="Click to Download">'
            newmatches = re.compile(newpatron, re.DOTALL).findall(data)
            if len(newmatches) > 0:
                logger.info(" newmatches = " + newmatches[0])
                xbmctools.addnewvideo(CHANNELNAME, "play", category, "Directo",
                                      title, newmatches[0], thumbnail, plot)

        elif servidor == "Stagevu":
            url = "http://stagevu.com/video/" + matches[0]
            url = servertools.findurl(url, servidor)

            logger.info(" url = " + url)
            if DEBUG:

                videotitle = "Video en Stagevu"
                server = servidor
                xbmctools.addnewvideo(
                    CHANNELNAME, "play", category, "Directo",
                    title.strip().replace(server, "").replace("  ", " ") +
                    " - " + videotitle, url, thumbnail, plot)
def extraevideos(patronvideos,data,category,title,thumbnail,plot,servidor):
	xbmc.output("patron="+patronvideos)
	matches = re.compile(patronvideos,re.DOTALL).findall(data)
	scrapertools.printMatches(matches)		

        if len(matches)>0 :
		# A�ade al listado de XBMC
              if servidor == "Directo":
                   
		   xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title, matches[0] , thumbnail , plot )

              elif servidor == "Veoh":
                                   
                   veohurl = servertools.findurl(matches[0],"veoh")
                   xbmc.output(" veohurl = " +veohurl)

                   if len(veohurl)>0:
                     if  veohurl=="http://./default.asp":
                         advertencia = xbmcgui.Dialog()
		         resultado = advertencia.ok('The Documental video' , title , 'not exist in Veoh','visit the web www.documentariestv.net for report this' )
		         return
                     xbmc.output(" newmatches = "+veohurl)
                     xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title, veohurl , thumbnail , plot )
                   else:
                     advertencia = xbmcgui.Dialog()
		     resultado = advertencia.ok('The Documental video' , title , 'not exist in Veoh')
		     return 

              elif servidor == "Google":
                   url = "http://www.flashvideodownloader.org/download.php?u=http://video.google.com/videoplay?docid="+matches[0]
                   xbmc.output(" Url = "+url)
                   data = scrapertools.cachePage(url)
                   newpatron = '</script><div.*?<a href="(.*?)" title="Click to Download">'
                   newmatches = re.compile(newpatron,re.DOTALL).findall(data)
                   if len(newmatches)>0:
                      xbmc.output(" newmatches = "+newmatches[0])
                      xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title, newmatches[0] , thumbnail , plot )

              elif servidor == "Stagevu":
                   url= "http://stagevu.com/video/"+matches[0]
                   url = servertools.findurl(url,servidor)
                   
                   xbmc.output(" url = "+url)
                   if DEBUG:
                      
                          videotitle = "Video en Stagevu"
                          server = servidor
                          xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title.strip().replace(server,"").replace("  "," ") + " - " + videotitle , url , thumbnail , plot )
def listvideosTVmirror(params,url,category):
	logger.info("[dospuntocerovision.py] listvideosTVmirror")
	title = urllib.unquote_plus( params.get("title") )
	thumbnail = urllib.unquote_plus( params.get("thumbnail") )

	# Descarga la p�gina
	data = scrapertools.cachePage(url)
	# ------------------------------------------------------------------------------------
	# Busca los enlaces a los videos
	# ------------------------------------------------------------------------------------
	listavideos = servertools.findvideos(data)
	
	for video in listavideos:
		#logger.info("")
		if video[2] == "tu.tv":
			url = urllib.unquote_plus(servertools.findurl(video[1],video[2]))
			xbmctools.addnewvideo( CHANNELNAME , "detail" , category , "Directo" , title +" - "+video[0], url, thumbnail , "" )
		else:
			xbmctools.addnewvideo( CHANNELNAME , "detail" , 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 )
Ejemplo n.º 4
0
def listvideosTVmirror(params,url,category):
	logger.info("[dospuntocerovision.py] listvideosTVmirror")
	title = urllib.unquote_plus( params.get("title") )
	thumbnail = urllib.unquote_plus( params.get("thumbnail") )

	# Descarga la p�gina
	data = scrapertools.cachePage(url)
	# ------------------------------------------------------------------------------------
	# Busca los enlaces a los videos
	# ------------------------------------------------------------------------------------
	listavideos = servertools.findvideos(data)
	
	for video in listavideos:
		#logger.info("")
		if video[2] == "tu.tv":
			url = urllib.unquote_plus(servertools.findurl(video[1],video[2]))
			xbmctools.addnewvideo( CHANNELNAME , "detail" , category , "Directo" , title +" - "+video[0], url, thumbnail , "" )
		else:
			xbmctools.addnewvideo( CHANNELNAME , "detail" , 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 playvideoEx(canal,server,url,category,title,thumbnail,plot,desdefavoritos,desdedescargados):
	
	xbmc.output("[xbmctools.py] playvideo")
	xbmc.output("[xbmctools.py] playvideo canal="+canal)
	xbmc.output("[xbmctools.py] playvideo server="+server)
	xbmc.output("[xbmctools.py] playvideo url="+url)
	xbmc.output("[xbmctools.py] playvideo category="+category)

	# Abre el diálogo de selección
	if (server=="Megavideo" or server=="Megaupload") and xbmcplugin.getSetting("megavideopremium")=="true":
		opciones = []
		opciones.append("Ver en calidad alta [Megavideo]")
		opciones.append("Ver en calidad baja [Megavideo]")
		if desdefavoritos:
			opciones.append("Quitar de favoritos")
		else:
			opciones.append("Añadir a favoritos")

		dia = xbmcgui.Dialog()
		seleccion = dia.select("Elige una opción", opciones)
		xbmc.output("seleccion=%d" % seleccion)

		if seleccion==-1:
			return
		if seleccion==0:
			if server=="Megaupload":
				mediaurl = servertools.getmegauploadhigh(url)
			else:
				mediaurl = servertools.getmegavideohigh(url)
		elif seleccion==1:
			#advertencia = xbmcgui.Dialog()
			#resultado = advertencia.ok('Megavideo tiene un límite de reproducción de 72 minutos' , 'Aunque tengas una cuenta Premium el límite sigue existiendo' , 'cuando ves los vídeos en calidad baja')
			if server=="Megaupload":
				mediaurl = servertools.getmegauploadlow(url)
			else:
				mediaurl = servertools.getmegavideolow(url)
		elif seleccion==2:
			if desdefavoritos:
				# La categoría es el nombre del fichero en favoritos
				os.remove(urllib.unquote_plus( category ))
				advertencia = xbmcgui.Dialog()
				resultado = advertencia.ok('Vídeo quitado de favoritos' , title , 'Se ha quitado de favoritos')
			else:
				keyboard = xbmc.Keyboard(downloadtools.limpia_nombre_excepto_1(title))
				keyboard.doModal()
				if (keyboard.isConfirmed()):
					title = keyboard.getText()
				favoritos.savebookmark(title,url,thumbnail,server,plot)
				advertencia = xbmcgui.Dialog()
				resultado = advertencia.ok('Nuevo vídeo en favoritos' , title , 'se ha añadido a favoritos')
			return

	else:
		opciones = []
		opciones.append("Ver ["+server+"]")
		if desdefavoritos:
			opciones.append("Quitar de favoritos")
		else:
			opciones.append("Añadir a favoritos")
	
		dia = xbmcgui.Dialog()
		seleccion = dia.select("Elige una opción", opciones)
		xbmc.output("seleccion=%d" % seleccion)
		
		if seleccion==-1:
			return
		if seleccion==0:
			if server=="Megavideo":
				advertencia = xbmcgui.Dialog()
				resultado = advertencia.ok('Megavideo tiene un límite de reproducción de 72 minutos' , 'Para evitar que los vídeos se corten pasado ese tiempo' , 'necesitas una cuenta Premium')
			mediaurl = servertools.findurl(url,server)
		elif seleccion==1:
			if desdefavoritos:
				# La categoría es el nombre del fichero en favoritos
				os.remove(urllib.unquote_plus( category ))
				advertencia = xbmcgui.Dialog()
				resultado = advertencia.ok('Vídeo quitado de favoritos' , title , 'Se ha quitado de favoritos')
			else:
				keyboard = xbmc.Keyboard(downloadtools.limpia_nombre_excepto_1(title))
				keyboard.doModal()
				if (keyboard.isConfirmed()):
					title = keyboard.getText()
				favoritos.savebookmark(title,url,thumbnail,server,plot)
				advertencia = xbmcgui.Dialog()
				resultado = advertencia.ok('Nuevo vídeo en favoritos' , title , 'se ha añadido a favoritos')
			return

	xbmc.output("[xbmctools.py] mediaurl="+mediaurl)
	
	if mediaurl=="":
		alertnodisponibleserver(server)
		return
	
	# Abre dialogo
	dialogWait = xbmcgui.DialogProgress()
	dialogWait.create( 'Accediendo al video...', title )

	# Playlist vacia
	playlist = xbmc.PlayList( xbmc.PLAYLIST_VIDEO )
	playlist.clear()

	# Crea la entrada y la añade al playlist
	listitem = xbmcgui.ListItem( title, iconImage="DefaultVideo.png", thumbnailImage=thumbnail )
	listitem.setInfo( "video", { "Title": title, "Plot" : plot , "Studio" : canal , "Genre" : category } )
	playlist.add( mediaurl, listitem )

	# Cierra dialogo
	dialogWait.close()
	del dialogWait

	# Reproduce
	xbmcPlayer = xbmc.Player( xbmc.PLAYER_CORE_DVDPLAYER )
	xbmcPlayer.play(playlist)   
Ejemplo n.º 6
0
def playvideo(canal,server,url,category,title,thumbnail,plot):
	
	xbmc.output("[xbmctools.py] playvideo")

	# Abre el diálogo de selección
	if server=="Megavideo" and xbmcplugin.getSetting("megavideopremium")=="true":
		opciones = []
		opciones.append("Ver en calidad alta (Megavideo)")
		opciones.append("Ver en calidad baja (Megavideo)")
		opciones.append("Descargar")

		dia = xbmcgui.Dialog()
		seleccion = dia.select("Elige una opción", opciones)
		xbmc.output("seleccion=%d" % seleccion)

		if seleccion==-1:
			return
		if seleccion==0:
			mediaurl = servertools.getmegavideohigh(url)
		elif seleccion==1:
			advertencia = xbmcgui.Dialog()
			resultado = advertencia.ok('Megavideo tiene un límite de reproducción de 72 minutos' , 'Aunque tengas una cuenta Premium el límite sigue existiendo' , 'cuando ves los vídeos en calidad baja')
			mediaurl = servertools.getmegavideolow(url)
		elif seleccion==2:
			if xbmcplugin.getSetting("megavideopremium")=="false":
				mediaurl = servertools.getmegavideolow(url)
			else:
				mediaurl = servertools.getmegavideohigh(url)
			downloadtools.downloadtitle(mediaurl,title)
			return
	else:
		opciones = []
		opciones.append("Ver")
		opciones.append("Descargar")
	
		dia = xbmcgui.Dialog()
		seleccion = dia.select("Elige una opción", opciones)
		xbmc.output("seleccion=%d" % seleccion)
		
		if seleccion==-1:
			return
		if seleccion==0:
			if server=="Megavideo":
				advertencia = xbmcgui.Dialog()
				resultado = advertencia.ok('Megavideo tiene un límite de reproducción de 72 minutos' , 'Para evitar que los vídeos se corten pasado ese tiempo' , 'necesitas una cuenta Premium')
			mediaurl = servertools.findurl(url,server)
		elif seleccion==1:
			mediaurl = servertools.findurl(url,server)
			downloadtools.downloadtitle(mediaurl,title)
			return
		
	xbmc.output("[xbmctools.py] mediaurl="+mediaurl)
	
	# Abre dialogo
	dialogWait = xbmcgui.DialogProgress()
	dialogWait.create( 'Accediendo al video...', title )

	# Playlist vacia
	playlist = xbmc.PlayList( xbmc.PLAYLIST_VIDEO )
	playlist.clear()

	# Crea la entrada y la añade al playlist
	listitem = xbmcgui.ListItem( title, iconImage="DefaultVideo.png", thumbnailImage=thumbnail )
	listitem.setInfo( "video", { "Title": title, "Plot" : plot , "Studio" : canal , "Genre" : category } )
	playlist.add( mediaurl, listitem )

	# Cierra dialogo
	dialogWait.close()
	del dialogWait

	# Reproduce
	xbmcPlayer = xbmc.Player( xbmc.PLAYER_CORE_DVDPLAYER )
	xbmcPlayer.play(playlist)   
def downloadall(params,url,category):
	xbmc.output("[downloadall.py] downloadall")

	xbmc.output("[downloadall.py] DOWNLOAD_PATH=%s" % DOWNLOAD_PATH)

	lista = os.listdir(DOWNLOAD_PATH)

	xbmc.output("[downloadall.py] numero de ficheros=%d" % len(lista))

	# Crea un listado con las entradas de favoritos
	for fichero in lista:
		# El primer video de la lista
		xbmc.output("[downloadall.py] fichero="+fichero)

		if fichero!="error":
			# Descarga el vídeo
			try:
				# Lee el bookmark
				titulo,thumbnail,plot,server,url = readbookmark(fichero)
				xbmc.output("[downloadall.py] url="+url)

				# Averigua la URL del vídeo
				if (server=="Megavideo" or server=="Megaupload") and xbmctools.getPluginSetting("megavideopremium")=="true":
					if server=="Megaupload":
						mediaurl = servertools.getmegauploadhigh(url)
					else:
						mediaurl = servertools.getmegavideohigh(url)
				else:
					mediaurl = servertools.findurl(url,server)
				xbmc.output("[downloadall.py] mediaurl="+mediaurl)
				
				# Genera el NFO
				nfofilepath = downloadtools.getfilefromtitle("sample.nfo",titulo)
				outfile = open(nfofilepath,"w")
				outfile.write("<movie>\n")
				outfile.write("<title>"+titulo+")</title>\n")
				outfile.write("<originaltitle></originaltitle>\n")
				outfile.write("<rating>0.000000</rating>\n")
				outfile.write("<year>2009</year>\n")
				outfile.write("<top250>0</top250>\n")
				outfile.write("<votes>0</votes>\n")
				outfile.write("<outline></outline>\n")
				outfile.write("<plot>"+plot+"</plot>\n")
				outfile.write("<tagline></tagline>\n")
				outfile.write("<runtime></runtime>\n")
				outfile.write("<thumb></thumb>\n")
				outfile.write("<mpaa>Not available</mpaa>\n")
				outfile.write("<playcount>0</playcount>\n")
				outfile.write("<watched>false</watched>\n")
				outfile.write("<id>tt0432337</id>\n")
				outfile.write("<filenameandpath></filenameandpath>\n")
				outfile.write("<trailer></trailer>\n")
				outfile.write("<genre></genre>\n")
				outfile.write("<credits></credits>\n")
				outfile.write("<director></director>\n")
				outfile.write("<actor>\n")
				outfile.write("<name></name>\n")
				outfile.write("<role></role>\n")
				outfile.write("</actor>\n")
				outfile.write("</movie>")
				outfile.flush()
				outfile.close()
				xbmc.output("[downloadall.py] Creado fichero NFO")
				
				# Descarga el thumbnail
				xbmc.output("[downloadall.py] thumbnail="+thumbnail)
				thumbnailfile = downloadtools.getfilefromtitle(thumbnail,titulo)
				thumbnailfile = thumbnailfile[:-4] + ".tbn"
				xbmc.output("[downloadall.py] thumbnailfile="+thumbnailfile)
				try:
					downloadtools.downloadfile(thumbnail,thumbnailfile)
					xbmc.output("[downloadall.py] Thumbnail descargado")
				except:
					xbmc.output("[downloadall.py] error al descargar thumbnail")
					for line in sys.exc_info():
						xbmc.output( "%s" % line , xbmc.LOGERROR )
				
				# Descarga el video
				dev = downloadtools.downloadtitle(mediaurl,titulo)
				if dev == -1:
					# El usuario ha cancelado la descarga
					xbmc.output("[downloadall.py] Descarga cancelada")
					return
				elif dev == -2:
					# Error en la descarga, lo mueve a ERROR y continua con el siguiente
					xbmc.output("[downloadall.py] ERROR EN DESCARGA DE "+fichero)
					origen = os.path.join( DOWNLOAD_PATH , fichero )
					destino = os.path.join( ERROR_PATH , fichero )
					shutil.move( origen , destino )
				else:
					xbmc.output("[downloadall.py] Video descargado")
					# Borra el bookmark e itera para obtener el siguiente video
					filepath = os.path.join( DOWNLOAD_PATH , fichero )
					os.remove(filepath)
					xbmc.output("[downloadall.py] "+fichero+" borrado")
			except:
				xbmc.output("[downloadall.py] ERROR EN DESCARGA DE "+fichero)
				origen = os.path.join( DOWNLOAD_PATH , fichero )
				destino = os.path.join( ERROR_PATH , fichero )
				shutil.move( origen , destino )

	# 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 )
Ejemplo n.º 8
0
def playvideo(canal, server, url, category, title, thumbnail, plot):

    xbmc.output("[xbmctools.py] playvideo")

    # Abre el diálogo de selección
    if server == "Megavideo" and xbmcplugin.getSetting(
            "megavideopremium") == "true":
        opciones = []
        opciones.append("Ver en calidad alta (Megavideo)")
        opciones.append("Ver en calidad baja (Megavideo)")
        opciones.append("Descargar")

        dia = xbmcgui.Dialog()
        seleccion = dia.select("Elige una opción", opciones)
        xbmc.output("seleccion=%d" % seleccion)

        if seleccion == -1:
            return
        if seleccion == 0:
            mediaurl = servertools.getmegavideohigh(url)
        elif seleccion == 1:
            advertencia = xbmcgui.Dialog()
            resultado = advertencia.ok(
                'Megavideo tiene un límite de reproducción de 72 minutos',
                'Aunque tengas una cuenta Premium el límite sigue existiendo',
                'cuando ves los vídeos en calidad baja')
            mediaurl = servertools.getmegavideolow(url)
        elif seleccion == 2:
            if xbmcplugin.getSetting("megavideopremium") == "false":
                mediaurl = servertools.getmegavideolow(url)
            else:
                mediaurl = servertools.getmegavideohigh(url)
            downloadtools.downloadtitle(mediaurl, title)
            return
    else:
        opciones = []
        opciones.append("Ver")
        opciones.append("Descargar")

        dia = xbmcgui.Dialog()
        seleccion = dia.select("Elige una opción", opciones)
        xbmc.output("seleccion=%d" % seleccion)

        if seleccion == -1:
            return
        if seleccion == 0:
            if server == "Megavideo":
                advertencia = xbmcgui.Dialog()
                resultado = advertencia.ok(
                    'Megavideo tiene un límite de reproducción de 72 minutos',
                    'Para evitar que los vídeos se corten pasado ese tiempo',
                    'necesitas una cuenta Premium')
            mediaurl = servertools.findurl(url, server)
        elif seleccion == 1:
            mediaurl = servertools.findurl(url, server)
            downloadtools.downloadtitle(mediaurl, title)
            return

    xbmc.output("[xbmctools.py] mediaurl=" + mediaurl)

    # Abre dialogo
    dialogWait = xbmcgui.DialogProgress()
    dialogWait.create('Accediendo al video...', title)

    # Playlist vacia
    playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
    playlist.clear()

    # Crea la entrada y la añade al playlist
    listitem = xbmcgui.ListItem(title,
                                iconImage="DefaultVideo.png",
                                thumbnailImage=thumbnail)
    listitem.setInfo("video", {
        "Title": title,
        "Plot": plot,
        "Studio": canal,
        "Genre": category
    })
    playlist.add(mediaurl, listitem)

    # Cierra dialogo
    dialogWait.close()
    del dialogWait

    # Reproduce
    xbmcPlayer = xbmc.Player(xbmc.PLAYER_CORE_DVDPLAYER)
    xbmcPlayer.play(playlist)
Ejemplo n.º 9
0
def playvideoEx(canal,server,url,category,title,thumbnail,plot,desdefavoritos,desdedescargados,desderrordescargas,strmfile=False,Serie=""):

	logger.info("[xbmctools.py] playvideo")
	logger.info("[xbmctools.py] playvideo canal="+canal)
	logger.info("[xbmctools.py] playvideo server="+server)
	logger.info("[xbmctools.py] playvideo url="+url)
	logger.info("[xbmctools.py] playvideo category="+category)
	logger.info("[xbmctools.py] playvideo serie="+Serie)
	
	# Parametrizacion especifica
	import parametrizacion

	# Abre el diálogo de selección
	opciones = []
	default_action = config.getSetting("default_action")
	# Los vídeos de Megavídeo sólo se pueden ver en calidad alta con cuenta premium
	# Los vídeos de Megaupload sólo se pueden ver con cuenta premium, en otro caso pide captcha
	if (server=="Megavideo" or server=="Megaupload") and config.getSetting("megavideopremium")=="true":
		opciones.append(config.getLocalizedString(30150)+" ["+server+"]") # "Ver en calidad alta"
		# Si la accion por defecto es "Ver en calidad alta", la seleccion se hace ya
		if default_action=="2":
			seleccion = len(opciones)-1

	# Los vídeos de Megavídeo o Megaupload se pueden ver en calidad baja sin cuenta premium, aunque con el límite
	if (server=="Megavideo" or server=="Megaupload"):
		opciones.append(config.getLocalizedString(30152)+" [Megavideo]") # "Ver en calidad baja"
		# Si la accion por defecto es "Ver en calidad baja", la seleccion se hace ya
		if default_action=="1":
			seleccion = len(opciones)-1
	else:
		opciones.append(config.getLocalizedString(30151)+" ["+server+"]") # "Ver en calidad normal"
		# Si la accion por defecto es "Ver en calidad baja", la seleccion se hace ya
		if default_action<>"0":  #Si hay alguna calidad elegida (alta o baja) seleccionarmos esta para los no megavideo
			seleccion = len(opciones)-1

	if (parametrizacion.DOWNLOAD_ENABLED):
		opciones.append(config.getLocalizedString(30153)) # "Descargar"

	if desdefavoritos: 
		opciones.append(config.getLocalizedString(30154)) # "Quitar de favoritos"
	else:
		opciones.append(config.getLocalizedString(30155)) # "Añadir a favoritos"

	if (parametrizacion.DOWNLOAD_ENABLED):
		if desdedescargados:
			opciones.append(config.getLocalizedString(30156)) # "Quitar de lista de descargas"
		else:
			opciones.append(config.getLocalizedString(30157)) # "Añadir a lista de descargas"

	opciones.append(config.getLocalizedString(30158)) # "Enviar a JDownloader"
	if default_action=="3":
		seleccion = len(opciones)-1

	if (parametrizacion.DOWNLOAD_ENABLED):
		if desderrordescargas:
			opciones.append(config.getLocalizedString(30159)) # "Borrar descarga definitivamente"
			opciones.append(config.getLocalizedString(30160)) # "Pasar de nuevo a lista de descargas"

	if not strmfile:
		if category in LIBRARY_CATEGORIES:
			opciones.append(config.getLocalizedString(30161)) # "Añadir a Biblioteca"

	# Busqueda de trailers en youtube	
	if not canal in ["Trailer","ecarteleratrailers"]:
		opciones.append(config.getLocalizedString(30162)) # "Buscar Trailer"

	# Si la accion por defecto es "Preguntar", pregunta
	if default_action=="0":
		dia = xbmcgui.Dialog()
		seleccion = dia.select(config.getLocalizedString(30163), opciones) # "Elige una opción"
		#dia.close()
	logger.info("seleccion=%d" % seleccion)
	logger.info("seleccion=%s" % opciones[seleccion])

	# No ha elegido nada, lo más probable porque haya dado al ESC 
	if seleccion==-1:
		if strmfile:  #Para evitar el error "Uno o más elementos fallaron" al cancelar la selección desde fichero strm
			listitem = xbmcgui.ListItem( title, iconImage="DefaultVideo.png", thumbnailImage=thumbnail)
			xbmcplugin.setResolvedUrl(int(sys.argv[ 1 ]),False,listitem)    # JUR Added
		if config.getSetting("subtitulo") == "true":
			config.setSetting("subtitulo", "false")
		return

	if opciones[seleccion]==config.getLocalizedString(30158): # "Enviar a JDownloader"
		if server=="Megaupload":
			d = {"web": "http://www.megaupload.com/?d=" + url}
		else:
			d = {"web": "http://www.megavideo.com/?v=" + url}
		
		import scrapertools
		data = scrapertools.cachePage(config.getSetting("jdownloader")+"/action/add/links/grabber0/start1/"+urllib.urlencode(d)+ " " +thumbnail)
		return

	# Ver en calidad alta
	if opciones[seleccion].startswith(config.getLocalizedString(30150)): # "Ver en calidad alta"
		if server=="Megaupload":
			mediaurl = servertools.getmegauploadhigh(url)
		else:
			mediaurl = servertools.getmegavideohigh(url)
	
	# Ver (calidad baja megavideo o resto servidores)
	elif opciones[seleccion].startswith(config.getLocalizedString(30151)) or opciones[seleccion].startswith(config.getLocalizedString(30152)): # Ver en calidad (normal o baja)
		if server=="Megaupload":
			mediaurl = servertools.getmegauploadlow(url)
			if mediaurl == "":
				alertanomegauploadlow(server)
				return
		elif server=="Megavideo":
			# Advertencia límite 72 minutos megavideo
			if config.getSetting("megavideopremium")=="false":
				advertencia = xbmcgui.Dialog()
				resultado = advertencia.ok(config.getLocalizedString(30052) , config.getLocalizedString(30053) , config.getLocalizedString(30054))			
			mediaurl = servertools.getmegavideolow(url)
		else:
			mediaurl = servertools.findurl(url,server)

	# Descargar
	elif opciones[seleccion]==config.getLocalizedString(30153): # "Descargar"
		if server=="Megaupload":
			if config.getSetting("megavideopremium")=="false":
				mediaurl = servertools.getmegauploadlow(url)
			else:
				mediaurl = servertools.getmegauploadhigh(url)
		elif server=="Megavideo":
			if config.getSetting("megavideopremium")=="false":
				mediaurl = servertools.getmegavideolow(url)
			else:
				mediaurl = servertools.getmegavideohigh(url)
		else:
			mediaurl = servertools.findurl(url,server)

		import downloadtools
		keyboard = xbmc.Keyboard(downloadtools.limpia_nombre_excepto_1(title))
		keyboard.doModal()
		if (keyboard.isConfirmed()):
			title = keyboard.getText()
			downloadtools.downloadtitle(mediaurl,title)
		return

	# TODO: Mover a modulo favoritos
	elif opciones[seleccion]==config.getLocalizedString(30154): #"Quitar de favoritos"
		# La categoría es el nombre del fichero en favoritos
		os.remove(urllib.unquote_plus( category ))
		advertencia = xbmcgui.Dialog()
		resultado = advertencia.ok(config.getLocalizedString(30102) , title , config.getLocalizedString(30105)) # 'Se ha quitado de favoritos'
		return

	# TODO: Mover a modulo descargadoslist
	elif opciones[seleccion]==config.getLocalizedString(30159): #"Borrar descarga definitivamente"
		# La categoría es el nombre del fichero en favoritos
		os.remove(urllib.unquote_plus( category ))
		advertencia = xbmcgui.Dialog()
		resultado = advertencia.ok(config.getLocalizedString(30101) , title , config.getLocalizedString(30106)) # 'Se ha quitado de la lista'
		return

	# TODO: Mover a modulo descargadoslist
	elif opciones[seleccion]==config.getLocalizedString(30160): #"Pasar de nuevo a lista de descargas":
		import descargadoslist
		# La categoría es el nombre del fichero en favoritos, así que lee el fichero
		titulo,thumbnail,plot,server,url = descargadoslist.readbookmarkfile(urllib.unquote_plus( category ),"")
		# Lo añade a la lista de descargas
		descargadoslist.savebookmark(title,url,thumbnail,server,plot)
		# Y lo borra de la lista de errores
		os.remove(urllib.unquote_plus( category ))
		advertencia = xbmcgui.Dialog()
		resultado = advertencia.ok(config.getLocalizedString(30101) , title , config.getLocalizedString(30107)) # 'Ha pasado de nuevo a la lista de descargas'
		return

	# TODO: Mover a modulo favoritos
	elif opciones[seleccion]==config.getLocalizedString(30155): #"Añadir a favoritos":
		import favoritos
		import downloadtools
		keyboard = xbmc.Keyboard(downloadtools.limpia_nombre_excepto_1(title))
		keyboard.doModal()
		if keyboard.isConfirmed():
			title = keyboard.getText()
			favoritos.savebookmark(title,url,thumbnail,server,plot)
			advertencia = xbmcgui.Dialog()
			resultado = advertencia.ok(config.getLocalizedString(30102) , title , config.getLocalizedString(30108)) # 'se ha añadido a favoritos'
		return

	# TODO: Mover a modulo descargadoslist
	elif opciones[seleccion]==config.getLocalizedString(30156): #"Quitar de lista de descargas":
		# La categoría es el nombre del fichero en la lista de descargas
		os.remove(urllib.unquote_plus( category ))
		advertencia = xbmcgui.Dialog()
		resultado = advertencia.ok(config.getLocalizedString(30101) , title , config.getLocalizedString(30106)) # 'Se ha quitado de lista de descargas'
		return

	# TODO: Mover a modulo descargadoslist
	elif opciones[seleccion]==config.getLocalizedString(30157): #"Añadir a lista de descargas":
		import descargadoslist
		import downloadtools
		keyboard = xbmc.Keyboard(downloadtools.limpia_nombre_excepto_1(title))
		keyboard.doModal()
		if keyboard.isConfirmed():
			title = keyboard.getText()
			descargadoslist.savebookmark(title,url,thumbnail,server,plot)
			advertencia = xbmcgui.Dialog()
			resultado = advertencia.ok(config.getLocalizedString(30101) , title , config.getLocalizedString(30109)) # 'se ha añadido a la lista de descargas'
		return

	elif opciones[seleccion]==config.getLocalizedString(30161): #"Añadir a Biblioteca":  # Library
		import library
		library.savelibrary(title,url,thumbnail,server,plot,canal=canal,category=category,Serie=Serie)
		return

	elif opciones[seleccion]==config.getLocalizedString(30162): #"Buscar Trailer":
		config.setSetting("subtitulo", "false")
		xbmc.executebuiltin("Container.Update(%s?channel=%s&action=%s&category=%s&title=%s&url=%s&thumbnail=%s&plot=%s&server=%s)" % ( sys.argv[ 0 ] , "trailertools" , "buscartrailer" , urllib.quote_plus( category ) , urllib.quote_plus( title ) , urllib.quote_plus( url ) , urllib.quote_plus( thumbnail ) , urllib.quote_plus( "" ) , server ))
		return

	# Si no hay mediaurl es porque el vídeo no está :)
	logger.info("[xbmctools.py] mediaurl="+mediaurl)
	if mediaurl=="":
		alertnodisponibleserver(server)
		return

	# Crea un listitem para pasárselo al reproductor

	# Obtención datos de la Biblioteca (solo strms que estén en la biblioteca)
	if strmfile:
		logger.info("[xbmctools.py] 1")
		listitem = getLibraryInfo(mediaurl)
	else:
		logger.info("[xbmctools.py] 2")
		listitem = xbmcgui.ListItem( title, iconImage="DefaultVideo.png", thumbnailImage=thumbnail)
		listitem.setInfo( "video", { "Title": title, "Plot" : plot , "Studio" : canal , "Genre" : category } )

		
	# Lanza el reproductor
	if strmfile: #Si es un fichero strm no hace falta el play
		logger.info("[xbmctools.py] 3")
		xbmcplugin.setResolvedUrl(int(sys.argv[ 1 ]),True,listitem)
	else:
		logger.info("[xbmctools.py] 4")
		launchplayer(mediaurl, listitem)
		
	if (config.getSetting("subtitulo") == "true") and (opciones[seleccion].startswith("Ver")):
		xbmc.Player().setSubtitles(os.path.join( config.DATA_PATH, 'subtitulo.srt' ) )
		config.setSetting("subtitulo", "false")
Ejemplo n.º 10
0
def downloadall(params, url, category):
    xbmc.output("[downloadall.py] downloadall")

    xbmc.output("[downloadall.py] DOWNLOAD_PATH=%s" % DOWNLOAD_PATH)

    lista = os.listdir(DOWNLOAD_PATH)

    xbmc.output("[downloadall.py] numero de ficheros=%d" % len(lista))

    # Crea un listado con las entradas de favoritos
    for fichero in lista:
        # El primer video de la lista
        xbmc.output("[downloadall.py] fichero=" + fichero)

        if fichero != "error":
            # Descarga el vídeo
            try:
                # Lee el bookmark
                titulo, thumbnail, plot, server, url = readbookmark(fichero)
                xbmc.output("[downloadall.py] url=" + url)

                # Averigua la URL del vídeo
                if (server == "Megavideo" or server == "Megaupload"
                    ) and xbmcplugin.getSetting("megavideopremium") == "true":
                    if server == "Megaupload":
                        mediaurl = servertools.getmegauploadhigh(url)
                    else:
                        mediaurl = servertools.getmegavideohigh(url)
                else:
                    mediaurl = servertools.findurl(url, server)
                xbmc.output("[downloadall.py] mediaurl=" + mediaurl)

                # Genera el NFO
                nfofilepath = downloadtools.getfilefromtitle(
                    "sample.nfo", titulo)
                outfile = open(nfofilepath, "w")
                outfile.write("<movie>\n")
                outfile.write("<title>" + titulo + ")</title>\n")
                outfile.write("<originaltitle></originaltitle>\n")
                outfile.write("<rating>0.000000</rating>\n")
                outfile.write("<year>2009</year>\n")
                outfile.write("<top250>0</top250>\n")
                outfile.write("<votes>0</votes>\n")
                outfile.write("<outline></outline>\n")
                outfile.write("<plot>" + plot + "</plot>\n")
                outfile.write("<tagline></tagline>\n")
                outfile.write("<runtime></runtime>\n")
                outfile.write("<thumb></thumb>\n")
                outfile.write("<mpaa>Not available</mpaa>\n")
                outfile.write("<playcount>0</playcount>\n")
                outfile.write("<watched>false</watched>\n")
                outfile.write("<id>tt0432337</id>\n")
                outfile.write("<filenameandpath></filenameandpath>\n")
                outfile.write("<trailer></trailer>\n")
                outfile.write("<genre></genre>\n")
                outfile.write("<credits></credits>\n")
                outfile.write("<director></director>\n")
                outfile.write("<actor>\n")
                outfile.write("<name></name>\n")
                outfile.write("<role></role>\n")
                outfile.write("</actor>\n")
                outfile.write("</movie>")
                outfile.flush()
                outfile.close()
                xbmc.output("[downloadall.py] Creado fichero NFO")

                # Descarga el thumbnail
                xbmc.output("[downloadall.py] thumbnail=" + thumbnail)
                thumbnailfile = downloadtools.getfilefromtitle(
                    thumbnail, titulo)
                thumbnailfile = thumbnailfile[:-4] + ".tbn"
                xbmc.output("[downloadall.py] thumbnailfile=" + thumbnailfile)
                try:
                    downloadtools.downloadfile(thumbnail, thumbnailfile)
                    xbmc.output("[downloadall.py] Thumbnail descargado")
                except:
                    xbmc.output(
                        "[downloadall.py] error al descargar thumbnail")
                    for line in sys.exc_info():
                        xbmc.output("%s" % line, xbmc.LOGERROR)

                # Descarga el video
                dev = downloadtools.downloadtitle(mediaurl, titulo)
                if dev == -1:
                    # El usuario ha cancelado la descarga
                    xbmc.output("[downloadall.py] Descarga cancelada")
                    return
                elif dev == -2:
                    # Error en la descarga, lo mueve a ERROR y continua con el siguiente
                    xbmc.output("[downloadall.py] ERROR EN DESCARGA DE " +
                                fichero)
                    origen = os.path.join(DOWNLOAD_PATH, fichero)
                    destino = os.path.join(ERROR_PATH, fichero)
                    shutil.move(origen, destino)
                else:
                    xbmc.output("[downloadall.py] Video descargado")
                    # Borra el bookmark e itera para obtener el siguiente video
                    filepath = os.path.join(DOWNLOAD_PATH, fichero)
                    os.remove(filepath)
                    xbmc.output("[downloadall.py] " + fichero + " borrado")
            except:
                xbmc.output("[downloadall.py] ERROR EN DESCARGA DE " + fichero)
                origen = os.path.join(DOWNLOAD_PATH, fichero)
                destino = os.path.join(ERROR_PATH, fichero)
                shutil.move(origen, destino)

    # 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 playvideoEx(canal,server,url,category,title,thumbnail,plot,desdefavoritos,desdedescargados,desderrordescargas,strmfile=False,Serie=""):

	xbmc.output("[xbmctools.py] playvideo")
	xbmc.output("[xbmctools.py] playvideo canal="+canal)
	xbmc.output("[xbmctools.py] playvideo server="+server)
	xbmc.output("[xbmctools.py] playvideo url="+url)
	xbmc.output("[xbmctools.py] playvideo category="+category)
	xbmc.output("[xbmctools.py] playvideo serie="+Serie)
	
	# Abre el diálogo de selección
	opciones = []
	default_action = getPluginSetting("default_action")
	# Los vídeos de Megavídeo sólo se pueden ver en calidad alta con cuenta premium
	# Los vídeos de Megaupload sólo se pueden ver con cuenta premium, en otro caso pide captcha
	if (server=="Megavideo" or server=="Megaupload") and getPluginSetting("megavideopremium")=="true":
		opciones.append("Ver en calidad alta ["+server+"]")
		# Si la accion por defecto es "Ver en calidad alta", la seleccion se hace ya
		if default_action=="2":
			seleccion = len(opciones)-1

	# Los vídeos de Megavídeo o Megaupload se pueden ver en calidad baja sin cuenta premium, aunque con el límite
	if (server=="Megavideo" or server=="Megaupload"):
		opciones.append("Ver en calidad baja [Megavideo]")
		# Si la accion por defecto es "Ver en calidad baja", la seleccion se hace ya
		if default_action=="1":
			seleccion = len(opciones)-1
	else:
		opciones.append("Ver ["+server+"]")
		# Si la accion por defecto es "Ver en calidad baja", la seleccion se hace ya
		if default_action<>"0":  #Si hay alguna calidad elegida (alta o baja) seleccionarmos esta para los no megavideo
			seleccion = len(opciones)-1

	opciones.append("Descargar")

	if desdefavoritos: 
		opciones.append("Quitar de favoritos")
	else:
		opciones.append("Añadir a favoritos")

	if desdedescargados:
		opciones.append("Quitar de lista de descargas")
	else:
		opciones.append("Añadir a lista de descargas")

	if desderrordescargas:
		opciones.append("Borrar descarga definitivamente")
		opciones.append("Pasar de nuevo a lista de descargas")

	if not strmfile:
#		if category in LIBRARY_CATEGORIES:
		opciones.append("Añadir a Biblioteca")

	# Busqueda de trailers en youtube	
	if not canal in ["Trailer","ecarteleratrailers"]:
		opciones.append("Buscar Trailer")

	# Si la accion por defecto es "Preguntar", pregunta
	if default_action=="0":
		dia = xbmcgui.Dialog()
		seleccion = dia.select("Elige una opción", opciones)
		#dia.close()
	xbmc.output("seleccion=%d" % seleccion)
	xbmc.output("seleccion=%s" % opciones[seleccion])

	# No ha elegido nada, lo más probable porque haya dado al ESC 
	if seleccion==-1:
		if strmfile:  #Para evitar el error "Uno o más elementos fallaron" al cancelar la selección desde fichero strm
			listitem = xbmcgui.ListItem( title, iconImage="DefaultVideo.png", thumbnailImage=thumbnail)
			xbmcplugin.setResolvedUrl(int(sys.argv[ 1 ]),False,listitem)    # JUR Added
		return
	# Ver en calidad alta
	if opciones[seleccion].startswith("Ver en calidad alta"):
		if server=="Megaupload":
			mediaurl = servertools.getmegauploadhigh(url)
		else:
			mediaurl = servertools.getmegavideohigh(url)
	# Ver (calidad baja megavideo o resto servidores)
	elif opciones[seleccion].startswith("Ver"):
		if server=="Megaupload":
			mediaurl = servertools.getmegauploadlow(url)
			if mediaurl == "":
				alertanomegauploadlow(server)
				return
		elif server=="Megavideo":
			if getPluginSetting("megavideopremium")=="false":
				advertencia = xbmcgui.Dialog()
				resultado = advertencia.ok('Megavideo tiene un límite de reproducción de 72 minutos' , 'Para evitar que los vídeos se corten pasado ese tiempo' , 'necesitas una cuenta Premium')			
			mediaurl = servertools.getmegavideolow(url)
		else:
			mediaurl = servertools.findurl(url,server)

	# Descargar
	elif opciones[seleccion]=="Descargar":
		if server=="Megaupload":
			if getPluginSetting("megavideopremium")=="false":
				mediaurl = servertools.getmegauploadlow(url)
			else:
				mediaurl = servertools.getmegauploadhigh(url)
		elif server=="Megavideo":
			if getPluginSetting("megavideopremium")=="false":
				mediaurl = servertools.getmegavideolow(url)
			else:
				mediaurl = servertools.getmegavideohigh(url)
		else:
			mediaurl = servertools.findurl(url,server)

		keyboard = xbmc.Keyboard(downloadtools.limpia_nombre_excepto_1(title))
		keyboard.doModal()
		if (keyboard.isConfirmed()):
			title = keyboard.getText()
			downloadtools.downloadtitle(mediaurl,title)
		return

	elif opciones[seleccion]=="Quitar de favoritos":
		# La categoría es el nombre del fichero en favoritos
		os.remove(urllib.unquote_plus( category ))
		advertencia = xbmcgui.Dialog()
		resultado = advertencia.ok('Vídeo quitado de favoritos' , title , 'Se ha quitado de favoritos')
		return

	elif opciones[seleccion]=="Borrar descarga definitivamente":
		# La categoría es el nombre del fichero en favoritos
		os.remove(urllib.unquote_plus( category ))
		advertencia = xbmcgui.Dialog()
		resultado = advertencia.ok('Vídeo quitado de la lista' , title , 'Se ha quitado de la lista')
		return

	elif opciones[seleccion]=="Pasar de nuevo a lista de descargas":
		# La categoría es el nombre del fichero en favoritos, así que lee el fichero
		titulo,thumbnail,plot,server,url = descargadoslist.readbookmarkfile(urllib.unquote_plus( category ),"")
		# Lo añade a la lista de descargas
		descargadoslist.savebookmark(title,url,thumbnail,server,plot)
		# Y lo borra de la lista de errores
		os.remove(urllib.unquote_plus( category ))
		advertencia = xbmcgui.Dialog()
		resultado = advertencia.ok('Vídeo de nuevo para descargar' , title , 'Ha pasado de nuevo a la lista de descargas')
		return

	elif opciones[seleccion]=="Añadir a favoritos":
		keyboard = xbmc.Keyboard(downloadtools.limpia_nombre_excepto_1(title))
		keyboard.doModal()
		if keyboard.isConfirmed():
			title = keyboard.getText()
			favoritos.savebookmark(title,url,thumbnail,server,plot)
			advertencia = xbmcgui.Dialog()
			resultado = advertencia.ok('Nuevo vídeo en favoritos' , title , 'se ha añadido a favoritos')
		return

	elif opciones[seleccion]=="Quitar de lista de descargas":
		# La categoría es el nombre del fichero en la lista de descargas
		os.remove(urllib.unquote_plus( category ))
		advertencia = xbmcgui.Dialog()
		resultado = advertencia.ok('Vídeo quitado de lista de descargas' , title , 'Se ha quitado de lista de descargas')
		return

	elif opciones[seleccion]=="Añadir a lista de descargas":
		keyboard = xbmc.Keyboard(downloadtools.limpia_nombre_excepto_1(title))
		keyboard.doModal()
		if keyboard.isConfirmed():
			title = keyboard.getText()
			descargadoslist.savebookmark(title,url,thumbnail,server,plot)
			advertencia = xbmcgui.Dialog()
			resultado = advertencia.ok('Nuevo vídeo en lista de descargas' , title , 'se ha añadido a la lista de descargas')
		return

	elif opciones[seleccion]=="Añadir a Biblioteca":  # Library
		library.savelibrary(title,url,thumbnail,server,plot,canal=canal,category=category,Serie=Serie)
		return

	elif opciones[seleccion]=="Buscar Trailer":
		xbmc.executebuiltin("Container.Update(%s?channel=%s&action=%s&category=%s&title=%s&url=%s&thumbnail=%s&plot=%s&server=%s)" % ( sys.argv[ 0 ] , "trailertools" , "buscartrailer" , urllib.quote_plus( category ) , urllib.quote_plus( title ) , urllib.quote_plus( url ) , urllib.quote_plus( thumbnail ) , urllib.quote_plus( "" ) , server ))
		return

	# Si no hay mediaurl es porque el vídeo no está :)
	xbmc.output("[xbmctools.py] mediaurl="+mediaurl)
	if mediaurl=="":
		alertnodisponibleserver(server)
		return

	# Crea un listitem para pasárselo al reproductor

	# Obtención datos de la Biblioteca (solo strms que estén en la biblioteca)
	if strmfile:
		xbmc.output("[xbmctools.py] 1")
		listitem = getLibraryInfo(mediaurl)
	else:
		xbmc.output("[xbmctools.py] 2")
		listitem = xbmcgui.ListItem( title, iconImage="DefaultVideo.png", thumbnailImage=thumbnail)
		listitem.setInfo( "video", { "Title": title, "Plot" : plot , "Studio" : canal , "Genre" : category } )

		
	# Lanza el reproductor
	if strmfile: #Si es un fichero strm no hace falta el play
		xbmc.output("[xbmctools.py] 3")
		xbmcplugin.setResolvedUrl(int(sys.argv[ 1 ]),True,listitem)
	else:
		xbmc.output("[xbmctools.py] 4")
		launchplayer(mediaurl, listitem)
Ejemplo n.º 12
0
def playvideoEx(canal, server, url, category, title, thumbnail, plot,
                desdefavoritos, desdedescargados):

    xbmc.output("[xbmctools.py] playvideo")
    xbmc.output("[xbmctools.py] playvideo canal=" + canal)
    xbmc.output("[xbmctools.py] playvideo server=" + server)
    xbmc.output("[xbmctools.py] playvideo url=" + url)
    xbmc.output("[xbmctools.py] playvideo category=" + category)

    # Abre el diálogo de selección
    if (server == "Megavideo" or server == "Megaupload"
        ) and xbmcplugin.getSetting("megavideopremium") == "true":
        opciones = []
        opciones.append("Ver en calidad alta [Megavideo]")
        opciones.append("Ver en calidad baja [Megavideo]")
        if desdefavoritos:
            opciones.append("Quitar de favoritos")
        else:
            opciones.append("Añadir a favoritos")

        dia = xbmcgui.Dialog()
        seleccion = dia.select("Elige una opción", opciones)
        xbmc.output("seleccion=%d" % seleccion)

        if seleccion == -1:
            return
        if seleccion == 0:
            if server == "Megaupload":
                mediaurl = servertools.getmegauploadhigh(url)
            else:
                mediaurl = servertools.getmegavideohigh(url)
        elif seleccion == 1:
            #advertencia = xbmcgui.Dialog()
            #resultado = advertencia.ok('Megavideo tiene un límite de reproducción de 72 minutos' , 'Aunque tengas una cuenta Premium el límite sigue existiendo' , 'cuando ves los vídeos en calidad baja')
            if server == "Megaupload":
                mediaurl = servertools.getmegauploadlow(url)
            else:
                mediaurl = servertools.getmegavideolow(url)
        elif seleccion == 2:
            if desdefavoritos:
                # La categoría es el nombre del fichero en favoritos
                os.remove(urllib.unquote_plus(category))
                advertencia = xbmcgui.Dialog()
                resultado = advertencia.ok('Vídeo quitado de favoritos',
                                           title, 'Se ha quitado de favoritos')
            else:
                keyboard = xbmc.Keyboard(
                    downloadtools.limpia_nombre_excepto_1(title))
                keyboard.doModal()
                if (keyboard.isConfirmed()):
                    title = keyboard.getText()
                favoritos.savebookmark(title, url, thumbnail, server, plot)
                advertencia = xbmcgui.Dialog()
                resultado = advertencia.ok('Nuevo vídeo en favoritos', title,
                                           'se ha añadido a favoritos')
            return

    else:
        opciones = []
        opciones.append("Ver [" + server + "]")
        if desdefavoritos:
            opciones.append("Quitar de favoritos")
        else:
            opciones.append("Añadir a favoritos")

        dia = xbmcgui.Dialog()
        seleccion = dia.select("Elige una opción", opciones)
        xbmc.output("seleccion=%d" % seleccion)

        if seleccion == -1:
            return
        if seleccion == 0:
            if server == "Megavideo":
                advertencia = xbmcgui.Dialog()
                resultado = advertencia.ok(
                    'Megavideo tiene un límite de reproducción de 72 minutos',
                    'Para evitar que los vídeos se corten pasado ese tiempo',
                    'necesitas una cuenta Premium')
            mediaurl = servertools.findurl(url, server)
        elif seleccion == 1:
            if desdefavoritos:
                # La categoría es el nombre del fichero en favoritos
                os.remove(urllib.unquote_plus(category))
                advertencia = xbmcgui.Dialog()
                resultado = advertencia.ok('Vídeo quitado de favoritos',
                                           title, 'Se ha quitado de favoritos')
            else:
                keyboard = xbmc.Keyboard(
                    downloadtools.limpia_nombre_excepto_1(title))
                keyboard.doModal()
                if (keyboard.isConfirmed()):
                    title = keyboard.getText()
                favoritos.savebookmark(title, url, thumbnail, server, plot)
                advertencia = xbmcgui.Dialog()
                resultado = advertencia.ok('Nuevo vídeo en favoritos', title,
                                           'se ha añadido a favoritos')
            return

    xbmc.output("[xbmctools.py] mediaurl=" + mediaurl)

    if mediaurl == "":
        alertnodisponibleserver(server)
        return

    # Abre dialogo
    dialogWait = xbmcgui.DialogProgress()
    dialogWait.create('Accediendo al video...', title)

    # Playlist vacia
    playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
    playlist.clear()

    # Crea la entrada y la añade al playlist
    listitem = xbmcgui.ListItem(title,
                                iconImage="DefaultVideo.png",
                                thumbnailImage=thumbnail)
    listitem.setInfo("video", {
        "Title": title,
        "Plot": plot,
        "Studio": canal,
        "Genre": category
    })
    playlist.add(mediaurl, listitem)

    # Cierra dialogo
    dialogWait.close()
    del dialogWait

    # Reproduce
    xbmcPlayer = xbmc.Player(xbmc.PLAYER_CORE_DVDPLAYER)
    xbmcPlayer.play(playlist)
Ejemplo n.º 13
0
def extraevideos(patronvideos, data, category, title, thumbnail, plot, servidor):
    logger.info("patron=" + patronvideos)
    matches = re.compile(patronvideos, re.DOTALL).findall(data)
    scrapertools.printMatches(matches)

    if len(matches) > 0:
        # A�ade al listado de XBMC
        if servidor == "Directo":
            if "youtube.com" in matches[0]:
                from youtube import Extract_id

                url = Extract_id(matches[0])
                xbmctools.addnewvideo(
                    CHANNELNAME, "play", category, "Youtube", "%s [YOUTUBE]" % title, url, thumbnail, plot
                )
            else:
                xbmctools.addnewvideo(
                    CHANNELNAME, "play", category, "Directo", "%s [Directo]" % title, matches[0], thumbnail, plot
                )

        elif servidor == "Veoh":

            veohurl = servertools.findurl(matches[0], "veoh")
            logger.info(" veohurl = " + veohurl)

            if len(veohurl) > 0:
                if veohurl == "http://./default.asp":
                    advertencia = xbmcgui.Dialog()
                    resultado = advertencia.ok(
                        "El Video Video",
                        title,
                        "no existe en Veoh",
                        "visite la pagina www.sonolatino.com para reportarlo",
                    )
                    return
                logger.info(" newmatches = " + veohurl)
                xbmctools.addnewvideo(CHANNELNAME, "play", category, "Directo", title, veohurl, thumbnail, plot)
            else:
                advertencia = xbmcgui.Dialog()
                resultado = advertencia.ok("El Video Video", title, "no existe en Veoh")
                return

        elif servidor == "Google":
            url = (
                "http://www.flashvideodownloader.org/download.php?u=http://video.google.com/videoplay?docid="
                + matches[0]
            )
            logger.info(" Url = " + url)
            data1 = scrapertools.cachePage(url)
            newpatron = '</script>.*?<a href="(.*?)" title="Click to Download">'
            newmatches = re.compile(newpatron, re.DOTALL).findall(data1)
            if len(newmatches) > 0:
                logger.info(" newmatches = " + newmatches[0])
                xbmctools.addnewvideo(CHANNELNAME, "play", category, "Directo", title, newmatches[0], thumbnail, plot)

        elif servidor == "Stagevu":
            url = "http://stagevu.com/video/" + matches[0]
            url = servertools.findurl(url, servidor)

            logger.info(" url = " + url)

            videotitle = "Video en Stagevu"
            server = servidor
            xbmctools.addnewvideo(
                CHANNELNAME,
                "play",
                category,
                "Directo",
                title.strip().replace(server, "").replace("  ", " ") + " - " + videotitle,
                url,
                thumbnail,
                plot,
            )

        elif servidor == "izlesene":
            url = "http://www.izlesene.com/actions/video/embed.php?video=" + matches[0]
            data1 = scrapertools.cachePage(url)
            newpatron = "fURL=([^\&]+)\&vduration=([^\&]+)\&"
            newmatches = re.compile(newpatron, re.DOTALL).findall(data1)
            if len(newmatches) > 0:
                logger.info(" izlesene furl = " + newmatches[0][0])
                url = "http://dcdn.nokta.com/%s%s" % (newmatches[0][0], "_1_5_1.xml")
                xbmctools.addnewvideo(
                    CHANNELNAME,
                    "play",
                    category,
                    "izlesene",
                    "%s (%s) [IZLESENE]" % (title, newmatches[0][1]),
                    url,
                    thumbnail,
                    plot,
                )

        elif servidor == "Dailymotion":
            if "/" in matches[0]:
                idd = matches[0].split("/")
                id = idd[len(idd) - 1]
            else:
                id = matches[0]
            daily = "http://www.dailymotion.com/video/%s" % id
            data2 = scrapertools.cachePage(daily)
            Lowres = re.compile("%22sdURL%22%3A%22(.+?)%22").findall(data2)
            if len(Lowres) > 0:
                videourl = urllib.unquote(Lowres[0])
                videourl = videourl.replace("\/", "/")

                subtitle = "[FLV-Directo-Dailymotion]"
                xbmctools.addnewvideo(
                    CHANNELNAME, "play", category, "Directo", title + " - " + subtitle, videourl, thumbnail, plot
                )

                # Busca el enlace al video con formato HQ (H264)
            Highres = re.compile("%22hqURL%22%3A%22(.+?)%22").findall(data2)
            if len(Highres) > 0:
                videourl = urllib.unquote(Highres[0])
                videourl = videourl.replace("\/", "/")

                subtitle = (
                    "[h264-Directo-Dailymotion-este video no es soportado en versiones antiguas o xbox plataforma]"
                )
                xbmctools.addnewvideo(
                    CHANNELNAME, "play", category, "Directo", title + " - " + subtitle, videourl, thumbnail, plot
                )

        elif servidor == "Vimeo":
            subtitle = "[Vimeo]"
            xbmctools.addnewvideo(
                CHANNELNAME, "play", category, "Vimeo", title + " - " + subtitle, matches[0], thumbnail, plot
            )
            ## -------------------------

        elif servidor == "Yahoo":
            import yahoo

            subtitle = "[Yahoo]"
            video_url = yahoo.geturl(matches[0])
            if len(video_url) > 0:
                if "rtmp" in video_url:
                    addnewvideo(
                        CHANNELNAME,
                        "playRtmp",
                        category,
                        "Directo",
                        title + " - " + subtitle,
                        video_url,
                        thumbnail,
                        plot,
                    )
                else:
                    xbmctools.addnewvideo(
                        CHANNELNAME, "play", category, "Directo", title + " - " + subtitle, video_url, thumbnail, plot
                    )