function calcula() { $enlace = array(); //&file=media/53/Video/10/1/10107_BAJA.mp4& //file $file = entre1y2($this->web_descargada, 'file=', '&'); //image=http://mediateca.regmurcia.com/MediatecaCRM/ServletLink?METHOD=MEDIATECA%26accion=imagen%26id=10107 $p = strrposF($file, '/'); $f = strpos($file, '_', $p); $imagen = 'http://mediateca.regmurcia.com/MediatecaCRM/ServletLink?METHOD=MEDIATECA&accion=imagen&id=' . substr($file, $p, $f - $p); //&title=Metros cuadrados& $titulo = utf8_encode(entre1y2($this->web_descargada, '&title=', '&')); $titulo = limpiaTitulo($titulo); //&description=Programa nº 62. $descripcion = utf8_encode(entre1y2($this->web_descargada, '&description=', "'")); $descripcion = limpiaTitulo($descripcion, 300); $obtenido = array('titulo' => $titulo, 'imagen' => $imagen, 'descripcion' => $descripcion, 'enlaces' => array()); //server $server = entre1y2($this->web_descargada, 'streamer=', '&'); $tipo = "http"; if (enString($server, 'rtmp')) { $server = substr($server, 0, strrpos($server, '/')); $file = 'mp4:' . $file; $obtenido['enlaces'][] = array('url' => '-', 'rtmpdump' => '-r "' . $server . '" -y "' . $file . '"', 'nombre_archivo' => generaNombreWindowsValido($titulo . '.mp4'), 'tipo' => 'rtmpConcreto'); } elseif (enString($server, 'http')) { $obtenido['enlaces'][] = array('url' => $server . '/' . $file, 'tipo' => 'http'); } finalCadena($obtenido, true); }
function URLSDelArrayBrightCove($r, $tipo, &$obtenido_enlaces, $titulo) { if ($r["audioOnly"] != "1") { if ($tipo === 'rtmpConcreto') { $_r = substr($r["defaultURL"], 0, strpos($r["defaultURL"], 'mp4')); $_r = substr($_r, 0, strrposF($_r, '/')); $_y = 'mp4' . entre1y2($r["defaultURL"], 'mp4', '?'); $_ry = substr($r["defaultURL"], strpos($r["defaultURL"], '?')); dbug_($_r); dbug_($_y); dbug_($_ry); $elem = array('calidad_ordenar' => $r["encodingRate"], 'url' => $r["defaultURL"], 'tipo' => $tipo, 'rtmpdump' => '-r "' . $_r . $_ry . '" -y "' . $_y . $_ry . '" -o "' . $titulo . '.mp4"'); if ($r["encodingRate"] != 0) { $elem['titulo'] = 'Calidad: ' . floor($r["encodingRate"] / 1000) . " Kbps"; } $obtenido_enlaces[] = $elem; } else { $elem = array('calidad_ordenar' => $r["encodingRate"], 'url' => $r["defaultURL"], 'tipo' => $tipo); if ($r["encodingRate"] != 0) { $elem['titulo'] = 'Calidad: ' . floor($r["encodingRate"] / 1000) . " Kbps"; } $obtenido_enlaces[] = $elem; } } }
function emp3world() { global $web; $res = CargaWebCurl('http://www.emp3world.com/r.php?submit=Search&phrase=' . urlencode($web)); //recortar a solo los enlaces $p = strposF($res, '<div id="results_box">'); $f = strpos($res, 'id="right_box"', $p); $res = substr($res, $p, $f - $p); $resultados = array('buscador' => 'emp3world.com', 'enlaces' => array()); $p1 = 0; for ($i = 0; $i < 10 && ($p1 = strpos($res, 'class="song_item"', $p1)); $i++) { $p1++; //título $p = strposF($res, '<span id="song_title">', $p1); $f = strpos($res, '</span', $p); $tit = trim(strtr(substr($res, $p, $f - $p) . "@@", array("mp3@@" => ""))); //url $p = strposF($res, 'class="play_link"', $p1); $f = strpos($res, "</div", $p); $url = substr($res, $p, $f - $p); $p = strrposF($url, '<a href="'); $f = strpos($url, '"', $p); $url = substr($url, $p, $f - $p); //peso $p = strposF($res, 'class="song_size">', $p1); $f = strpos($res, "</div", $p); $peso = substr($res, $p, $f - $p); $peso = trim(strtr($peso, array("MB" => ""))); $r = array('url' => $url, 'titulo' => $tit, 'peso' => $peso, 'preview' => 1); $resultados['enlaces'][] = $r; } dbug_r($resultados); return $resultados; }
function calcula() { //title: "Matalobos quotAno 1 A familiaquot", $titulo = entre1y2($this->web_descargada, '<title>', '<'); if (enString($titulo, ' |')) { $titulo = entre1y2($titulo, 0, ' |'); } $titulo = limpiaTitulo($titulo); dbug('titulo=' . $titulo); if (enString($this->web_descargada, "id=\$(this).attr('id').split('|');")) { dbug('modo 1'); preg_match("#url:.*?'(.*?)',#i", $this->web_descargada, $matches); dbug_r($matches); $url = $matches[1]; if ($url[0] === '/') { $url = 'http://www.crtvg.es' . $url; } else { if ($url[0] !== 'h') { $url = substr($this->web, 0, strrposF($this->web, '/')) . $url; } } dbug_r($url); preg_match_all("#<div class='cap' id='([0-9]+?)\\|([0-9]+?)'>#", $this->web_descargada, $matches); dbug_r($matches); $obtenido = array('titulo' => $titulo, 'imagen' => '/canales/tvg.jpg', 'enlaces' => array()); for ($i = 0, $i_t = count($matches[0]); $i < $i_t; $i++) { $ret = CargaWebCurl($url, 'idSerie=' . $matches[1][$i] . '&idCapitulo=' . $matches[2][$i]); //dbug_($ret); $tit = entre1y2($ret, '<div id="titulo">', '</div'); $tit = strip_tags($tit); $this->parsefragment($obtenido['enlaces'], $ret, $tit, true); } } else { dbug('modo 2'); //backgroundImage: "url(http://www.crtvg.es/files/web/000020120911000003.jpg)" if (enString($this->web_descargada, 'backgroundImage:')) { $p = strpos($this->web_descargada, 'backgroundImage:'); $imagen = entre1y2_a($this->web_descargada, $p, 'url(', ')'); } else { $imagen = entre1y2($this->web_descargada, '"playlist":[{"url":"', '"'); $imagen = str_replace('\\', '', $imagen); } dbug('imagen=' . $imagen); $obtenido = array('titulo' => $titulo, 'imagen' => $imagen, 'enlaces' => array()); $this->parsefragment($obtenido['enlaces'], $this->web_descargada, $titulo); } finalCadena($obtenido); }
function calcula() { $retfull = CargaWebCurlProxy($this->web, 'ESP'); //titulo //<meta property="og:title" content="Alaska y Mario Episodio Extra - Pierrot"/> $p = strpos($retfull, 'og:title'); $titulo = entre1y2_a($retfull, $p, 'content="', '"'); $titulo = limpiaTitulo($titulo); dbug('titulo=' . $titulo); //imagen //<meta property="og:image" content="http://....jpg?height=106&quality=0.91"/> $p = strpos($retfull, 'og:image'); $imagen = entre1y2_a($retfull, $p, 'content="', '?'); if (enString($imagen, 'mtvnimages.com')) { $imagen = $imagen . '?height=180&quality=1'; } else { $imagen = substr($imagen, 0, strpos($imagen, '"')); } if ($imagen == '' || enString($imagen, '<')) { $imagen = entre1y2($retfull, 'rel="image_src" href="', '"'); } dbug('imagen=' . $imagen); //vid:"786779", $id = entre1y2($retfull, 'vid:"', '"'); dbug('id=' . $id); //http://intl.esperanto.mtvi.com/www/xml/media/mediaGen.jhtml?uri=mgid:uma:video:mtv.es:747606 $url = 'http://intl.esperanto.mtvi.com/www/xml/media/mediaGen.jhtml?uri=mgid:uma:video:mtv.es:' . $id; dbug('url=' . $url); $ret = CargaWebCurlProxy($url, 'ESP'); dbug($ret); //Por situación geográfica del servidor (supongo) da error. Usar pydowntv :( if (!enString($ret, 'copyright_error.flv')) { $extracto = entre1y2($ret, '<rendition', '<beacons>'); dbug('extracto=' . $extracto); $p = strrposF($extracto, '<src>'); $f = strpos($extracto, '<', $p); $url = substr($extracto, $p, $f - $p); } else { dbug('Usando pydowntv'); $ret = CargaWebCurl('http://www.pydowntv.com/api?url=' . $this->web); dbug($ret); $url = entre1y2($ret, '"url_video": ["', '"'); } $obtenido = array('titulo' => $titulo, 'imagen' => $imagen, 'enlaces' => array(array('url' => $url, 'rtmpdump' => '-r "' . $url . '" -o "' . generaNombreWindowsValido($titulo) . '.' . (enString($url, '.mp4') ? 'mp4' : 'flv') . '"', 'tipo' => 'rtmpConcreto'))); finalCadena($obtenido); }
function calcula() { //mirar si hay video $obtenido = array(); if (!enString($this->web_descargada, '_w320.jpg')) { return; } $p = strpos($this->web_descargada, 'og:image'); $imagen = entre1y2_a($this->web_descargada, $p, 'content="', '"'); dbug('imagen=' . $imagen); $id = entre1y2($imagen, strrposF($imagen, '/'), "_w320.jpg"); dbug('id=' . $id); // Problemas con geobloqueo. //$ret=CargaWebCurl(urldecode(entre1y2($this->web_descargada, "'file': '", "'"))); //$ret=CargaWebCurl('http://www.adnstream.com/get_playlist.php?lista=video¶m='.$id); $ret = CargaWebCurl('http://proxyanonimo.es/browse.php?u=' . urlencode('http://www.adnstream.com/get_playlist.php?lista=video¶m=' . $id) . '&b=12&f=norefer', '', 0, '', array('Referer: http://proxyanonimo.es/')); dbug_($ret); $titulo = entre1y2($ret, '<title>', '<'); $titulo = limpiaTitulo($titulo); dbug('titulo=' . $titulo); $descripcion = entre1y2($ret, '<description>', '<'); dbug('descripcion=' . $descripcion); if (enString($ret, 'hd.file>')) { $ret = entre1y2($ret, 'hd.file>', '<'); } elseif (enString($ret, 'file>')) { $ret = entre1y2($ret, 'file>', '<'); } else { $p = strpos($ret, 'http://'); $f = strpos($ret, '<', $p); $ret = substr($ret, $p, $f - $p); } if (enString($ret, '.flv')) { $ret = substr($ret, 0, strrposF($ret, '/')) . $id . '.H264-480p.mp4'; $ret = 'http://176.31.233.154' . substr($ret, strpos($ret, '/', 10)); } $obtenido = array('titulo' => $titulo, 'imagen' => $imagen, 'descripcion' => $descripcion, 'enlaces' => array(array('url' => $ret, 'tipo' => 'http'))); finalCadena($obtenido); return $obtenido; }
function calcula() { $obtenido = array('enlaces' => array()); $pageId = substr($this->web, strrposF($this->web, '/')); dbug_($pageId); if (preg_match('#"pageId":"' . $pageId . '".+?"urls":\\[(.+?)[,\\]]#', $this->web_descargada, $matches)) { $jsonurl = $matches[1]; } else { setErrorWebIntera('No se ha encontrado ningún vídeo.'); return; } dbug_($jsonurl); $jsonurl = json_decode($jsonurl, true); dbug_($jsonurl); $json = CargaWebCurl($jsonurl); dbug_($json); $json2 = json_decode($json, true); $titulo = $json2['title']; // http://www.arucitys.com.usrfiles.com/html/5eb649_d2c495cc1c5e09ffcb959aa180074c3d.html $html = desde1a2($json, '"html/', '"', true); $html = json_decode($html, true); $html = 'http://www.arucitys.com.usrfiles.com/' . $html; dbug_($html); $html = CargaWebCurl($html); dbug_($html); $app_flash = trim(entre1y2($html, 'app_flash=', '&')); dbug_($app_flash); $ubicacion_fichero = trim(entre1y2($html, 'ubicacion_fichero=', '&')); dbug_($ubicacion_fichero); $rtmpbase = 'rtmp://178.33.166.26/' . $app_flash; $rtmp = $rtmpbase . '/mp4:' . $ubicacion_fichero; $obtenido['enlaces'] = array(array('url' => $rtmp, 'rtmpdump' => '-r "' . $rtmpbase . '" -y "' . $ubicacion_fichero . '" -o "' . generaNombreWindowsValido($titulo) . '.mp4"', 'url_txt' => 'Descargar', 'tipo' => 'rtmpConcreto')); $obtenido['titulo'] = $titulo; $obtenido['imagen'] = $imagen; finalCadena($obtenido, false); }
function univisionID($id) { dbug('univisionID'); $ret = 'http://cdn-download.mcm.univision.com/videos_mcm/' . $id . '.js'; dbug('url=' . $ret); $ret = CargaWebCurl($ret); if (enString($ret, "Access Denied")) { setErrorWebIntera("El vídeo de Univisión está bloqueado."); return; } $obtenido = array('enlaces' => array()); //imagen $imagen = entre1y2($ret, '"src_image_url":"', '"'); $imagen = strtr($imagen, array('\\' => '')); dbug('imagen=' . $imagen); //titulo $titulo = entre1y2($ret, '"def_title":"', '"'); $titulo = jsonRemoveUnicodeSequences($titulo); $titulo = limpiaTitulo($titulo); dbug('titulo=' . $titulo); if (!enString($ret, '"published_urls":[]')) { dbug('No aparece "published_urls":[]'); $json = substr($ret, strposF($ret, '(')); $json = substr($json, 0, strrpos($json, ')')); dbug_($json); $json = json_decode($json, true); dbug_r($json); $urls = array(); if (isset($json['published_urls'])) { foreach ($json['published_urls'] as &$url) { if (enString($url['embed_url'], '.mp4')) { $u =& $url['embed_url']; dbug_($u); $p = strrposF($u, '_'); $f = strpos($u, '.', $p); $calidad = substr($u, $p, $f - $p); $urls[] = array($u, $calidad); } } } dbug('urls: ' . count($urls)); //ya tenemos las urls en formato: /120615_2708697_El_Talisman_Capitulo_98_99___Ultimo_capitulo_1339800465_2000.mp4 //ordenar if (count($urls) > 0) { $urls = sortmulti($urls, 1, "123", true); } } if (enString($ret, '"published_urls":[]') || isset($urls) && count($urls) === 0) { dbug('No se pueden encontrar urls. Usando método 2'); // http://vmscdn-download.s3.amazonaws.com/videos_mcm/variant/2912557.m3u8 $m3u8FuenteUrls = 'http://vmscdn-download.s3.amazonaws.com/videos_mcm/variant/' . $id . '.m3u8'; dbug('$m3u8FuenteUrls = ' . $m3u8FuenteUrls); $m3u8FuenteUrls = CargaWebCurl($m3u8FuenteUrls); dbug($m3u8FuenteUrls); preg_match('@http://.*media(.*?)_[0-9]{3,4}.m3u8@', $m3u8FuenteUrls, $matches); dbug_r($matches); $urlBase = $matches[1]; $calidades = array(2000, 1200, 810, 800, 510, 500, 270, 150); $urls = array(); foreach ($calidades as $calidad) { $urlT = 'http://h.univision.com/media' . $urlBase . '_' . $calidad . '.mp4'; $urls[] = array($urlT, $calidad); } //ya tenemos las urls en formato: /120615_2708697_El_Talisman_Capitulo_98_99___Ultimo_capitulo_1339800465_2000.mp4 //ya está ordenado } $urls_length = count($urls); for ($i = 0; $i < $urls_length; $i++) { if ($urls[$i][1] == 2000) { $preContext = array('http' => array('method' => 'HEAD', 'header' => "User-agent: Mozilla/5.0 (Windows NT 6.1; rv:11.0) Gecko/20100101 Firefox/11.0\r\n" . "Connection: close\r\n" . "Accept-Language: es-ES,es;en-US;en\r\n" . "Accept: text/html,application/xhtml+xml,application/xml\r\n", 'timeout' => 5, 'ignore_errors' => '1')); $preContext = stream_context_create($preContext); if (file_get_contents($urls[$i][0], false, $preContext) === false) { dbug('no se puede abrir la url de calidad 2000'); continue; } dbug_r($http_response_header); if (strpos($http_response_header[0], ' 404 ')) { dbug('la url de calidad 2000 da 404'); continue; } } if (esVideoAudioAnon($urls[$i][0])) { $obtenido['enlaces'][] = array('url' => $urls[$i][0], 'url_txt' => 'Calidad: ' . $urls[$i][1] . " Kbps", 'tipo' => 'http'); } } for ($i = 0, $ii = count($json['captions']); $i < $ii; $i++) { if ($json['captions'][$i]['language'] === 'es') { $url = $json['captions'][$i]['url']; $obtenido['enlaces'][] = array('url_txt' => 'Subtítulos en formato ' . substr($url, strrposF($url, '.')), 'url' => $url, 'tipo' => 'srt'); } } $obtenido['titulo'] = $titulo; $obtenido['imagen'] = $imagen; $obtenido['alerta_especifica'] = 'Si no puedes descargar el vídeo necesitas usar proxy.<br/>Descarga el programa ultrasurf (<a href="https://ultrasurf.us/download/u.zip">Descargar ultrasurf</a>), descomprime el archivo, ejecuta el programa y una vez hecho intenta descargar el vídeo de nuevo.<br/>Si 2000kbps da error prueba 1200kbps.'; finalCadena($obtenido, false); }
function calcula() { dbug('empezando RTVE'); //si no se pone / al final de un enlace que lo necesita, se arma parda. aplicar la / en caso de que se necesite. /*$p=strrpos($this->web,"/"); if($p!=strlen($this->web)-1){ $analisis=substr($this->web,$p); if(!enString($analisis,".")) $this->web.='/'; }*/ //modo audio //modo infantil //modo alacarta if (enString($this->web, '/audios/')) { dbug('modo audio'); //$retfull=CargaWebCurl($this->web); $audio = 1; } elseif (enString($this->web, '/infantil/')) { dbug('modo infantil'); if (strposF($this->web, '/todos') + 2 > strlen($this->web) || !strpos($this->web, '/', strposF($this->web, '/todos') + 2)) { $web2 = strtr($this->web, array('/#' => '')); $enlaceInfantil = substr($web2, strpos($web2, '/infantil/')); dbug('$enlaceInfantil = ' . $enlaceInfantil); if (enString($this->web_descargada, $enlaceInfantil)) { preg_match('@(TE_[A-Z]+).*?' . $enlaceInfantil . '@', $this->web_descargada, $matches); dbug_r($matches); $pre_asset = $matches[1]; dbug('pre_asset=' . $pre_asset); $pre_asset = 'http://www.rtve.es/infantil/components/' . $pre_asset . '/videos/videos-1.inc'; $pre_asset = CargaWebCurl($pre_asset); preg_match('@/([0-9]+?)/@', $pre_asset, $matches); dbug_r($matches); $asset = $matches[1]; dbug('asset=' . $asset); /* $titulo = entre1y2($pre_asset, 'title="', '"'); dbug('$titulo='.$titulo); $imagen = entre1y2($pre_asset, '<img src="', '"'); dbug('$imagen='.$imagen); */ } } else { $p = strrposF($this->web, "/", strrposF($this->web, "/") - 2 - strlen($this->web)); $f = strpos($this->web, "/", $p); $asset = substr($this->web, $p, $f - $p); dbug('asset=' . $asset); if (!is_numeric($asset)) { $preIDURL = entre1y2($this->web_descargada, "/#/", '"'); dbug('preIDURL=' . $preIDURL); $p = strpos($preIDURL, "/", strlen($preIDURL) - 12); $asset = entre1y2_a($preIDURL, $p, "/", "/"); dbug('asset=' . $asset); } } } else { dbug('modo normal'); //$retfull=CargaWebCurl($this->web); //assetID=974036_ $asset = $this->encuentraAssetEnContenido($this->web_descargada); } //audio if (isset($audio)) { dbug('audio'); //file:'/resources/TE_SENTREN/mp3/0/3/1329728190030.mp3' //obtener url (boton descargar en pagina) $p = strpos($this->web_descargada, 'class="download"'); $p = strpos($this->web_descargada, 'href="', $p) + 6; $f = strpos($this->web_descargada, '"', $p); $ret = substr($this->web_descargada, $p, $f - $p); if (!enString($ret, 'http://') || $ret[0] === '/') { $ret = 'http://www.rtve.es' . $ret; } if (enString($ret, '.mp3')) { dbug('El mp3 estaba en la web'); } else { dbug('toca sacar el audio por metodo nuevo'); //$ret=assetdataid $p = strposF($this->web_descargada, 'data-assetID="'); $f = strpos($this->web_descargada, '_', $p); $asset = substr($this->web_descargada, $p, $f - $p); $ret = $this->convierteID($asset, array('audio', 'video')); if ($ret === false) { return; } } dbug('ret=' . $ret); } else { $ret = $this->convierteID($asset); if ($ret === false) { return; } dbug('ret=' . $ret); } if (isset($asset)) { //titulo $opciones = array("videos", "audios"); $sigue = 0; $opciones_length = count($opciones); for ($i = 0; $i < $opciones_length && !$sigue; $i++) { $urlmedia = 'http://www.rtve.es/api/' . $opciones[$i] . '/' . $asset . '/config/mmedia.json'; dbug('urlmedia=' . $urlmedia); $retmedia = CargaWebCurl($urlmedia); if (!enString($retmedia, "no existir") && !enString($retmedia, "Informe de Error") && strlen($retmedia) > 0) { $sigue = 1; } } if ($sigue) { $sustituir = array('\\"' => "'"); $retmedia = strtr($retmedia, $sustituir); $p = strpos($retmedia, '"title":"') + 9; $f = strpos($retmedia, '"', $p); $titulo = substr($retmedia, $p, $f - $p); $titulo = limpiaTitulo($titulo); //imagen if (enString($retmedia, '"image":null')) { $imagen = 'http://www.' . DOMINIO . '/canales/rtve.png'; dbug('imagen null'); } else { $p = strpos($retmedia, '"image":"') + 9; $f = strpos($retmedia, '"', $p); $imagen = substr($retmedia, $p, $f - $p); } } else { $titulo = "RTVE"; $imagen = 'http://www.' . DOMINIO . '/canales/rtve.png'; } } else { //titulo if (enString($this->web_descargada, '<meta name="audio_title" content="')) { $titulo = entre1y2($this->web_descargada, '<meta name="audio_title" content="', '"'); $imagen = entre1y2($this->web_descargada, '<link rel="image_src" href="', '"'); } else { $p = strpos($this->web_descargada, 'class="header"'); $p = strpos($this->web_descargada, 'titu', $p); $p = strposF($this->web_descargada, '>', $p); $f = strpos($this->web_descargada, '<', $p); $titulo = substr($this->web_descargada, $p, $f - $p); $titulo = limpiaTitulo($titulo); //imagen $p = strpos($this->web_descargada, 'imgPrograma'); $p = strposF($this->web_descargada, 'src="', $p); $f = strpos($this->web_descargada, '"', $p); $imagen = substr($this->web_descargada, $p, $f - $p); } } dbug('titulo=' . $titulo); dbug('imagen=' . $imagen); $obtenido = array('titulo' => $titulo, 'imagen' => $imagen, 'enlaces' => array(array('url' => $ret, 'tipo' => 'http', 'url_txt' => 'Descargar'))); if (isset($asset)) { // Buscar subtítulos. Tienen extensión .vtt $subs = CargaWebCurl('http://www.rtve.es/api/videos/' . $asset . '/subtitulos.json'); $subs = json_decode($subs, true); dbug_r($subs); if (isset($subs['page']['items'][0])) { foreach ($subs['page']['items'] as $subtitle) { $obtenido['enlaces'][] = array('url' => $subtitle['src'], 'tipo' => 'srt', 'url_txt' => 'Descargar subtítulos (' . $subtitle['lang'] . ')'); } dbug('Agregados subtítulos (' . $subtitle['lang'] . ')'); } } $obtenido['alerta_especifica'] = 'Si no funciona el enlace intenta descargarlo de nuevo dentro de varios minutos.'; finalCadena($obtenido, false); }
function calcula() { $obtenido = array('enlaces' => array()); //http://www.canalsuralacarta.es/television/video/presenta-enrique-romero/7718/44 //video no admitido if (enString($this->web_descargada, "_url_xml_datos")) { dbug("_url_xml_datos encontrado"); //<param name="flashVars" value="_width=630&_height=354&_url_xml_datos=http://www.canalsuralacarta.es/webservice/video/7718" /> //flashVars="_width=630&_height=354&_url_xml_datos=" $p = strrposF($this->web_descargada, '_url_xml_datos='); $f = strpos($this->web_descargada, '"', $p); $xml = substr($this->web_descargada, $p, $f - $p); dbug("xml=" . $xml); //http://www.canalsuralacarta.es/webservice/video/7718 $titulo = entre1y2($this->web_descargada, '<title>', '<'); if (enString($titulo, ' ::')) { $titulo = substr($titulo, 0, strpos($titulo, ' ::')); } //$titulo=utf8_encode($titulo); $titulo = limpiaTitulo($titulo); dbug('titulo=' . $titulo); $ret = CargaWebCurl($xml); //imagen //<archivoMultimediaMaxi><archivo>clipping/2012/02/08/00127/30.jpg</archivo><alt></alt></archivoMultimediaMaxi> $imagen = entre1y2($ret, '<picture>', '</'); dbug('imagen=' . $imagen); if (enString($imagen, '1pxtrans.gif')) { $imagen = 'http://www.' . DOMINIO . '/canales/canalsur.png'; } //<video type="content"> //</video> $p = strpos($ret, '<video type="content">'); $ret = substr($ret, $p); preg_match_all('#<url>([^\\[]*?)</url>#', $ret, $matches); dbug_r($matches[1]); dbug('total videos=' . count($matches[1])); switch (count($matches[1])) { case 0: setErrorWebIntera("No se encuentra ningún vídeo"); return; break; case 1: $obtenido['enlaces'][] = array('url' => $matches[1][0], 'tipo' => 'http', 'url_txt' => 'Descargar'); break; default: for ($i = 0, $i_t = count($matches[1]); $i < $i_t; $i++) { $obtenido['enlaces'][] = array('url' => $matches[1][$i], 'tipo' => 'http', 'url_txt' => 'parte ' . ($i + 1)); } break; } //<url>http://ondemand.rtva.ondemand.flumotion.com/rtva/ondemand/flash8/programas/toros-para-todos/20110921122144-7-toros-para-todos-245--domingo.flv</url> //http://ondemand.rtva.ondemand.flumotion.com/rtva/ondemand/mp4-web/programas/andalucia-directo/54134_1_6110.mp4 } elseif (enString($this->web_descargada, "var elementos = [];")) { dbug('var elementos = [];'); $ret = utf8_encode($this->web_descargada); $ret = strtr($ret, array('\\"' => "'")); $videos = substr_count($ret, 'elementos.push'); dbug('total videos=' . $videos); $last = strpos($ret, "elementos.push"); $imagen = "http://www.canalsur.es/" . entre1y2_a($ret, $last, '"urlPrevia": "', '"'); if ($videos > 1) { $titulo = "Canal Sur"; for ($i = 0; $i < $videos; $i++) { $obtenido['enlaces'][$i] = array('url' => entre1y2_a($ret, $last, '"url": "', '"'), 'tipo' => 'http', 'url_txt' => entre1y2_a($ret, $last, '"pie": "', '"')); $last = strpos($ret, "});", $last) + 1; } } else { $titulo = entre1y2_a($ret, $last, '"pie": "', '",'); $obtenido['enlaces'][$i] = array('url' => entre1y2_a($ret, $last, '"url": "', '"'), 'tipo' => 'http'); } } else { dbug('último case ifelse'); $titulo = utf8_encode(entre1y2($this->web_descargada, '<title>', '<')); if (enString($this->web_descargada, "og:image")) { $p = strpos($this->web_descargada, "og:image"); $imagen = entre1y2_a($this->web_descargada, 'content="', '"'); } else { $imagen = 'http://www.' . DOMINIO . '/canales/canalsur.png'; } preg_match("@http://[^ ]*?\\.(?:mp4|flv)@i", $this->web_descargada, $matches); $url = $matches[0]; $obtenido['enlaces'][] = array('url' => $url, 'tipo' => 'http'); } $obtenido['titulo'] = $titulo; $obtenido['imagen'] = $imagen; finalCadena($obtenido, 0); }
function resuelveIDMetodo2($id, &$enlaces_array, &$titulo, &$imagen, $ignoraCaducados = false) { //http://www.tv3.cat/pvideo/FLV_bbd_media.jsp?ID=4048670&QUALITY=H&FORMAT=MP4 $server2 = 'http://www.tv3.cat/pvideo/FLV_bbd_dadesItem.jsp?idint=' . $id; dbug('server2=' . $server2); $ret = CargaWebCurl($server2); dbug('obtenido=' . $ret); if (enString($ret, '<title>')) { //rectificar titulo dbug('rectificar titulo'); //<h1>Amb Fidel, passi el que passi</h1> $titulo = entre1y2($ret, '<title>', '</'); $titulo = utf8_encode($titulo); $titulo = limpiaTitulo($titulo); dbug('nuevo titulo=' . $titulo); } //<format>MP4GES</format> //PARA VIDEOS LIMITADOS //http://www.tv3.cat/pvideo/FLV_bbd_media.jsp?ID=3932951&QUALITY=H&FORMAT=MP4GES if (enString($ret, '<imgsrc>') && !isset($imagen)) { $p = strrposF($ret, '<imgsrc>'); $f = strrpos($ret, '</imgsrc>', $p); $imagen = substr($ret, $p, $f - $p); } $formato = 'MP4'; if (enString($ret, '<format>')) { //ENCUENTRA EL PRIMERO EN LA LISTA; NO EL MEJOR dbug('formato encontrado'); $p = strrposF($ret, '<format>'); $f = strrpos($ret, '</format>', $p); $formato = substr($ret, $p, $f - $p); } $server3 = 'http://www.tv3.cat/pvideo/FLV_bbd_media.jsp?' . 'ID=' . $id . '&QUALITY=H&FORMAT=' . $formato; dbug('server3=' . $server3); $server4 = 'http://www.tv3.cat/pvideo/FLV_bbd_media.jsp?' . 'ID=' . $id . '&QUALITY=H&PROFILE=APPMOB&FORMAT=' . $formato; dbug('server4=' . $server4); $ret = CargaWebCurl($server4); dbug('obtenido='); dbug_($ret); if (enString($ret, 'err.service.expired')) { if (!$ignoraCaducados) { setErrorWebIntera('El vídeo fue borrado de TV3'); } return; } elseif (enString($ret, '<media')) { //a sacer el video. si falla la busqueda, entonces hay un error //<media videoname="La Costa Brava en caiac/Thalassa/13042012/BB_THALASS"> //http://mp4-medium-dwn.media.tv3.cat/g/tvcatalunya/0/2/1394113435120.mp4 //</media> $p = strrpos($ret, '<media'); $ret = entre1y2_a($ret, $p, '>', '<'); if (enString($ret, 'mp4:') || enString($ret, 'http://')) { dbug('urlFinal=' . $ret); if (strpos($ret, 'rtmp://') === 0) { $ret = preg_replace('@rtmp://.*?mp4:(.*?)$@', 'http://mp4-medium-dwn.media.tv3.cat/$1', $ret); dbug('urlFinal (mediante preg replace=' . $ret); } $enlaces_array[] = array('titulo' => 'Calidad media', 'url' => $ret, 'tipo' => 'http'); } } $ret = CargaWebCurl($server3); dbug('obtenido='); dbug_($ret); if (enString($ret, '<media')) { //http://www.tv3.cat/feeds/videos/fitxaVideo.jsp?id=4874451&device=and-h&format=xml&version=1 //a sacer el video. si falla la busqueda, entonces hay un error //<media videoname="La Costa Brava en caiac/Thalassa/13042012/BB_THALASS"> //rtmp://mp4-500-str.tv3.cat/ondemand/mp4:g/tvcatalunya/2/2/1334322726322.mp4 //</media> $p = strrpos($ret, '<media'); $ret = entre1y2_a($ret, $p, '>', '<'); if (enString($ret, 'mp4:')) { preg_match('@^(.*?/)(mp4:.*?)$@', $ret, $matches); dbug_r($matches); // 4/09/2012 metodo rectificado dbug('urlFinal=' . $ret); $enlaces_array[] = array('titulo' => 'Calidad alta', 'url' => $ret, 'rtmpdump' => '-r "' . $matches[1] . '" -y "' . $matches[2] . '" -o "' . generaNombreWindowsValido($titulo) . '.mp4"', 'tipo' => 'rtmpConcreto', 'extension' => 'mp4'); } else { // 2/06/2014 dbug('urlFinal=' . $ret); $ext = substr($ret, -3, 3); $enlaces_array[] = array('url' => $ret, 'rtmpdump' => '-r "' . $ret . '" -o "' . generaNombreWindowsValido($titulo) . '.' . $ext . '"', 'tipo' => 'rtmpConcreto', 'extension' => '.' . $ext); } } }
function parseaXMLNormal($url, &$xml_ret, $modo = 'normal') { dbug('parseaXMLNormal'); dbug('xml=' . $url); $xml = CargaWebCurl($url); if ($xml_ret === '') { dbug('xml_ret (url)=' . $url); $xml_ret = $xml; } $netStorage = false; if (enString($xml, '<NetStorage><![CDATA[')) { $ret2 = entre1y2($xml, '<NetStorage><![CDATA[', ']'); $netStorage = true; } else { $ret2 = entre1y2($xml, '<urlHttpVideo><![CDATA[', ']'); } //fix para evitar geobloqueo. $ret2 = strtr($ret2, array('geodesprogresiva' => 'desprogresiva')); $p = strpos($xml, '<archivoMultimedia>'); $ret = entre1y2_a($xml, $p, '<archivo><![CDATA[', ']'); //$ret contiene el primer enlace. usandolo podemos saber si hay mas enlaces. //sacamos la extension de $ret y suponiendo que todas las partes tienen la misma extension //buscamos la existencia del mismo principio y aseguramos con el mismo final $extension = substr($ret, strposF($ret, '.')); dbug('extensión: ' . $extension); if ($extension === 'f4v') { dbug('Tiene DRM (ext === f4v). No usar resultado.'); return array(); } $f = strrposF($ret, '/', 0); $baselimpia = substr($ret, 0, $f); $lastpos = $total = 0; $i = 1; $obtenidoT = array(); while ($total == 0) { $p = strpos($xml, '<archivoMultimedia>', $lastpos) + 3; $lastpos = $f = strpos($xml, 'archivoMultimedia', $p); $rettemp = substr($xml, $p, $f - $p); if ($netStorage) { $temp = $ret2 . entre1y2($rettemp, '<archivoNetStorage><![CDATA[', ']'); } else { $temp = $ret2 . entre1y2($rettemp, '<archivo><![CDATA[', ']'); } if (enString($temp, $extension)) { if ($modo == 'multi') { $urltxt = entre1y2($xml, '<nombre><![CDATA[', ']'); if (stringContains($urltxt, array('<', '>'))) { //<title>CarreraBarhein1 </title> $urltxt = entre1y2($xml, '<title>', '<'); } $urltxt = limpiaTitulo($urltxt); } else { $urltxt = 'parte ' . $i; } dbug('url encontrada: ' . $temp); $obtenidoT[] = array('url' => $temp, 'tipo' => 'http', 'url_txt' => $urltxt); } else { $total = $i; } $i++; } $retornar = array(); if (count($obtenidoT) > 1) { $retornar[] = array('titulo' => 'En partes:'); foreach ($obtenidoT as $individual) { $retornar[] = $individual; } //añadir la versión del vídeo completa. Gracias a doriape@gmail.com, creador de www.elbarco.tk y www.elbarcoxml.tk $retornar[] = array('titulo' => 'Completo:', 'url' => 'rtmp://antena3tvfs.fplive.net/antena3mediateca/' . $baselimpia . '000.' . $extension, 'tipo' => 'rtmp'); } else { if ($modo === 'normal') { unset($obtenidoT[0]['url_txt']); } foreach ($obtenidoT as $elem) { $retornar[] = $elem; } } return $retornar; }