Extracción y Carga Directa de URL de Video desde Respuesta JSON

  • Autor Autor Armandolqr
  • Fecha de inicio Fecha de inicio
Armandolqr

Armandolqr

Gamma
Verificado por Whatsapp
¡Usuario con pocos negocios! ¡Utiliza siempre saldo de Forobeta!
https://api.filelions.com/api/file/direct_link?key=895bvq8x2cvnmt2bih6&file_code=5lnhh4j4noaf
este link da esta respuesta
{"server_time":"2023-06-10 18:01:55","msg":"OK","result":{"file_length":5367,"player_img":"https://lions-img.xyz/5lnhh4j4noaf.jpg","file_name":"Anaconda","versions":[{"size":2539674937,"url":" ","name":"o"}]},"status":200}
lo que quiero es usar la seccion url que trae. que cargue directamente ese link y que no traiga lo demas algo como un fetch
lo que quiero que traiga directamente esta marcado en negrita
 
https://api.filelions.com/api/file/direct_link?key=895bvq8x2cvnmt2bih6&file_code=5lnhh4j4noaf
este link da esta respuesta
{"server_time":"2023-06-10 18:01:55","msg":"OK","result":{"file_length":5367,"player_img":"https://lions-img.xyz/5lnhh4j4noaf.jpg","file_name":"Anaconda","versions":[{"size":2539674937,"url":" ","name":"o"}]},"status":200}
lo que quiero es usar la seccion url que trae. que cargue directamente ese link y que no traiga lo demas algo como un fetch
lo que quiero que traiga directamente esta marcado en negrita
Serial algo asi...
PHP:
<?php

$url = 'https://api.filelions.com/api/file/direct_link?key=895bvq8x2cvnmt2bih6&file_code=5lnhh4j4noaf';

$get = file_get_contents($url);
$json = json_decode($get, true);

echo $json['result']['versions'][0]['url'];

?>
 
no trae nada
 
pusiste el 0 y trajo ya
 
pusiste el 0 y trajo ya
Si, de nada bro.

PHP:
<?php

function curl_url($url){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_REFERER, 'https://google.com');
    
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36');
    
    $resp = curl_exec($ch);
    curl_close($ch);
    return $resp;
}

$url = 'https://api.filelions.com/api/file/direct_link?key=895bvq8x2cvnmt2bih6&file_code=5lnhh4j4noaf';

$get = curl_url($url);
$json = json_decode($get, true);

echo $json['result']['versions'][0]['url'];

?>
 
solo faltaria redirigir
 
solo faltaria redirigir
PHP:
<?php

function curl_url($url){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_REFERER, 'https://google.com');
    
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36');
    
    $resp = curl_exec($ch);
    curl_close($ch);
    return $resp;
}

$url = 'https://api.filelions.com/api/file/direct_link?key=895bvq8x2cvnmt2bih6&file_code=5lnhh4j4noaf';

$get = curl_url($url);
$json = json_decode($get, true);

if(!empty($json['result']['versions'][0]['url'])){
    
    $video_url = $json['result']['versions'][0]['url'];
    header('Location: '.$video_url);
    
}

?>
 
nice bro te agradezco
 
y como traigo la calidad 1080p ahora bro me renderiza a multiples calidades y solo me descarga la 480p
 
{"server_time":"2023-06-16 17:07:05","msg":"OK","status":200,"result":{"player_img":"https://sw-cdn-images.com/f7dnlu387vi1.jpg","file_length":6166,"versions":[{"url":"https://xbnvn96ecelj.sw-cdnstream.com/v/01/00375/tjadpmnlftn4_n/Un.Año.Inolvidable-.Otoño.2023.1080P-Dual-Lat_n.mp4?t=jMJm5ucfcL38EQ5qQn6P3f2cd7mO8w8FOSYR-keKL7w&s=1686935225&e=129600&f=1984139&sp=300&i=0.0","name":"n","size":702971867},{"size":1354161727,"url":"https://xbnvn96ecelj.sw-cdnstream.com/v/01/00375/tjadpmnlftn4_h/Un.Año.Inolvidable-.Otoño.2023.1080P-Dual-Lat_h.mp4?t=rnLE3NSXlBuqlTFvFC38y8TbbeuFJ6oRzPNalQ4LZtY&s=1686935225&e=129600&f=1984139&sp=600&i=0.0","name":"h"},{"size":1796209765,"name":"x","url":"https://xbnvn96ecelj.sw-cdnstream.com/v/01/00375/tjadpmnlftn4_x/Un.Año.Inolvidable-.Otoño.2023.1080P-Dual-Lat_x.mp4?t=_-gxynccc2y2EweML-A8m8BFMPWe8JhubId25tHMzzw&s=1686935225&e=129600&f=1984139&sp=1000&i=0.0"}],"file_name":"Un.Año.Inolvidable-.Otoño.2023.1080P-Dual-Lat"}}
 
GET https://api.streamwish.com/api/file/direct_link?key=450fhvveofkpzts8b&file_code={file_code}
PARAMETERS

NameDescriptionExampleFormatRequired
keyAPI key450fhvveofkpzts8bSTRING
file_codeFile codefb5asfuj2snhSTRING
qVideo quality if available. Possible values: n , h , l, onSTRING
hlsGenerate HLS manifest URL (HLS mod required)1INT
RESPONSE{
"msg":"OK",
"server_time":"2021-08-14 05:32:27",
"status":200,
"result":
{
"versions":[
{"url":"http://s1.xvs.tt/zqsccwdttqsal2eyd2pjrlvodgh7iyejldkogrnzwypvlnajbosxsuchfurq/v.mp4","name":"n","size":"120755726"},
{"url":"http://s1.xvs.tt/zqsccwdttqsal2eyd2pjrlvodgh7iyejldkogrnzwapvlnajbostzwskpx4a/v.mp4","name":"h","size":"135481436"},
{"url":"http://s1.xvs.tt/zqsccwdttqsal2eyd2pjrlvodgh7iyejldkogrnzwqpvlnajbosrpvmuh5la/v.mp4","name":"l","size":"34744877"},
{"url":"http://s1.xvs.tt/zqsccwdttqsal2eyd2pjrlvodgh7iyejldkogrnzw4pvlnajbosyx264xtsq/v.mp4","name":"o","size":"319256576"}
],
"file_length":"1560",
"player_img":"http://img.xvs.tt/abnormamorph.jpg",
"hls_direct":"http://s1.xvs.tt/hls/zqsccwdttqsal2...hfurq,apvlnajbostzwskpx4a,.urlset/master.m3u8"
}
}
 
Agregandole el parametro &q={n , h , l, o} a la url.
 
voy a probarlo
 
{"msg":"OK","result":"https://026ljzhkje3707.lions-vidcdn...U&s=1686946264&e=129600&f=243938&sp=800&i=0.0","status":200,"server_time":"2023-06-16 20:11:04"} trae asi la api pero no funciona en el get ya que no dice url ahora dice result

Lee bien la documentación

Según la API es el mismo formato. Y como veo en la respuesta, retorna todas las calidades disponibles, y en el link que pasaste solo retorna la calidad 'n', ya que las otras no figuran si lo revisas de manera independiente.
 
Lee bien la documentación

Según la API es el mismo formato. Y como veo en la respuesta, retorna todas las calidades disponibles, y en el link que pasaste solo retorna la calidad 'n', ya que las otras no figuran si lo revisas de manera independiente.
es h la que pase recien
 
if(!empty($json['result']['versions'][0]['url'])){

$video_url = $json['result']['versions'][0]['url'];
header('Location: '.$video_url);
aqui habria que modificar creo
 
if(!empty($json['result']['versions'][0]['url'])){

$video_url = $json['result']['versions'][0]['url'];
header('Location: '.$video_url);
aqui habria que modificar creo

Lo mismo solo especifica que versión deseas. Sel asume que el ultimo elemento es que que trae la mayor calidad como en la mayoría de esos servicios genéricos de archivos.

PHP:
if (!empty($json['result']['versions'])) {

    $all_video_url = $json['result']['versions'];

    # Asumiendo que el ultimo elemento es el que tiene mayor calidad
    $video_url = end($all_video_url);
    header('Location: ' . $video_url['url']);
}
 
Última edición:
Atrás
Arriba