def scrapvideoURL(urlSY):
	data = scrapertools.cachePage(urlSY)
	patronvideos  = 'href="http://www.seriesyonkis.com/player/visor_pymeno4.php.*?id=([^"]+)".*?alt="([^"]+)".*?'
	patronvideos += '<td><div[^>]+><[^>]+>[^<]+</span></div></td>[^<]+<td><div[^>]+><[^>]+>[^<]+</span></div></td>[^<]+'
	patronvideos += '<td><div[^>]+><[^>]+>(.*?)</span></div></td>.*?</tr>'
	matches = re.compile(patronvideos,re.DOTALL).findall(data)
	scrapertools.printMatches(matches)

	if len(matches)==0:
		xbmctools.alertnodisponible()
		return ""
	elif len(matches)==1:
		cortar = matches[0][0].split("&")
		id = cortar[0]
		xbmc.output("[seriesyonkis.py]  id="+id)
		dec = Yonkis.DecryptYonkis()
		id = dec.decryptID_series(dec.unescape(id))
		print 'codigo :%s' %id
		return id		
	else:
		id = choiceOne(matches)
		if len(id)==0:return ""
		xbmc.output("[seriesyonkis.py]  id="+id)
		dec = Yonkis.DecryptYonkis()
		id = dec.decryptID_series(dec.unescape(id))
		print 'codigo :%s' %id
		return id
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)
def detail(params, url, category):
    logger.info("[documentalesyonkis.py] detail")

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

    # ------------------------------------------------------------------------------------
    # Busca los enlaces a los videos
    # ------------------------------------------------------------------------------------
    data = scrapertools.cachePage(url)
    patroniframe = '<iframe src="(http:\/\/documentales\.videosyonkis\.com.*?id=(.*?))" onLoad.*'
    matches = re.compile(patroniframe, re.DOTALL).findall(data)
    # scrapertools.printMatches(matches)

    if len(matches) > 0:
        id = matches[0][1]
        logger.info("[documentalesyonkis.py] detail id=" + id)
        if "&" in id:
            ids = id.split("&")
            id = ids[0]
        dec = Yonkis.DecryptYonkis()
        id = dec.decryptALT(dec.charting(dec.unescape(id)))
        logger.info("[documentalesyonkis.py] detail id=" + id)
        url = id
    else:
        xbmctools.alertnodisponible()
        return

    xbmctools.playvideo(CHANNELNAME, "Megavideo", url, category, title, thumbnail, plot)
def play(params,url,category):
	logger.info("[delatv.py] play")

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

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

	# Busca los enlaces a los videos
	data = scrapertools.cachePage(url)
	listavideos = servertools.findvideos(data)

	# Cierra dialogo
	dialogWait.close()
	del dialogWait

	if len(listavideos)>0:
		url = listavideos[0][1]
		server = listavideos[0][2]
		logger.info("url="+url)
		xbmctools.playvideo(CHANNELNAME,server,url,category,title,thumbnail,plot)
	else:
		xbmctools.alertnodisponible()
def scrapvideoURL(urlSY):
	data = scrapertools.cachePage(urlSY)
	patronvideos  = 'href="http://www.seriesyonkis.com/player/visor_([^\.]+).php.*?id=([^"]+)".*?alt="([^"]+)".*?'
	patronvideos += '<td><div[^>]+><[^>]+>[^<]+</span></div></td>[^<]+<td><div[^>]+><[^>]+>[^<]+</span></div></td>[^<]+'
	patronvideos += '<td><div[^>]+><[^>]+>(.*?)</tr>'
	matches = re.compile(patronvideos,re.DOTALL).findall(data)
	scrapertools.printMatches(matches)
	id=""
	if len(matches)==0:
		xbmctools.alertnodisponible()
		return ""
	elif len(matches)==1:
		#print matches[0][1]
		if matches[0][0] == "svueno":
			id = matches[0][1]
			logger.info("[seriesyonkis.py]  id="+id)
			dec = Yonkis.DecryptYonkis()
			id = dec.decryptALT(dec.charting(dec.unescape(id)))
			id = "http://stagevu.com/video/" + id
		elif matches[0][0] in ["pymeno2","pymeno3","pymeno4","pymeno5","pymeno6"]:
			cortar = matches[0][1].split("&")
			id = cortar[0]
			logger.info("[seriesyonkis.py]  id="+id)
			dec = Yonkis.DecryptYonkis()
			id = dec.decryptID_series(dec.unescape(id))
		else:pass
		print 'codigo :%s' %id
		return id		
	else:
		id = choiceOne(matches)
		if len(id)==0:return ""
		print 'codigo :%s' %id
		return id
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)
Beispiel #7
0
def scrapvideoURL(urlSY):
    data = scrapertools.cachePage(urlSY)
    patronvideos = 'href="http://www.seriesyonkis.com/player/visor_([^\.]+).php.*?id=([^"]+)".*?alt="([^"]+)".*?'
    patronvideos += "<td><div[^>]+><[^>]+>[^<]+</span></div></td>[^<]+<td><div[^>]+><[^>]+>[^<]+</span></div></td>[^<]+"
    patronvideos += "<td><div[^>]+><[^>]+>(.*?)</tr>"
    matches = re.compile(patronvideos, re.DOTALL).findall(data)

    patronvideos1 = 'http://www.seriesyonkis.com/lista-series/(descargar)/n/(.+?)/.*?alt="([^"]+)".*?'
    patronvideos1 += "Durac.+?:\s?([^>]+?)>"
    matches1 = re.compile(patronvideos1, re.DOTALL).findall(data)
    if len(matches1) > 0:
        for j in matches1:
            matches.append(j)
    scrapertools.printMatches(matches)
    id = ""
    # newdec = Yonkis.DecryptYonkis()
    # xbmc.output(newdec.ccM(newdec.charting(newdec.unescape("%B7%AC%A6%B1%B7%AD%A9%B1"))))

    if len(matches) == 0:
        xbmctools.alertnodisponible()
        return "", ""
    elif len(matches) == 1:
        server = SERVER[matches[0][0]]
        # print matches[0][1]
        if matches[0][0] == "svueno":
            id = matches[0][1]
            logger.info("[seriesyonkis.py]  id=" + id)
            dec = Yonkis.DecryptYonkis()
            id = dec.decryptALT(dec.charting(dec.unescape(id)))
            id = "http://stagevu.com/video/" + id
        elif matches[0][0] in ["pymeno2", "pymeno3", "pymeno4", "pymeno5", "pymeno6"]:
            cortar = matches[0][1].split("&")
            id = cortar[0]
            logger.info("[seriesyonkis.py]  id=" + id)
            dec = Yonkis.DecryptYonkis()
            id = dec.decryptID_series(dec.unescape(id))
        else:
            pass
        print "codigo :%s" % id
        return server, id
    else:

        server, id = choiceOne(matches)
        if len(id) == 0:
            return "", ""
        print "codigo :%s" % id
        return server, id
Beispiel #8
0
def scrapvideoURL(urlSY):
    data = scrapertools.cachePage(urlSY)
    patronvideos  = 'href="http://www.seriesyonkis.com/player/visor_([^\.]+).php.*?id=([^"]+)".*?alt="([^"]+)".*?'
    patronvideos += '<td><div[^>]+><[^>]+>[^<]+</span></div></td>[^<]+<td><div[^>]+><[^>]+>[^<]+</span></div></td>[^<]+'
    patronvideos += '<td><div[^>]+><[^>]+>(.*?)</tr>'
    matches = re.compile(patronvideos,re.DOTALL).findall(data)
    
    patronvideos1  = 'http://www.seriesyonkis.com/lista-series/(descargar)/n/(.+?)/.*?alt="([^"]+)".*?'
    patronvideos1 += 'Durac.+?:\s?([^>]+?)>'
    matches1 = re.compile(patronvideos1,re.DOTALL).findall(data)
    if (len(matches1) > 0):
        for j in matches1:
            matches.append(j)
    scrapertools.printMatches(matches)
    id=""
    #newdec = Yonkis.DecryptYonkis()
    #xbmc.output(newdec.ccM(newdec.charting(newdec.unescape("%B7%AC%A6%B1%B7%AD%A9%B1"))))
    
    if len(matches)==0:
        xbmctools.alertnodisponible()
        return "",""
    elif len(matches)==1:
        server = SERVER[matches[0][0]]
        #print matches[0][1]
        if matches[0][0] == "svueno":
            id = matches[0][1]
            logger.info("[seriesyonkis.py]  id="+id)
            dec = Yonkis.DecryptYonkis()
            id = dec.decryptALT(dec.charting(dec.unescape(id)))
            id = "http://stagevu.com/video/" + id
        elif matches[0][0] in ["pymeno2","pymeno3","pymeno4","pymeno5","pymeno6"]:
            cortar = matches[0][1].split("&")
            id = cortar[0]
            logger.info("[seriesyonkis.py]  id="+id)
            dec = Yonkis.DecryptYonkis()
            id = dec.decryptID_series(dec.unescape(id))
        else:pass
        print 'codigo :%s' %id
        return server,id        
    else:
        
        server,id = choiceOne(matches)
        if len(id)==0:return "",""
        print 'codigo :%s' %id
        return server,id
def detail(params, url, category):
    logger.info("[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)
    # logger.info(data)

    # ------------------------------------------------------------------------------------
    # Busca los enlaces a los videos
    # ------------------------------------------------------------------------------------
    patronvideos = 'href="http://www.peliculasyonkis.com/player/visor_([^\.]+).php.*?'
    patronvideos += 'id=([^"]+)".*?'
    patronvideos += 'alt="([^"]+)"'
    patronvideos += "(.*?)</tr>"
    matches = re.compile(patronvideos, re.DOTALL).findall(data)

    if len(matches) > 0:
        scrapertools.printMatches(matches)
        id, serv = ChoiceOneVideo(matches, title)
        logger.info("[peliculasyonkis.py]  id=" + id)
        url = Decrypt_Server(id, serv)
        if (serv in ["pymeno2", "pymeno3"]) and (":" in url):
            match = url.split(":")
            url = choiceOnePart(match)
            if url == "":
                return
        print "codigo :%s" % url
    else:
        xbmctools.alertnodisponible()
        return ""

    if url == "":
        return
    xbmctools.playvideo(CHANNELNAME, SERVER[serv], url, category, title, thumbnail, plot)
def detail(params, url, category):
    logger.info("[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)
    #logger.info(data)

    # ------------------------------------------------------------------------------------
    # Busca los enlaces a los videos
    # ------------------------------------------------------------------------------------
    patronvideos = 'href="http://www.peliculasyonkis.com/player/visor_([^\.]+).php.*?'
    patronvideos += 'id=([^"]+)".*?'
    patronvideos += 'alt="([^"]+)"'
    patronvideos += '(.*?)</tr>'
    matches = re.compile(patronvideos, re.DOTALL).findall(data)

    if len(matches) > 0:
        scrapertools.printMatches(matches)
        id, serv = ChoiceOneVideo(matches, title)
        logger.info("[peliculasyonkis.py]  id=" + id)
        url = Decrypt_Server(id, serv)
        if (serv in ["pymeno2", "pymeno3"]) and (":" in url):
            match = url.split(":")
            url = choiceOnePart(match)
            if url == "": return
        print 'codigo :%s' % url
    else:
        xbmctools.alertnodisponible()
        return ""

    if url == "": return
    xbmctools.playvideo(CHANNELNAME, SERVER[serv], url, category, title,
                        thumbnail, plot)
Beispiel #11
0
def play(params,url,category):
	logger.info("[delatv.py] play")
	try:
		title = unicode( xbmc.getInfoLabel( "ListItem.Title" ), "utf-8" )
	except:
		title = urllib.unquote_plus( params.get("title") )
	thumbnail = urllib.unquote_plus( params.get("thumbnail") )
	plot = unicode( xbmc.getInfoLabel( "ListItem.Plot" ), "utf-8" )
	server = params.get("server")

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

	# Descarga la página del reproductor
	# http://delatv.com/modulos/player.php?url=dmlkZW8uYWsuZmFjZWJvb2suY29tL2Nmcy1hay1hc2gyLzMzMjM2LzY4NS8xMDU1NTcxNDYxNjI3MjNfMzQ5ODk=
	# http://delatv.com/modulos/embed/playerembed.php?url=dmlkZW8uYWsuZmFjZWJvb2suY29tL2Nmcy1hay1hc2gyLzMzMjM2LzY4NS8xMDU1NTcxNDYxNjI3MjNfMzQ5ODk=
	logger.info("[delatv.py] url="+url)
	
	## --------------------------------------------------------------------------------------##
	#            Busca enlaces de videos para el servidor vkontakte.ru                        #
	## --------------------------------------------------------------------------------------##
	#"http://vkontakte.ru/video_ext.php?oid=89710542&id=147003951&hash=28845bd3be717e11&hd=1
	
	
	if "vkontakteX.php" or "/vk/" in url:
		data = scrapertools.cachePage(url)
		server = "Directo"
		'''
		var video_host = 'http://cs12916.vkontakte.ru/';
		var video_uid = '87155741';
		var video_vtag = 'fc697084d3';
		var video_no_flv = 1;
		var video_max_hd = '1'
		'''
		patronvideos = '<iframe src="(http://vk[^/]+/video_ext.php[^"]+)"'
		matches = re.compile(patronvideos,re.DOTALL).findall(data)
		if len(matches)>0:
			print " encontro VKontakte.ru :%s" %matches[0]
			url = 	vk.geturl(matches[0])
			
			
 		'''
			data2 = scrapertools.cachePage(matches[0])
			print data2
			patron  = "var video_host = '([^']+)'.*?"
			patron += "var video_uid = '([^']+)'.*?"
			patron += "var video_vtag = '([^']+)'.*?"
			patron += "var video_no_flv = ([^;]+);.*?"
			patron += "var video_max_hd = '([^']+)'"
			matches2 = re.compile(patron,re.DOTALL).findall(data2)
			if len(matches2)>0:    #http://cs12385.vkontakte.ru/u88260894/video/d09802a95b.360.mp4
				for match in matches2:
					if match[3].strip() == "0":
						tipo = "flv"
						url = "%su%s/video/%s.%s" % (match[0],match[1],match[2],tipo)
					
					else:
						tipo = "360.mp4"
						url = "%su%s/video/%s.%s" % (match[0],match[1],match[2],tipo)
						
		'''
	
	
	# Cierra dialogo
	dialogWait.close()
	del dialogWait

	if len(url)>0:
		
		logger.info("url="+url)
		xbmctools.playvideo(CHANNELNAME,server,url,category,title,thumbnail,plot)
	else:
		xbmctools.alertnodisponible()
def detail(params,url,category):
	logger.info("[cinegratis24h.py] detail")

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

	# Descarga la p�gina
	data = scrapertools.cachePage(url)
	#logger.info(data)
        patrondescrip = '<a onblur=.*?src="([^"]+)" border.*?</a><.*?><.*?>(Sinopsis:<br />.*?)</div>'
        matches = re.compile(patrondescrip,re.DOTALL).findall(data)
        if DEBUG:
			if len(matches)>0:
				for match in matches:
					thumbnail = match[0]
					descripcion = match[1]
					descripcion = descripcion.replace('&#8220;','"')
					descripcion = descripcion.replace('&#8221;','"')
					descripcion = descripcion.replace('&#8230;','...')
					descripcion = descripcion.replace("&nbsp;","")
					descripcion = descripcion.replace("<br/>","")
					descripcion = descripcion.replace("\r","")
					descripcion = descripcion.replace("\n"," ")
					descripcion = descripcion.replace("\t"," ")
					descripcion = re.sub("<[^>]+>"," ",descripcion)
					descripcion = acentos(descripcion)
					try :
						plot = unicode( descripcion, "utf-8" ).encode("iso-8859-1")
					except:
						plot = descripcion
				                    
                   
          
	# ------------------------------------------------------------------------------------
	# Busca los enlaces a los videos
	# ------------------------------------------------------------------------------------
	#listavideos = servertools.findvideos(data)

	#for video in listavideos:
	#	videotitle = video[0]
	#	url = video[1]
	#	server = video[2]
	#	xbmctools.addnewvideo( CHANNELNAME , "play" , category , server , title.strip() + " - " + videotitle , url , thumbnail , plot )
	# ------------------------------------------------------------------------------------
        
        #--- Busca los videos Directos
        patronvideos = 'file=([^\&]+)\&'
        matches = re.compile(patronvideos,re.DOTALL).findall(data)
        
        if len(matches)>0:
          if ("xml" in matches[0]):  
            #data = scrapertools.cachePage(matches[0])
            req = urllib2.Request(matches[0])
            try:
		response = urllib2.urlopen(req)
	    except:
                xbmctools.alertnodisponible()
                return
            data=response.read()
	    response.close()
            #logger.info("archivo xml :"+data)
            newpatron = '<title>([^<]+)</title>[^<]+<location>([^<]+)</location>'
            newmatches = re.compile(newpatron,re.DOTALL).findall(data)
            for match in newmatches:
				logger.info(" videos = "+match)
				if match[1].startwith("vid"):
					subtitle = match[0] + " (rtmpe) no funciona en xbmc"
				else:
					subtitle = match[0]             
                
				xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title + " - "+subtitle, match[1] , thumbnail , plot )
                 
          else:
			parte = 0
			tipo = " (FLV)"
			for match in matches:
				logger.info(" matches = "+match)
				parte = parte + 1
				if match.endswith('mp4'):
					tipo = " (MP4)"
				xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title + " (%d) %s" %(parte,tipo), match , thumbnail , plot )
	
	# 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 )
Beispiel #13
0
def detail(params, url, category):
    logger.info("[peliculasid.py] detail")

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

    # Descarga la p�gina
    data = scrapertools.downloadpageGzip(url)
    #logger.info(data)
    patrondescrip = '<strong>Sinopsis:</strong><br />(.*?)</p>'
    matches = re.compile(patrondescrip, re.DOTALL).findall(data)

    if len(matches) > 0:
        descripcion = matches[0]
        descripcion = descripcion.replace("<br/>", "")
        descripcion = descripcion.replace("\r", "")
        descripcion = descripcion.replace("\n", " ")
        descripcion = descripcion.replace("\t", " ")
        descripcion = re.sub("<[^>]+>", " ", descripcion)
        #logger.info("descripcion="+descripcion)
        descripcion = acentos(descripcion)
        #logger.info("descripcion="+descripcion)
        try:
            plot = unicode(descripcion, "utf-8").encode("iso-8859-1")
        except:
            plot = descripcion
        plot = scrapertools.unescape(plot.strip())
        #--- Busca los videos Directos
        patronvideos = 'flashvars" value="file=([^\&]+)\&amp'
        matches = re.compile(patronvideos, re.DOTALL).findall(data)

        if len(matches) > 0:

            if ("xml" in matches[0]):
                xbmctools.addnewvideo(CHANNELNAME, "play", category, "xml",
                                      "Reproducir todas las partes a la vez",
                                      matches[0], thumbnail, plot)
                #data = scrapertools.downloadpageGzip(matches[0])
                req = urllib2.Request(matches[0])
                try:
                    response = urllib2.urlopen(req)
                except:
                    xbmctools.alertnodisponible()
                    return
                data = response.read()
                response.close()

                #logger.info("archivo xml :"+data)
                newpatron = '<title>([^<]+)</title>[^<]+<location>([^<]+)</location>'
                newmatches = re.compile(newpatron, re.DOTALL).findall(data)
                if len(newmatches) > 0:
                    for match in newmatches:
                        logger.info(" videos = " + match[1])
                        if match[1].startswith("vid"):
                            subtitle = match[0] + " (rtmpe) no funciona en xbmc"
                        else:
                            subtitle = match[0]

                        xbmctools.addnewvideo(CHANNELNAME, "play", category,
                                              "Directo",
                                              title + " - " + subtitle,
                                              match[1], thumbnail, plot)

            else:
                logger.info(" matches = " + matches[0])
                xbmctools.addnewvideo(CHANNELNAME, "play", category, "Directo",
                                      title, matches[0], thumbnail, plot)

    # Ahora usa servertools
    listavideos = servertools.findvideos(data)

    j = 1
    for video in listavideos:
        videotitle = video[0]
        url = video[1]
        server = video[2]
        xbmctools.addnewvideo(CHANNELNAME, "play", category, server,
                              (title.strip() + " (%d) " + videotitle) % j, url,
                              thumbnail, plot)
        j = j + 1
    patronvideos = '<a href="(http://peliculasid.net/modulos/iframeplayer.php[^"]+)" target="[^"]+">([^<]+)</a>'
    #patronvideos2 = 'file=([^\&]+)\&'
    matches = re.compile(patronvideos, re.DOTALL).findall(data)
    if len(matches) > 0:
        urllists = ""
        for match in matches:
            if urllists == "":
                urllists = match[0]
            else:
                urllists = urllists + "|" + match[0]
            #data2 = scrapertools.downloadpageGzip(match[0])
            #matches2 = re.compile(patronvideos2,re.DOTALL).findall(data2)
            xbmctools.addnewvideo(CHANNELNAME, "play", category, "Directo",
                                  title + " - " + match[1], match[0],
                                  thumbnail, plot)
        xbmctools.addnewvideo(CHANNELNAME, "play", category, "Directo",
                              "(Reproducir todas las partes a la vez...)",
                              urllists, thumbnail, plot)
    ## --------------------------------------------------------------------------------------##
    #            Busca enlaces de videos para el servidor vkontakte.ru                        #
    ## --------------------------------------------------------------------------------------##
    #"http://vkontakte.ru/video_ext.php?oid=89710542&id=147003951&hash=28845bd3be717e11&hd=1
    '''
	var video_host = 'http://cs12916.vkontakte.ru/';
	var video_uid = '87155741';
	var video_vtag = 'fc697084d3';
	var video_no_flv = 1;
	var video_max_hd = '1'
	'''
    patronvideos = '<iframe src="(http://vk[^/]+/video_ext.php[^"]+)"'
    matches = re.compile(patronvideos, re.DOTALL).findall(data)
    if len(matches) > 0:
        print " encontro VKontakte.ru :%s" % matches[0]

        data2 = scrapertools.downloadpageGzip(matches[0])
        print data2
        patron = "var video_host = '([^']+)'.*?"
        patron += "var video_uid = '([^']+)'.*?"
        patron += "var video_vtag = '([^']+)'.*?"
        patron += "var video_no_flv = ([^;]+);.*?"
        patron += "var video_max_hd = '([^']+)'"
        matches2 = re.compile(patron, re.DOTALL).findall(data2)
        if len(
                matches2
        ) > 0:  #http://cs12385.vkontakte.ru/u88260894/video/d09802a95b.360.mp4
            for match in matches2:
                if match[3].strip() == "0":
                    tipo = "flv"
                    videourl = "%s/u%s/video/%s.%s" % (match[0], match[1],
                                                       match[2], tipo)
                    xbmctools.addnewvideo(
                        CHANNELNAME, "play", category, "Directo",
                        title + " - " + "[VKONTAKTE] [%s]" % tipo, videourl,
                        thumbnail, plot)
                else:
                    tipo = "360.mp4"
                    videourl = "%s/u%s/video/%s.%s" % (match[0], match[1],
                                                       match[2], tipo)
                    xbmctools.addnewvideo(
                        CHANNELNAME, "play", category, "Directo",
                        title + " - " + "[VKONTAKTE] [%s]" % tipo, videourl,
                        thumbnail, plot)
                    tipo = "240.mp4"
                    videourl = "%s/u%s/video/%s.%s" % (match[0], match[1],
                                                       match[2], tipo)
                    xbmctools.addnewvideo(
                        CHANNELNAME, "play", category, "Directo",
                        title + " - " + "[VKONTAKTE] [%s]" % tipo, videourl,
                        thumbnail, plot)

    patronvideos = '"(http://peliculasid.net/modulos/iframevk.php[^"]+)"'
    matches = re.compile(patronvideos, re.DOTALL).findall(data)
    if len(matches) > 0:
        print " encontro VKontakte.ru :%s" % matches[0]
        xbmctools.addnewvideo(CHANNELNAME, "play", category, "Directo",
                              title + " - [VKserver]", matches[0], thumbnail,
                              plot)

    patronvideos = '"(http://peliculasid.net/modulos/iframemv.php[^"]+)"'
    matches = re.compile(patronvideos, re.DOTALL).findall(data)
    if len(matches) > 0:
        print " encontro Megavideo :%s" % matches[0]
        xbmctools.addnewvideo(CHANNELNAME, "play", category, "Megavideo",
                              title + " - [Megavideo]", matches[0], thumbnail,
                              plot)
    # Label (top-right)...
    xbmcplugin.setPluginCategory(handle=pluginhandle, category=category)
    xbmcplugin.addSortMethod(handle=pluginhandle,
                             sortMethod=xbmcplugin.SORT_METHOD_NONE)
    xbmcplugin.endOfDirectory(handle=pluginhandle, succeeded=True)
def play(params,url,category):
	xbmc.output("[a3.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" )

	if url.startswith("rtmp"):
		# Playlist vacia
		playlist = xbmc.PlayList( xbmc.PLAYLIST_VIDEO )
		playlist.clear()

		'''
		C:\util\rtmpdump-2.2>rtmpdump.exe -V -r "rtmp://antena3tvfs.fplive.net/antena3tv/ps3/doctormateo/Mateo-Temp3-cap5-parte1.mp4" -o out.mp4
		RTMPDump v2.2
		(c) 2010 Andrej Stepanchuk, Howard Chu, The Flvstreamer Team; license: GPL
		DEBUG: Parsing...
		DEBUG: Parsed protocol: 0
		DEBUG: Parsed host    : antena3tvfs.fplive.net
		DEBUG: Parsed app     : antena3tv/ps3
		DEBUG: Protocol : RTMP
		DEBUG: Hostname : antena3tvfs.fplive.net
		DEBUG: Port     : 1935
		DEBUG: Playpath : mp4:doctormateo/Mateo-Temp3-cap5-parte1
		DEBUG: tcUrl    : rtmp://antena3tvfs.fplive.net:1935/antena3tv/ps3
		DEBUG: swfUrl   : (null)
		DEBUG: pageUrl  : (null)
		DEBUG: app      : antena3tv/ps3
		DEBUG: auth     : (null)
		DEBUG: subscribepath : (null)
		DEBUG: flashVer : WIN 10,0,22,87
		DEBUG: live     : no
		'''
		#url=rtmp://antena3tvfs.fplive.net/antena3tv/ps3/doctormateo/Mateo-Temp3-cap5-parte1.mp4
		hostname = "antena3tvfs.fplive.net"
		xbmc.output("[a3.py] hostname="+hostname)
		portnumber = "1935"
		xbmc.output("[a3.py] portnumber="+portnumber)
		tcurl = "rtmp://antena3tvfs.fplive.net/antena3tv/ps3"
		xbmc.output("[a3.py] tcurl="+tcurl)
		#playpath = "mp4:doctormateo/Mateo-Temp3-cap5-parte1"
		playpath = "mp4:"+url[44:-4]
		xbmc.output("[a3.py] playpath="+playpath)
		app = "antena3tv/ps3"
		xbmc.output("[a3.py] app="+app)
		
		listitem = xbmcgui.ListItem( title, iconImage="DefaultVideo.png", thumbnailImage=thumbnail )
		#listitem.setProperty("SWFPlayer", "http://www.plus.es/plustv/carcasa.swf")
		listitem.setProperty("Hostname",hostname)
		listitem.setProperty("Port",portnumber)
		listitem.setProperty("tcUrl",tcurl)
		listitem.setProperty("Playpath",playpath)
		listitem.setProperty("app",app)
		listitem.setProperty("flashVer","WIN 10,0,22,87")

		listitem.setInfo( "video", { "Title": title, "Plot" : plot , "Studio" : CHANNELNAME , "Genre" : category } )
		playlist.add( url, listitem )

		# Reproduce
		xbmcPlayer = xbmc.Player( xbmc.PLAYER_CORE_AUTO )
		xbmcPlayer.play(playlist)   
	elif url.startswith("http"):
		xbmctools.playvideo(CHANNELNAME,"Directo",url,category,title,thumbnail,plot)
	else:
		xbmctools.alertnodisponible()
def play(params,url,category):
	logger.info("[delatv.py] play")
	try:
		title = unicode( xbmc.getInfoLabel( "ListItem.Title" ), "utf-8" )
	except:
		title = urllib.unquote_plus( params.get("title") )
	thumbnail = urllib.unquote_plus( params.get("thumbnail") )
	plot = unicode( xbmc.getInfoLabel( "ListItem.Plot" ), "utf-8" )
	server = params.get("server")

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

	# Descarga la página del reproductor
	# http://delatv.com/modulos/player.php?url=dmlkZW8uYWsuZmFjZWJvb2suY29tL2Nmcy1hay1hc2gyLzMzMjM2LzY4NS8xMDU1NTcxNDYxNjI3MjNfMzQ5ODk=
	# http://delatv.com/modulos/embed/playerembed.php?url=dmlkZW8uYWsuZmFjZWJvb2suY29tL2Nmcy1hay1hc2gyLzMzMjM2LzY4NS8xMDU1NTcxNDYxNjI3MjNfMzQ5ODk=
	logger.info("[delatv.py] url="+url)
	
	## --------------------------------------------------------------------------------------##
	#            Busca enlaces de videos para el servidor vkontakte.ru                        #
	## --------------------------------------------------------------------------------------##
	#"http://vkontakte.ru/video_ext.php?oid=89710542&id=147003951&hash=28845bd3be717e11&hd=1
	
	
	if "vkontakteX.php" in url:
		data = scrapertools.cachePage(url)
		server = "Directo"
		'''
		var video_host = 'http://cs12916.vkontakte.ru/';
		var video_uid = '87155741';
		var video_vtag = 'fc697084d3';
		var video_no_flv = 1;
		var video_max_hd = '1'
		'''
		patronvideos = '<iframe src="(http://vk[^/]+/video_ext.php[^"]+)"'
		matches = re.compile(patronvideos,re.DOTALL).findall(data)
		if len(matches)>0:
			print " encontro VKontakte.ru :%s" %matches[0]
 		
			data2 = scrapertools.cachePage(matches[0])
			print data2
			patron  = "var video_host = '([^']+)'.*?"
			patron += "var video_uid = '([^']+)'.*?"
			patron += "var video_vtag = '([^']+)'.*?"
			patron += "var video_no_flv = ([^;]+);.*?"
			patron += "var video_max_hd = '([^']+)'"
			matches2 = re.compile(patron,re.DOTALL).findall(data2)
			if len(matches2)>0:    #http://cs12385.vkontakte.ru/u88260894/video/d09802a95b.360.mp4
				for match in matches2:
					if match[3].strip() == "0":
						tipo = "flv"
						url = "%su%s/video/%s.%s" % (match[0],match[1],match[2],tipo)
					
					else:
						tipo = "360.mp4"
						url = "%su%s/video/%s.%s" % (match[0],match[1],match[2],tipo)
						
	
	
	
	# Cierra dialogo
	dialogWait.close()
	del dialogWait

	if len(url)>0:
		
		logger.info("url="+url)
		xbmctools.playvideo(CHANNELNAME,server,url,category,title,thumbnail,plot)
	else:
		xbmctools.alertnodisponible()
def detail(params,url,category):
	xbmc.output("[peliculasid.py] detail")

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

	# Descarga la p�gina
	data = scrapertools.cachePage(url)
	#xbmc.output(data)
        patrondescrip = '<li class="description">(.*?)</li>'
        matches = re.compile(patrondescrip,re.DOTALL).findall(data)
        if DEBUG:
          if len(matches)>0:
		descripcion = matches[0]
                descripcion = descripcion.replace('&#8220;','"')
                descripcion = descripcion.replace('&#8221;','"')
                descripcion = descripcion.replace('&#8230;','...')
                descripcion = descripcion.replace("&nbsp;","")
		descripcion = descripcion.replace("<br/>","")
		descripcion = descripcion.replace("\r","")
		descripcion = descripcion.replace("\n"," ")
                descripcion = descripcion.replace("\t"," ")
		descripcion = re.sub("<[^>]+>"," ",descripcion)
#                xbmc.output("descripcion="+descripcion)
                descripcion = acentos(descripcion)
#                xbmc.output("descripcion="+descripcion)
                try :
                    plot = unicode( descripcion, "utf-8" ).encode("iso-8859-1")
                except:
                    plot = descripcion
	# ------------------------------------------------------------------------------------
	# Busca los enlaces a los videos
	# ------------------------------------------------------------------------------------
	#listavideos = servertools.findvideos(data)

	#for video in listavideos:
	#	videotitle = video[0]
	#	url = video[1]
	#	server = video[2]
	#	xbmctools.addnewvideo( CHANNELNAME , "play" , category , server , title.strip() + " - " + videotitle , url , thumbnail , plot )
	# ------------------------------------------------------------------------------------
        #--- Busca los videos Directos
        patronvideos = 'flashvars" value="file=([^\&]+)\&amp'
        matches = re.compile(patronvideos,re.DOTALL).findall(data)
        
        if len(matches)>0:
          if ("xml" in matches[0]):  
            #data = scrapertools.cachePage(matches[0])
            req = urllib2.Request(matches[0])
            try:
		response = urllib2.urlopen(req)
	    except:
                xbmctools.alertnodisponible()
                return
            data=response.read()
	    response.close()
            #xbmc.output("archivo xml :"+data)
            newpatron = '<title>([^<]+)</title>[^<]+<location>([^<]+)</location>'
            newmatches = re.compile(newpatron,re.DOTALL).findall(data)
            
            for match in newmatches:
              xbmc.output(" videos = "+match[1])
              if match[1].startswith("vid"):
				subtitle = match[0] + " (rtmpe) no funciona en xbmc"
              else:
				subtitle = match[0]
				
              xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title + " - "+subtitle, match[1] , thumbnail , plot )
                 
          else:
                xbmc.output(" matches = "+matches[0])
                xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title, matches[0] , thumbnail , plot )

	# 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 detail(params,url,category):
	logger.info("[peliculasid.py] detail")

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

	# Descarga la p�gina
	data = scrapertools.cachePage(url)
	#logger.info(data)
	patrondescrip = '<strong>Sinopsis:</strong><br />(.*?)</p>'
	matches = re.compile(patrondescrip,re.DOTALL).findall(data)
	
	if len(matches)>0:
		descripcion = matches[0]
		descripcion = descripcion.replace("<br/>","")
		descripcion = descripcion.replace("\r","")
		descripcion = descripcion.replace("\n"," ")
		descripcion = descripcion.replace("\t"," ")
		descripcion = re.sub("<[^>]+>"," ",descripcion)
		#logger.info("descripcion="+descripcion)
		descripcion = acentos(descripcion)
		#logger.info("descripcion="+descripcion)
		try :
			plot = unicode( descripcion, "utf-8" ).encode("iso-8859-1")
		except:
			plot = descripcion
		plot = scrapertools.unescape(plot.strip())
		#--- Busca los videos Directos
		patronvideos = 'flashvars" value="file=([^\&]+)\&amp'
		matches = re.compile(patronvideos,re.DOTALL).findall(data)
		
		if len(matches)>0:
			
			if ("xml" in matches[0]):  
				xbmctools.addnewvideo( CHANNELNAME , "play" , category , "xml" , "Reproducir todas las partes a la vez" , matches[0] , thumbnail , plot )
				#data = scrapertools.cachePage(matches[0])
				req = urllib2.Request(matches[0])
				try:
					response = urllib2.urlopen(req)
				except:
					xbmctools.alertnodisponible()
					return
				data=response.read()
				response.close()
				
					
			#logger.info("archivo xml :"+data)
				newpatron = '<title>([^<]+)</title>[^<]+<location>([^<]+)</location>'
				newmatches = re.compile(newpatron,re.DOTALL).findall(data)
				if len(newmatches)>0:
					for match in newmatches:
						logger.info(" videos = "+match[1])
						if match[1].startswith("vid"):
							subtitle = match[0] + " (rtmpe) no funciona en xbmc"
						else:
							subtitle = match[0]
				
						xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title + " - "+subtitle, match[1] , thumbnail , plot )
				 
			else:
				logger.info(" matches = "+matches[0])
				xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title, matches[0] , thumbnail , plot )


	# Ahora usa servertools
	listavideos = servertools.findvideos(data)

	j=1
	for video in listavideos:
		videotitle = video[0]
		url = video[1]
		server = video[2]
		xbmctools.addnewvideo( CHANNELNAME , "play" , category , server , (title.strip() + " (%d) " + videotitle) % j , url , thumbnail , plot )
		j=j+1
	patronvideos = '<a href="(http://peliculasid.net/modulos/iframeplayer.php[^"]+)" target="[^"]+">([^<]+)</a>'
	#patronvideos2 = 'file=([^\&]+)\&'
	matches = re.compile(patronvideos,re.DOTALL).findall(data)
	if len(matches)>0:
		urllists = ""
		for match in matches:
			if urllists == "":
				urllists = match[0]
			else:	
				urllists = urllists + "|" + match[0] 
			#data2 = scrapertools.cachePage(match[0])
			#matches2 = re.compile(patronvideos2,re.DOTALL).findall(data2)
			xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title+" - "+match[1], match[0] , thumbnail , plot )
		xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , "(Reproducir todas las partes a la vez...)", urllists , thumbnail , plot )
	## --------------------------------------------------------------------------------------##
	#            Busca enlaces de videos para el servidor vkontakte.ru                        #
	## --------------------------------------------------------------------------------------##
	#"http://vkontakte.ru/video_ext.php?oid=89710542&id=147003951&hash=28845bd3be717e11&hd=1
	'''
	var video_host = 'http://cs12916.vkontakte.ru/';
	var video_uid = '87155741';
	var video_vtag = 'fc697084d3';
	var video_no_flv = 1;
	var video_max_hd = '1'
	'''
	patronvideos = '<iframe src="(http://vk[^/]+/video_ext.php[^"]+)"'
	matches = re.compile(patronvideos,re.DOTALL).findall(data)
	if len(matches)>0:
		print " encontro VKontakte.ru :%s" %matches[0]
 		
		data2 = scrapertools.cachePage(matches[0])
		print data2
		patron  = "var video_host = '([^']+)'.*?"
		patron += "var video_uid = '([^']+)'.*?"
		patron += "var video_vtag = '([^']+)'.*?"
		patron += "var video_no_flv = ([^;]+);.*?"
		patron += "var video_max_hd = '([^']+)'"
		matches2 = re.compile(patron,re.DOTALL).findall(data2)
		if len(matches2)>0:    #http://cs12385.vkontakte.ru/u88260894/video/d09802a95b.360.mp4
			for match in matches2:
				if match[3].strip() == "0":
					tipo = "flv"
					videourl = "%s/u%s/video/%s.%s" % (match[0],match[1],match[2],tipo)
					xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title + " - "+"[VKONTAKTE] [%s]" %tipo, videourl , thumbnail , plot )
				else:
					tipo = "360.mp4"
					videourl = "%s/u%s/video/%s.%s" % (match[0],match[1],match[2],tipo)
					xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title + " - "+"[VKONTAKTE] [%s]" %tipo, videourl , thumbnail , plot )
					tipo = "240.mp4"
					videourl = "%s/u%s/video/%s.%s" % (match[0],match[1],match[2],tipo)
					xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title + " - "+"[VKONTAKTE] [%s]" %tipo, videourl , thumbnail , plot )
	
	patronvideos = '"(http://peliculasid.net/modulos/iframevk.php[^"]+)"'
	matches = re.compile(patronvideos,re.DOTALL).findall(data)
	if len(matches)>0:
		print " encontro VKontakte.ru :%s" %matches[0]	
		xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title+" - [VKserver]", matches[0] , thumbnail , plot )
		
	patronvideos = '"(http://peliculasid.net/modulos/iframemv.php[^"]+)"'
	matches = re.compile(patronvideos,re.DOTALL).findall(data)
	if len(matches)>0:
		print " encontro Megavideo :%s" %matches[0]	
		xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Megavideo" , title+" - [Megavideo]", matches[0] , thumbnail , plot )		
	# Label (top-right)...
	xbmcplugin.setPluginCategory( handle=pluginhandle, category=category )
	xbmcplugin.addSortMethod( handle=pluginhandle, sortMethod=xbmcplugin.SORT_METHOD_NONE )
	xbmcplugin.endOfDirectory( handle=pluginhandle, succeeded=True )
def detail(params,url,category):
	logger.info("[peliculasid.py] detail")

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

	# Descarga la p�gina
	data = scrapertools.cachePage(url)
	#logger.info(data)
        patrondescrip = '<strong>Sinopsis:</strong><br />(.*?)</p>'
        matches = re.compile(patrondescrip,re.DOTALL).findall(data)
        if DEBUG:
          if len(matches)>0:
		descripcion = matches[0]
                descripcion = descripcion.replace('&#8220;','"')
                descripcion = descripcion.replace('&#8221;','"')

                descripcion = descripcion.replace('&#8230;','...')
                descripcion = descripcion.replace('&#8217;',"'")
                descripcion = descripcion.replace("&nbsp;","")
		descripcion = descripcion.replace("<br/>","")
		descripcion = descripcion.replace("\r","")
		descripcion = descripcion.replace("\n"," ")
                descripcion = descripcion.replace("\t"," ")
		descripcion = re.sub("<[^>]+>"," ",descripcion)
#                logger.info("descripcion="+descripcion)
                descripcion = acentos(descripcion)
#                logger.info("descripcion="+descripcion)
                try :
                    plot = unicode( descripcion, "utf-8" ).encode("iso-8859-1")
                except:
                    plot = descripcion

        #--- Busca los videos Directos
        patronvideos = 'flashvars" value="file=([^\&]+)\&amp'
        matches = re.compile(patronvideos,re.DOTALL).findall(data)
        
        if len(matches)>0:
          if ("xml" in matches[0]):  
            #data = scrapertools.cachePage(matches[0])
            req = urllib2.Request(matches[0])
            try:
		response = urllib2.urlopen(req)
	    except:
                xbmctools.alertnodisponible()
                return
            data=response.read()
	    response.close()
            #logger.info("archivo xml :"+data)
            newpatron = '<title>([^<]+)</title>[^<]+<location>([^<]+)</location>'
            newmatches = re.compile(newpatron,re.DOTALL).findall(data)
            
            for match in newmatches:
              logger.info(" videos = "+match[1])
              if match[1].startswith("vid"):
				subtitle = match[0] + " (rtmpe) no funciona en xbmc"
              else:
				subtitle = match[0]
				
              xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title + " - "+subtitle, match[1] , thumbnail , plot )
                 
          else:
                logger.info(" matches = "+matches[0])
                xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , title, matches[0] , thumbnail , plot )


	# Ahora usa servertools
	listavideos = servertools.findvideos(data)

	j=1
	for video in listavideos:
		videotitle = video[0]
		url = video[1]
		server = video[2]
		xbmctools.addnewvideo( CHANNELNAME , "play" , category , server , (title.strip() + " (%d) " + videotitle) % j , url , thumbnail , plot )
		j=j+1

	# Carga los iframes
	#<a href="http://peliculasid.com/iframeplayer.php?url=aHR0cDovL3ZpZGVvLmFrLmZhY2Vib29rLmNvbS9jZnMtYWstc25jNC80MjIxNi82MS8xMjgxMTI4ODgxOTUwXzM5NTAwLm1wNA==" target="repro">Parte 1</a>
        patronvideos = '<a href="(http...peliculasid.com.iframeplayer[^"]+)"[^>]+>([^<]+)</a>'
        matches = re.compile(patronvideos,re.DOTALL).findall(data)

	for match in matches:
		scrapedtitle = match[1]
		scrapedurl = match[0]
		scrapedthumbnail = thumbnail
		scrapedplot = plot

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

	# Label (top-right)...
	xbmcplugin.setPluginCategory( handle=pluginhandle, category=category )
	xbmcplugin.addSortMethod( handle=pluginhandle, sortMethod=xbmcplugin.SORT_METHOD_NONE )
	xbmcplugin.endOfDirectory( handle=pluginhandle, succeeded=True )
def play(params,url,category):
	xbmc.output("[rtve.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"

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

	# Extrae el código
	#http://www.rtve.es/mediateca/videos/20100410/telediario-edicion/741525.shtml
	patron = 'http://.*?/([0-9]+).shtml'
	data = url
	matches = re.compile(patron,re.DOTALL).findall(data)
	scrapertools.printMatches(matches)
	codigo = matches[0]
	xbmc.output("idvideo="+codigo)

	try:
		# Compone la URL
		#http://www.rtve.es/swf/data/es/videos/alacarta/5/2/5/1/741525.xml
		url = 'http://www.rtve.es/swf/data/es/videos/alacarta/'+codigo[-1:]+'/'+codigo[-2:-1]+'/'+codigo[-3:-2]+'/'+codigo[-4:-3]+'/'+codigo+'.xml'
		xbmc.output("[rtvemediateca.py] url=#"+url+"#")

		# Descarga el XML y busca el vídeo
		#<file>rtmp://stream.rtve.es/stream/resources/alacarta/flv/6/9/1270911975696.flv</file>
		data = scrapertools.cachePage(url)
		patron = '<file>([^<]+)</file>'
		matches = re.compile(patron,re.DOTALL).findall(data)
		scrapertools.printMatches(matches)
		#url = matches[0].replace('rtmp://stream.rtve.es/stream/','http://www.rtve.es/')
		url = matches[0]
	except:
		url = ""
	
	# Hace un segundo intento
	if url=="":
		try:
			# Compone la URL
			#http://www.rtve.es/swf/data/es/videos/video/0/5/8/0/500850.xml
			url = 'http://www.rtve.es/swf/data/es/videos/video/'+codigo[-1:]+'/'+codigo[-2:-1]+'/'+codigo[-3:-2]+'/'+codigo[-4:-3]+'/'+codigo+'.xml'
			xbmc.output("[rtvemediateca.py] url=#"+url+"#")

			# Descarga el XML y busca el vídeo
			#<file>rtmp://stream.rtve.es/stream/resources/alacarta/flv/6/9/1270911975696.flv</file>
			data = scrapertools.cachePage(url)
			patron = '<file>([^<]+)</file>'
			matches = re.compile(patron,re.DOTALL).findall(data)
			scrapertools.printMatches(matches)
			#url = matches[0].replace('rtmp://stream.rtve.es/stream/','http://www.rtve.es/')
			url = matches[0]
		except:
			url = ""
		
	xbmc.output("[rtve.py] url="+url)

	# Cierra dialogo
	dialogWait.close()
	del dialogWait

	if url.startswith("rtmp"):
		# Playlist vacia
		playlist = xbmc.PlayList( xbmc.PLAYLIST_VIDEO )
		playlist.clear()

		'''
		flvstreamer  -r "rtmp://stream.rtve.es/stream/resources/alacarta/flv/5/3/1270074791935.flv" -o out.flv
		FLVStreamer v1.7
		(c) 2009 Andrej Stepanchuk, license: GPL
		DEBUG: Parsing...
		DEBUG: Parsed protocol: 0
		DEBUG: Parsed host    : stream.rtve.es
		DEBUG: Parsed app     : stream/resources
		DEBUG: Parsed playpath: alacarta/flv/5/3/1270074791935
		DEBUG: Setting buffer time to: 36000000ms
		Connecting ...
		DEBUG: Protocol : RTMP
		DEBUG: Hostname : stream.rtve.es
		DEBUG: Port     : 1935
		DEBUG: Playpath : alacarta/flv/5/3/1270074791935
		DEBUG: tcUrl    : rtmp://stream.rtve.es:1935/stream/resources
		DEBUG: app      : stream/resources
		DEBUG: flashVer : LNX 9,0,124,0
		DEBUG: live     : no
		DEBUG: timeout  : 300 sec
		DEBUG: Connect, ... connected, handshaking
		DEBUG: HandShake: Type Answer   : 03
		DEBUG: HandShake: Server Uptime : 1463582178
		DEBUG: HandShake: FMS Version   : 3.5.2.1
		DEBUG: Connect, handshaked
		Connected...
		'''
		#url=rtmp://stream.rtve.es/stream/resources/alacarta/flv/5/3/1270074791935.flv
		hostname = "stream.rtve.es"
		xbmc.output("[rtve.py] hostname="+hostname)
		portnumber = "1935"
		xbmc.output("[rtve.py] portnumber="+portnumber)
		tcurl = "rtmp://stream.rtve.es/stream/resources"
		xbmc.output("[rtve.py] tcurl="+tcurl)
		#playpath = "alacarta/flv/5/3/1270074791935"
		playpath = url[39:-4]
		xbmc.output("[rtve.py] playpath="+playpath)
		app = "stream/resources"
		xbmc.output("[rtve.py] app="+app)
		
		listitem = xbmcgui.ListItem( title, iconImage="DefaultVideo.png", thumbnailImage=thumbnail )
		#listitem.setProperty("SWFPlayer", "http://www.plus.es/plustv/carcasa.swf")
		listitem.setProperty("Hostname",hostname)
		listitem.setProperty("Port",portnumber)
		listitem.setProperty("tcUrl",tcurl)
		listitem.setProperty("Playpath",playpath)
		listitem.setProperty("app",app)
		listitem.setProperty("flashVer","LNX 9,0,124,0")
		listitem.setProperty("pageUrl","LNX 9,0,124,0")

		listitem.setInfo( "video", { "Title": title, "Plot" : plot , "Studio" : CHANNELNAME , "Genre" : category } )
		playlist.add( url, listitem )

		# Reproduce
		xbmcPlayer = xbmc.Player( xbmc.PLAYER_CORE_AUTO )
		xbmcPlayer.play(playlist)   
	elif url.startswith("http"):
		xbmctools.playvideo(CHANNELNAME,server,url,category,title,thumbnail,plot)
	else:
		xbmctools.alertnodisponible()