getaudio.php version 1
<?php
$youtubeUrl = $_GET['url'];
$content = shell_exec("youtube-dl -j $youtubeUrl ");
$meta=json_decode($content);
$file= $meta->{'_filename'};
$fileWithoutExtension = explode(".",$file)[0];
$extension = ".m4a";
$file = $fileWithoutExtension . $extension;
header("Content-Disposition: attachment; filename=\"$file\"" );
header("Content-Type: application/octet-stream");
passthru("youtube-dl -f 140 -o - $youtubeUrl");
?>
getaudio.php version 2
<?php
$youtubeUrl = $_GET['url'];
$file = shell_exec("youtube-dl -f 140 --get-filename $youtubeUrl ");
header("Content-Disposition: attachment; filename=\"$file\"" );
header("Content-Type: application/octet-stream");
passthru("youtube-dl -f 140 -o - $youtubeUrl");
?>
if url = https://www.youtube.com/watch?v=bvYtKY-UMxA then we get $file = Deewana Kar Raha Hai Full Song 1080p HD Raaz 3 2012 YouTube-bvYtKY-UMxA.m4a
my question is getaudio.php version 1 is working fine but getaudio.php version 2 isn't....
getaudio.php version 2 is downloading but the file is coruppted....
when $file is same for both php files then how is it possible that the second one is not working
HINT: download youtube-dl.exe(for windows) & place it with the two php files & run in localhost