Last active
July 14, 2021 17:58
-
-
Save ForumPlayer/5aed7107a8fa5fe679c2ce0bf26199b8 to your computer and use it in GitHub Desktop.
Outdated Youtube API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (isset($_GET['id'])) { | |
$id = trim($_GET['id']); | |
parse_str(file_get_contents("http://youtube.com/get_video_info?video_id=".$id),$info); | |
$streams = explode(',',$info['url_encoded_fmt_stream_map']); | |
$found = false; | |
foreach($streams as $stream){ | |
parse_str($stream,$data); | |
if(stripos($data['type'],"video/mp4") !== false){ | |
$found = true; | |
/*if(array_keys($_GET)[1]=="save" ){ | |
$video = fopen($data['url'].'&signature='.$data['sig'],'r'); //the video | |
$file = fopen("yt/".$id.".mp4",'w'); | |
stream_copy_to_stream($video,$file); //copy it to the file | |
fclose($video); | |
fclose($file); | |
header("location:http://fpsandbox.esy.es/src/yt/".$id.".mp4"); | |
} else */ | |
if(array_keys($_GET)[1]=="dl" ){ | |
header("Cache-Control: public"); | |
header("Content-Description: File Transfer"); | |
header("Content-Disposition: attachment; filename=".$id.".mp4"); | |
header("Content-Type: video/mp4"); | |
header("Content-Transfer-Encoding: binary"); | |
readfile($data['url'].'&signature='.$data['sig']); | |
exit; | |
} else { | |
header("location:".$data['url'].'&signature='.$data['sig']); | |
} | |
break; | |
} | |
} | |
if (!$found) { | |
header("HTTP/1.0 404 Not Found"); | |
} | |
} else { | |
header("HTTP/1.1 400 Bad Request"); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment