def play(params,url,category):
    logger.info("[pelispekes.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://pelispekes.com/modulos/player.php?url=dmlkZW8uYWsuZmFjZWJvb2suY29tL2Nmcy1hay1hc2gyLzMzMjM2LzY4NS8xMDU1NTcxNDYxNjI3MjNfMzQ5ODk=
    # http://pelispekes.com/modulos/embed/playerembed.php?url=dmlkZW8uYWsuZmFjZWJvb2suY29tL2Nmcy1hay1hc2gyLzMzMjM2LzY4NS8xMDU1NTcxNDYxNjI3MjNfMzQ5ODk=
    logger.info("[pelispekes.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]
            url =     vk.geturl(matches[0])
            
    
    # 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("[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 pv°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)
    
    patronvideos1  = 'http://www.peliculasyonkis.com/go/(d)/(.+?)".*?alt="([^"]+)"'
    patronvideos1 += "(.+?)<br /></span></div></td>"
    matches1 = re.compile(patronvideos1,re.DOTALL).findall(data)
    if (len(matches1) > 0):
        for j in matches1:
            matches.append(j)
    
    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 scrapvideoURL(urlSY):
    data = scrapertools.cachePage(urlSY)
    patronvideos  = 'href="http://www.seriesyonkis.com/go/(mv)\/([^"]+)".*?alt="([^"]+)".*?'
    patronvideos += '<td><div[^>]+><[^>]+>[^<]+</span></div></td>[^<]+<td><div[^>]+><[^>]+>[^<]+</span></div></td>[^<]+'
    patronvideos += '<td><div[^>]+><[^>]+>(.*?)</tr>'
    matches = re.compile(patronvideos,re.DOTALL).findall(data)
    
    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>'
    matches0 = re.compile(patronvideos,re.DOTALL).findall(data)
    matches = matches + matches0
    patronvideos1  = 'http://www.seriesyonkis.com/go/(d)/(.+?)".*?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:
        if  matches[0][0] == "d":
            player = "descargar"
            url = "http://www.seriesyonkis.com/go/%s/%s" % (matches[0][0],matches[0][1])
            id = getId(url)
        elif matches[0][0] == "mv":
            player = "pymeno2"
            url = "http://www.seriesyonkis.com/go/%s/%s" % (matches[0][0],matches[0][1])
            id = getId(url)
        else:
            player = matches[0][0]
            id = matches[0][1]
        server = SERVER[player]
        #print matches[0][1]
        if player == "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 player 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))
        
        elif player == "descargar":
            cortar = matches[0][1].split("&")
            id = cortar[0]
            logger.info("[seriesyonkis.py]  id="+id)
            dec = Yonkis.DecryptYonkis()
            id = dec.ccM(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