/*
Made by [egyJs.com](https://www.instagram.com/egyjs/);
*/
install it on your localhost and try it :
/*
Made by [egyJs.com](https://www.instagram.com/egyjs/);
*/
install it on your localhost and try it :
<?php | |
/* | |
Made by [egyJs.com](https://www.instagram.com/egyjs/); | |
v2.0 | |
*/ | |
header('Access-Control-Allow-Origin: *'); | |
header('Content-Type: application/json'); | |
function get_error($ErrorExaction){ | |
$myObj = new stdClass(); | |
$myObj->error = true; | |
$myObj->msg = $ErrorExaction; | |
$myObj->madeBy = "A.El-zahaby"; | |
$myObj->instagram = "egy.js"; | |
$myJSON = json_encode($myObj,JSON_PRETTY_PRINT); | |
echo $myJSON; | |
exit; | |
} | |
function get_log($dump){ | |
if (isset($_GET['log'])) var_dump($dump).'\n\n\n'; | |
} | |
if(isset($_GET['url']) && $_GET['url'] != ""){ | |
parse_str( parse_url( $_GET['url'], PHP_URL_QUERY ), $vars ); | |
$id=$vars['v']; | |
$dt=file_get_contents("https://www.youtube.com/get_video_info?video_id=$id&el=embedded&ps=default&eurl=&gl=US&hl=en"); | |
if (strpos($dt, 'status=fail') !== false) { | |
$x=explode("&",$dt); | |
$t=array(); $g=array(); $h=array(); | |
foreach($x as $r){ | |
$c=explode("=",$r); | |
$n=$c[0]; $v=$c[1]; | |
$y=urldecode($v); | |
$t[$n]=$v; | |
} | |
$x=explode("&",$dt); | |
foreach($x as $r){ | |
$c=explode("=",$r); | |
$n=$c[0]; $v=$c[1]; | |
$h[$n]=urldecode($v); | |
} | |
$g[]=$h; | |
$g[0]['error'] = true; | |
$g[0]['instagram'] = "egy.js"; | |
$g[0]['apiMadeBy'] = 'El-zahaby'; | |
echo json_encode($g,JSON_PRETTY_PRINT); | |
}else{ | |
$x=explode("&",$dt); | |
$t=array(); $g=array(); $h=array(); | |
foreach($x as $r){ | |
$c=explode("=",$r); | |
$n=$c[0]; $v=$c[1]; | |
$y=urldecode($v); | |
$t[$n]=$v; | |
} | |
$streams = explode(',',urldecode($t['url_encoded_fmt_stream_map'])); | |
// if(empty($streams[0])){ get_error('ops! this video has something wrong! :( '); } | |
if(empty($streams[0])){ | |
get_log($streams); | |
} | |
foreach($streams as $dt){ | |
$x=explode("&",$dt); | |
foreach($x as $r){ | |
$c=explode("=",$r); | |
if ($c[0] == 'itag'){ // reference: https://superuser.com/q/1386658 | |
switch ($c[1]){ | |
case '18': | |
$h['mimeType'] = "mp4"; | |
$h['width'] = "640"; | |
$h['height'] = "360"; | |
$h['qualityLabel'] = '360p'; | |
break; | |
case '22': | |
$h['mimeType'] = "mp4"; | |
$h['width'] = "1280"; | |
$h['height'] = "720"; | |
$h['qualityLabel'] = '720p'; | |
break; | |
case '43': | |
$h['mimeType'] = "webm"; | |
$h['width'] = "640"; | |
$h['height'] = "360"; | |
$h['qualityLabel'] = '360p'; | |
break; | |
default: | |
$h['mimeType'] = null; | |
$h['width'] = null; | |
$h['height'] = null; | |
$h['qualityLabel'] = ''; | |
} | |
} | |
$n=$c[0]; /* => */ $v=$c[1]; | |
$h[$n]=urldecode($v); | |
} | |
$g[]=$h; | |
} | |
echo json_encode($g,JSON_PRETTY_PRINT); | |
// var_dump( $g[1]["quality"],true); | |
} | |
}else{ | |
get_error("Ops, there is no youtube link!"); | |
} |
@Maadhav
I just tried with the package you built.
$yt = new YouTubeDownloader();
$links = $yt->getDownloadLinks("https://www.youtube.com/watch?v=LJzCYSdrHMI");
var_dump($links); exit;
I am getting array(0) {}
as a result.
How can I get working url with above url ?
does this still work?
I love u <3 <3 u saved my life <3 its working
Thanks! I have given the source code just below the title.
Anyway: https://github.com/Maadhav/youtube-downloader-API
Great work man.. hopefully this remains working for a longer time.
I found an error when running on Repl.it:
[Tue Dec 15 22:14:00 2020] PHP Notice: Undefined index: url_encoded_fmt_stream_map in /home/runner/FreeYoutube/index.php on line 66 [Tue Dec 15 22:14:00 2020] PHP Notice: Undefined offset: 1 in /home/runner/FreeYoutube/index.php on line 102
@jazzy8 Can u send the repl.it public URL for the project u are trying to run?
I created a Javascript variant for anyone not wanting to rely on calling an external API, https://gist.github.com/JMV2112/f131f6d7c7782eb6e54c72f4da735ec0
this doesnt work
This no longer works 😞
Cool man! Big ups for making this.