Beispiel #1
0
    def atresplayer_mobile(self):
        #stream = self.__get(self.url)
        stream = Descargar.get(self.url)
        episode = re.findall('episode="(.*)">', stream)[0]
        header = {"Accept":"application/json"}
        j = json.loads(Descargar.getHtmlHeaders("http://servicios.atresplayer.com/episode/get?episodePk="+episode, header=header))

        if j['type'] == "REGISTER":
            url = Utiles.url_fix(self.__getApiMobileUrl2(episode))
            #self.debug(unicode(url))
            #jj = json.loads(Descargar.getHtmlHeaders(Utiles.url_fix(url)))
            try:
                #url2down = jj['resultDes']
                url2down = url
            except:
                raise Error.GeneralPyspainTVsError(unicode(jj['resultDes']))
        elif j['type'] == "FREE": # TEMP FIX
            url = Utiles.url_fix(self.__getApiMobileUrl2(episode))
            try:
                url2down = url
            except:
                raise Error.GeneralPyspainTVsError(unicode(jj['resultDes']))
        else:
            url = Utiles.url_fix(self.__getApiMobileUrl(episode).replace("https://", "http://"))
            self.debug(unicode(url))
            #jj = json.loads(self.__get(Utiles.url_fix(url)))
            jj = json.loads(Descargar.get(Utiles.url_fix(url)))
            try:
                url2down = jj['resultObject']['es']
            except:
                raise Error.GeneralPyspainTVsError(unicode(jj['resultDes']))

            if url2down is None:
                raise Error.GeneralPyspainTVsError(u"[Atresplayer] No se han podido obtener enlaces para URL proporcionada")

            

        title = u"%s %s".encode('utf-8') % (j['titleSection'].encode('utf-8'), j['titleDetail'].encode('utf-8'))
        desc = unicode(j['seoDescription']).encode('utf-8')
        name = u"VideoAtresPlayer.mp4"
        img = j['urlImage'].replace(".jpg", "06.jpg")

        return {"exito" : True,
                "num_videos" : 1,
                "mensaje"   : u"URL obtenido correctamente",
                "videos":[{
                        "url_video" : [url2down] if type(url2down) != list else url2down,
                        "url_img"   : img if img is not None else None,
                        "filename"  : [name] if type(name) != list else name,
                        "tipo"      : "http",
                        "partes"    : 1 if type(url2down) != list else len(url2down),
                        "rtmpd_cmd" : None,
                        "menco_cmd" : None,
                        "url_publi" : None,
                        "otros"     : None,
                        "mensaje"   : None
                        }],
                "titulos": [title] if title is not None else None,
                "descs": [desc] if desc is not None else None
                }
    def atresplayer_mobile(self):
        #stream = self.__get(self.url)
        stream = Descargar.get(self.url)
        episode = re.findall('episode="(.*)">', stream)[0]
        header = {"Accept":"application/json"}
        j = json.loads(Descargar.getHtmlHeaders(self.URL_EPISODE_INFO+episode, header=header))

        url = Utiles.url_fix(self.__getApiMobileUrl(episode).replace("https://", "http://"))
        self.debug(unicode(url))
        #jj = json.loads(self.__get(Utiles.url_fix(url)))
        jj = json.loads(Descargar.get(Utiles.url_fix(url)))
        try:
            url2down = jj['resultObject']['es']
        except:
            raise Error.GeneralPyspainTVsError(unicode(jj['resultDes']))

        if url2down is None:
            raise Error.GeneralPyspainTVsError(u"[Atresplayer] No se han podido obtener enlaces para URL proporcionada")

        title = u"%s %s".encode('utf-8') % (j['titleSection'].encode('utf-8'), j['titleDetail'].encode('utf-8'))
        desc = unicode(j['seoDescription']).encode('utf-8')
        urlparsed = urlparse.urlparse(self.url)
        pathsplit = urlparsed.path.split('/')
        del pathsplit[:3]
        name = u'_'.join(pathsplit)
        name = name.replace('.html','.mp4')
        img = j['urlImage'].replace(".jpg", "06.jpg")

        return {"exito" : True,
                "num_videos" : 1,
                "mensaje"   : u"URL obtenido correctamente",
                "videos":[{
                        "url_video" : [url2down] if type(url2down) != list else url2down,
                        "url_img"   : img if img is not None else None,
                        "filename"  : [name] if type(name) != list else name,
                        "tipo"      : "http",
                        "partes"    : 1 if type(url2down) != list else len(url2down),
                        "rtmpd_cmd" : None,
                        "menco_cmd" : None,
                        "url_publi" : None,
                        "otros"     : None,
                        "mensaje"   : None
                        }],
                "titulos": [title] if title is not None else None,
                "descs": [desc] if desc is not None else None
                }
    def atresplayer(self):
        getEpisodeUrl = "http://servicios.atresplayer.com/episode/get?episodePk="
        locationHTTP2down = "desprogresiva.antena3.com/"
        # locationHTTP2down = "tcdn.desprogresiva.antena3.com/"
        locationRTMP2down = "a3premiumtkfs.fplive.net/"
        locationQ = "deswowa3player.antena3.com/"

        # Get episode info
        streamHTML = Descargar.get(self.url)
        episode = re.findall('episode="(.*)">', streamHTML)[0]
        header = {"Accept": "application/json"}
        j = json.loads(
            Descargar.getHtmlHeaders("http://servicios.atresplayer.com/episode/get?episodePk=" + episode, header=header)
        )
        # j = json.loads(self.__get("http://servicios.atresplayer.com/episode/get?episodePk="+episode))
        wowzaPath = j["wowzaPath"].replace("//", "/")

        # Flags
        isGeo = j["geolocked"]
        isRtmp = True if wowzaPath.find("a3player") != -1 else False

        hasOffline = True if j["offlineDownload"] else False
        hasHD = True if j["hd"] else False
        hasVO = True if j["vo"] else False
        hasDRM = True if j["drmEncrypted"] else False
        hasDrm = True if j["drm"] else False

        protocol = "rtmp" if isRtmp else "http"
        geo = "geo" if isGeo else ""
        sigra = "sigra" if j["sigra"] else "000"
        smil = "mp4" if j["sigra"] else "smil"
        playlist = sigra if j["sigra"] else "es"
        vsng = "vcg" if isGeo else "vsg"
        ext = "." + j["fileExtension"] if j.has_key("fileExtension") else ".mp4"
        assetsN = re.findall("a3player(.)\/", wowzaPath)[0] if isRtmp else re.findall("assets(.)\/", wowzaPath)[0]

        if isRtmp:
            if isGeo:
                wowzaPath = wowzaPath.replace("a3player%s/geo/" % assetsN, "assets%s/" % assetsN)
            else:
                wowzaPath = wowzaPath.replace("a3player%s/nogeo/" % assetsN, "assets%s/" % assetsN)
                wowzaPath = wowzaPath.replace("a3player%s/" % assetsN, "assets%s/" % assetsN)

            # rtmpd_cmd = "rtmpdump -r rtmp://%s%s%sa3premiumtk/%s/%s.mp4 -o %s" % (geo, locationRTMP2down, geo, wowzaPath, sigra, name)
            url2down = "http://%s%s%s%s%s" % (geo, locationHTTP2down, wowzaPath, sigra, ext)
            title = u"%s %s".encode("utf-8") % (j["titleSection"].encode("utf-8"), j["titleDetail"].encode("utf-8"))
            protocol = "http"
        else:
            # Obtener distintas calidades
            try:
                urlQ = "http://%s%s%s/_definst_/%s:%s%s.%s/playlist.m3u8" % (
                    geo,
                    locationQ,
                    vsng,
                    smil,
                    wowzaPath,
                    playlist,
                    smil,
                )
                Q = self.__getQ(urlQ)
            except:
                Q = [
                    ("600", "720x404"),
                    ("900", "720x404"),
                    ("1300", "720x404"),
                    ("1500", "1280x720"),
                    ("2225", "1280x720"),
                ]

            if len(Q) > 1:
                url2down = []
                title = []
                for q in Q:
                    w = "720" if not q[1] else q[1].split("x")[0]
                    ww = "720x404" if not q[1] else q[1]
                    k = q[0]
                    tmp = "http://%s%s%svideo_%s_%sk_es.mp4" % (
                        geo,
                        locationHTTP2down,
                        wowzaPath,
                        w,
                        k,
                    )  # TODO: include VO
                    url2down.append(tmp)
                    title.append(
                        u"%s %s [%s (%sk)]".encode("utf-8")
                        % (
                            j["titleSection"].encode("utf-8"),
                            j["titleDetail"].encode("utf-8"),
                            ww.encode("utf-8"),
                            k.encode("utf-8"),
                        )
                    )
            else:
                url2down = "http://%s%s%svideo_%s_%sk_es.mp4" % (
                    geo,
                    locationHTTP2down,
                    wowzaPath,
                    Q[1],
                    Q[0],
                )  # TODO: include VO
                title = u"%s %s [%s (%sk)]".encode("utf-8") % (
                    j["titleSection"].encode("utf-8"),
                    j["titleDetail"].encode("utf-8"),
                    Q[i][1].encode("utf-8"),
                    Q[i][0].encode("utf-8"),
                )

        desc = [unicode(j["seoDescription"]).encode("utf-8")] * len(url2down)
        name = u"VideoAtresPlayer.mp4"
        img = j["urlImage"].replace(".jpg", "06.jpg")

        url2down = [url2down] if type(url2down) is not list else url2down
        videos = []
        for i in range(len(url2down)):
            qString = (
                None
                if isRtmp
                else u"RESOLUTION: %s // BANDWIDTH: %s" % (Q[i][1].encode("utf-8"), Q[i][0].encode("utf-8")) or None
            )
            tmp = {
                "url_video": [url2down[i]],
                "url_img": img if img is not None else None,
                "filename": [name] if type(name) != list else name,
                "tipo": protocol,
                "partes": 1,
                "rtmpd_cmd": [rtmpd_cmd] if protocol == "rtmp" else None,
                "menco_cmd": None,
                "url_publi": None,
                "otros": qString or None,
                "mensaje": u"Puede que alguna calidad no esté disponible".encode("utf-8"),
            }
            videos.append(tmp)

        return {
            "exito": True,
            "num_videos": len(url2down),
            "mensaje": u"URL obtenido correctamente",
            "videos": videos,
            "titulos": [title] if type(title) != list else title,
            "descs": [desc] if type(desc) != list else title,
        }
    def atresplayer_mobile(self):
        # stream = self.__get(self.url)
        stream = Descargar.get(self.url)
        episode = re.findall('episode="(.*)">', stream)[0]
        header = {"Accept": "application/json"}
        self.debug("http://servicios.atresplayer.com/episode/get?episodePk=" + episode)
        j = json.loads(
            Descargar.getHtmlHeaders("http://servicios.atresplayer.com/episode/get?episodePk=" + episode, header=header)
        )

        if j["type"] == "FREE":
            url = Utiles.url_fix(self.__getApiMobileUrl2(episode))
            header = {"User-Agent": "Dalvik/1.6.0 (Linux; U; Android 4.3; GT-I9300 Build/JSS15J)"}
            data = json.loads(Descargar.getHtmlHeaders(url.replace("https://", "http://"), header=header))
            self.debug(u"DATA:\n%s" % data)
            try:
                url2down = data["resultObject"]["es"]
                if url2down is None:
                    raise Error.GeneralPyspainTVsError(u"No se ha podido obtener el enlace del vídeo")
                # url2down = url.replace("https://", "http://")
            except:
                raise Error.GeneralPyspainTVsError(unicode(jj["resultDes"]))
        else:
            if not self.opcs["a3user"] or not self.opcs["a3pass"]:
                raise Error.GeneralPyspainTVsError(
                    u"No tienes permisos para acceder al contenido. Proporciona tu usuario y contraseña para volver a intentarlo (en la web: botón de opciones arriba a la izquierda)."
                )
            cj = self.atresplayer_mobile_login(
                "http://servicios.atresplayer.com/j_spring_security_check",
                {"j_username": self.opcs["a3user"], "j_password": self.opcs["a3pass"]},
            )
            apiUrl = Utiles.url_fix(self.__getApiMobileUrl2(episode)).replace("https://", "http://")
            opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
            opener.addheaders = [
                ("Accept", "application/json"),
                ("User-Agent", "Dalvik/1.6.0 (Linux; U; Android 4.3; GT-I9300 Build/JSS15J"),
                ("Referer", "http://www.atresplayer.com/"),
            ]
            response = opener.open(apiUrl)
            content = json.loads(response.read())
            self.debug(u"CONTENT:\n%s" % content)
            url2down = content["resultObject"]["es"]
            if url2down is None:
                raise Error.GeneralPyspainTVsError(u"No se ha podido obtener el enlace del vídeo")
            if not url2down:
                raise Error.GeneralPyspainTVsError(unicode(content["resultDes"]))

        # if j['type'] == "REGISTER":
        #     url = Utiles.url_fix(self.__getApiMobileUrl2(episode))
        #     #header = {"User-Agent":"Dalvik/1.6.0 (Linux; U; Android 4.3; GT-I9300 Build/JSS15J)"}
        #     #data = json.loads(Descargar.getHtmlHeaders(url.replace("https://", "http://"), header=header))
        #     try:
        #         #url2down = data['resultObject']['es']
        #         url2down = url.replace("https://", "http://")
        #     except:
        #         raise Error.GeneralPyspainTVsError(unicode(jj['resultDes']))
        # elif j['type'] == "FREE": # TEMP FIX

        # else:
        #     url = Utiles.url_fix(self.__getApiMobileUrl2(episode).replace("https://", "http://"))
        #     self.debug(unicode(url))
        #     #jj = json.loads(self.__get(Utiles.url_fix(url)))
        #     jj = json.loads(Descargar.get(Utiles.url_fix(url)))
        #     try:
        #         url2down = jj['resultObject']['es']
        #     except:
        #         raise Error.GeneralPyspainTVsError(unicode(jj['resultDes']))

        #     if url2down is None:
        #         raise Error.GeneralPyspainTVsError(u"[Atresplayer] No se han podido obtener enlaces para URL proporcionada")

        title = u"%s %s".encode("utf-8") % (j["titleSection"].encode("utf-8"), j["titleDetail"].encode("utf-8"))
        desc = unicode(j["seoDescription"]).encode("utf-8")
        name = u"VideoAtresPlayer.mp4"
        img = j["urlImage"].replace(".jpg", "06.jpg")

        return {
            "exito": True,
            "num_videos": 1,
            "mensaje": u"URL obtenido correctamente",
            "videos": [
                {
                    "url_video": [url2down] if type(url2down) != list else url2down,
                    "url_img": img if img is not None else None,
                    "filename": [name] if type(name) != list else name,
                    "tipo": "http",
                    "partes": 1 if type(url2down) != list else len(url2down),
                    "rtmpd_cmd": None,
                    "menco_cmd": None,
                    "url_publi": None,
                    "otros": None,
                    "mensaje": None,
                }
            ],
            "titulos": [title] if title is not None else None,
            "descs": [desc] if desc is not None else None,
        }
Beispiel #5
0
    def getInfo(self):
        '''
            Devuelve toda la información asociada a la URL recibida, de la siguiente forma:
            {
             "exito"     : bool,  <-- True (si se han obtenido videos)
             "num_video" : int,   <-- Número de vídeos obtenidos
             "mensaje"   : u"" ,  <-- Mensajes de la API (ej.: El vídeo no ha sido encontrado ["exito": False])
             "videos"    :  [{
                            "url_video" : [],   <-- Url de descarga de vídeo
                            "url_img"   : "",   <-- Url de la miniatura del video
                            "filename"  : [],   <-- Nombre de las partes para guardar en disco
                            "tipo"      : "",   <-- http, rtmp[e,..], mms, ...
                            "partes"    : int,  <-- Número de partes que tiene el vídeo
                            "rtmpd_cmd" : [],   <-- Comando rtmpdump (si tipo == rtmp) sino None
                            "menco_cmd" : [],   <-- Comando mencoder (Si tipo == rtmp) sino None
                            "url_publi" : "",   <-- Url del vídeo de publicidad asociado al vídeo
                            "otros"     : [],   <-- Lista donde se pueden pasar cosas opcionales
                            "mensaje"   : ""    <-- Mensajes de la API
                            }], <-- Debe ser una lista de tamaño "num_videos"
             "titulos"   : [u""], <-- Titulos de los videos
             "descs"     : [u""] <-- Descripción de cada vídeo
            }
            
            Los valores que no se rellenen, deberán devolver None.
            La clave "exito" es obligatoria, sino se puede encontrar el vídeo se puede devolver directamente:
            {
            "exito": False,
            "mensaje": "No se pudo descargar el video"  
            }
            
            "videos", "mesajes" y "descs" deben ser listas de cadenas (si no son None)
            "url_video", "filename", "rtmp_cmd", "menco_cmd" (de "videos") deben ser listas de cadenas (si no son None)
        '''
        #TODO: Cuida con las paginas que tiene más de un vídeo. De momento funciona porque es el primer video que aparece!
        
        # Primero: nos quedamos con le id dependiendo si el user metio la url con
        # una barra (/) final o no y si tiene extensión (no es alacarta)
        logging.debug(self.url)
        
        videoID = self.url.split('/')[-1]
        if videoID == "":
            videoID = self.url.split('/')[-2]
        elif videoID.find(".shtml") != -1 or videoID.find(".html") != -1 or \
            videoID.find(".html") != -1:
            videoID = videoID.split('.')[0]
        
        if not videoID.isdigit(): videoID = self.getID(self.url)
            
        try: self.debug(u"ID del vídeo en url = " + videoID)
        except: pass
        #if self.url.find("rtve.es/infantil/") != -1: self.url = self.url.replace("/#","") # Vídeos de Clan a veces falla con el ancla
        
        # Añadido para vídeos nuevos (periodo de prueba):
        sourceHTML = Descargar.getHtml(self.url).decode('string-escape')
        #sourceHTML = self.toUtf(sourceHTML)
        videoID_comp = None
        if sourceHTML.find("flashcontentId:\'videoplayer") != -1:
            videoID_comp = sourceHTML.split("flashcontentId:\'videoplayer")[1].split("\'")[0]
            if videoID_comp != videoID: videoID = videoID_comp
        if sourceHTML.find("<div id=\"video") != -1:
            videoID_comp = sourceHTML.split("<div id=\"video")[1].split("\"")[0]
            if videoID_comp != videoID and videoID_comp.isdigit(): videoID = videoID_comp
        ########################################################
        
        self.debug(u"ID del vídeo en HTML = " + videoID_comp if videoID_comp else "No ID en HTML")
        self.log(u"[INFO] ID del Vídeo :", videoID)
        
        if videoID is None: raise Error.GeneralPyspainTVsError(u"No se encuentra el ID del vídeo")
        
        if self.url.find("rtve.es/infantil/") != -1:
            return self.__ClanTV(sourceHTML, videoID)

        # -- Método 24 Mayo 2013
        self.debug(u"Probando método de 24 de uno de Mayo de 2013")
        try: manager = re.findall('data-idManager="(.*?)"', sourceHTML)[0]
        except:
            try: manager = re.findall('idManager="(.*?)"', sourceHTML)[0]
            except: manager = "default"

        # # Nuevo método (22/02/14) , dejo el actual que todavía funciona
        # if sourceHTML.find("themadvideo.com/player/js/MadVideo.js.php") != -1:
            
        #     themadvideo_id = re.findall('<iframe.*id\=\"visor(.*)\"' , sourceHTML)[0]
        #     xmldata = Descargar.get("http://studio.themadvideo.com/api/videos/%s/player_data" % themadvideo_id).decode('utf8')
        #     xmltree = xml.etree.ElementTree.fromstring(xmldata)

        #     urlVideo = xmltree.find('./Layout/VideoPlayer/Data/src').text
        #     url_img = xmltree.find('./Layout/VideoPlayer/Data/Keyframe').text
        #     titulo = xmltree.find('.').attrib['title']
        #     try: name = Utiles.formatearNombre(titulo) + ".mp4"
        #     except: name = "VideoRtve.mp4"
        #     desc = None
        
        tipo = "videos"
        url = "http://www.rtve.es/ztnr/movil/thumbnail/%s/%s/%s.png" % (manager, tipo, videoID)

        self.debug(u"Probando url:", url)
        try:
            tmp_ = decode(Descargar.getHtmlHeaders(url, {"Referer": "http://www.rtve.es"}))
            tmp = re.findall(".*tEXt(.*)#[\x00]*([0-9]*).*", tmp_)[0]
            tmp = [n for n in tmp]
            cyphertext = tmp[0]
            key = tmp[1]
            tmp = tmp = [0 for n in range(500)]

            # Créditos para: http://sgcg.es/articulos/2012/09/11/nuevos-cambios-en-el-mecanismo-para-descargar-contenido-multimedia-de-rtve-es-2/
            intermediate_cyphertext = ""
            increment = 1
            text_index = 0
            while text_index < len(cyphertext):
                text_index = text_index + increment
                try: intermediate_cyphertext = intermediate_cyphertext + cyphertext[text_index-1]
                except: pass
                increment = increment + 1
                if increment == 5: increment = 1

            plaintext = ""
            key_index = 0
            increment = 4
            while key_index < len(key):
                key_index = key_index + 1
                text_index = int(key[key_index-1]) * 10
                key_index = key_index + increment
                try: text_index = text_index + int(key[key_index-1])
                except: pass
                text_index = text_index + 1
                increment = increment + 1
                if increment == 5: increment = 1
                plaintext = plaintext + intermediate_cyphertext[text_index-1]
                #try: plaintext = plaintext + intermediate_cyphertext[text_index-1]
                #except: pass
            urlVideo = plaintext
        except:
             ads  = "6037182945"
             str1 = "51%s-" % videoID
             inverted_str1 = str1[::-1]
             s = "".join([ads[int(n)] for n in inverted_str1[1:]])
             url  = "http://ztnr.rtve.es/ztnr/pub/%s/%s/%s/%s/%s" % (s[0],s[1],s[2],s[3],s)
             self.debug(u"Probando url:", url)
             xmldata = Descargar.doPOST("www.pydowntv.com", "/utils/cnR2ZV9yYW5kb21fNA/", {"encrypted":Descargar.get(url)})
             self.debug(xmldata.replace(xmldata[xmldata.find("</quality>")+10:],""))

             try:
                 xmltree = xml.etree.ElementTree.fromstring(xmldata.replace(xmldata[xmldata.find("</quality>")+10:],""))
                 for node in xmltree.findall("./preset"):
                     if node.attrib.get('type') == "Alta":
                         for url in node.findall("./response/url"):
                             if url.attrib.get('provider') == "AKAMAI_STR-1030":
                                 urlVideo = url.text
             except:
                 urlVideo = re.findall("<url.*>(.*)</url>", xmldata)[0]



        
        if urlVideo != "":
            if not urlVideo.endswith(".mp4"): urlVideo = urlVideo.replace(urlVideo.split(".mp4")[1], "")
            url_video = urlVideo.replace("www.rtve.es", "media5.rtve.es").replace("iphonelive","mvod")
            
            titulo = sourceHTML.split("<title>")[1].split("</")[0].replace("RTVE.es", "").replace("-", "").strip()
            filename = titulo + ".mp4"
            filename = Utiles.formatearNombre(filename)

            try: url_img = sourceHTML.split("\"thumbnail\" content=\"")[1].split("\"")[0]
            except:
                try: url_img = re.findall('<link.*rel\=\"image_src\".*href\=\"(.*)\"' , sourceHTML)[0]
                except: url_img = re.findall('<meta.*name\=\"RTVE\.thumb_video\".*content\=\"(.*)\"',sourceHTML)[0]
        else:
            raise Error.GeneralPyspainTVsError("No se pudo encontrar el enlace de descarga")

        #TEMP FIX:
        #url_video = url_video.replace(url_video.split(".")[1], url_video.split(".")[1][:3])

        # -- Método 24 Mayo 2013 FIN
        
        desc = None
        try: #obtener descripción del video
            desc = Utiles.recortar(sourceHTML, "<meta itemprop=\"description\" content=\"", "\"").strip()
        except:
            try:
                desc = Utiles.recortar(sourceHTML, "<meta property=\"og:description\" content=\"", "\"").strip()
            except:
                try:
                    desc = Utiles.recortar(sourceHTML, "<meta name=\"description\" content=\"", "\"").strip()
                except:
                    desc = u"Vídeos de Televión Española"
        
        # Comprobar si existe calidad FLV
        url_flv = url_video.replace("mp4", "flv")
        if Descargar.isReachableHead(url_flv):
            msgCalidad = u'''Este vídeo dispone de dos calidades. 
            Para los vídeos de RTVE, la mejor suele ser la que se presenta en formato FLV. 
            En los vídeos con más tiempo puede que el audio al principio no esté bien sincronizado 
            con el audio. Este problema será menos grave en el formato FLV llegándose incluso a 
            sincronizar totalmente pasados unos segundos.'''.encode('utf8')

            return {"exito" : True,
                    "num_videos" : 2,
                    "mensaje"   : u"URL obtenido correctamente",
                    "videos":[{
                            "url_video" : [url_video],
                            "url_img"   : url_img,
                            "filename"  : [filename],
                            "tipo"      : "http",
                            "partes"    : 1,
                            "rtmpd_cmd" : None,
                            "menco_cmd" : None,
                            "url_publi" : None,
                            "otros"     : "MP4",
                            "mensaje"   : msgCalidad
                            },
                            {
                            "url_video" : [url_flv],
                            "url_img"   : url_img,
                            "filename"  : [filename.replace(".mp4", ".flv")],
                            "tipo"      : "http",
                            "partes"    : 1,
                            "rtmpd_cmd" : None,
                            "menco_cmd" : None,
                            "url_publi" : None,
                            "otros"     : "FLV",
                            "mensaje"   : msgCalidad
                            }],
                    "titulos": [titulo,titulo],
                    "descs": [desc, desc]
                    }
        else:
            return {"exito" : True,
                    "num_videos" : 1,
                    "mensaje"   : u"URL obtenido correctamente",
                    "videos":[{
                            "url_video" : [url_video],
                            "url_img"   : url_img,
                            "filename"  : [filename],
                            "tipo"      : "http",
                            "partes"    : 1,
                            "rtmpd_cmd" : None,
                            "menco_cmd" : None,
                            "url_publi" : None,
                            "otros"     : None,
                            "mensaje"   : None
                            }],
                    "titulos": [titulo],
                    "descs": [desc] if desc is not None else None
                    }