/dev/null &", $output, $ret);
// preg_match("/[0-9]+x[0-9]+/", $output[6], $match);
// $output[6]=$match[0];
if($ret != 0){
return false;
}
return $output;
}
function video_dl($VIDEO, $CACHEDIR, $FILENAME){
$fp=fopen($CACHEDIR."/".$FILENAME.".txt", "w");
$content="downloading: ".$FILENAME."\n";
fputs($fp, $content);
fclose($fp);
exec("youtube-dl --no-part --output '".$CACHEDIR."/".$FILENAME."' '$VIDEO'", $pid, $ret);
if($ret != 0){
return false;
} else {
return true;
}
}
function video_xt_audio($VIDEO, $CACHEDIR, $FILENAME){
$fp=fopen($CACHEDIR."/".$FILENAME.".audio.txt", "w");
$content="extracting audio: ".$FILENAME."\n";
fputs($fp, $content);
fclose($fp);
//exec("youtube-dl --no-part -x --output '".escapeshellarg($CACHEDIR."/".$FILENAME.".%(ext)s' " .escapeshellarg($VIDEO), $pid, $ret);
exec("youtube-dl --no-part -x --output ".escapeshellarg($CACHEDIR."/".$FILENAME.".%(ext)s")." " .escapeshellarg($VIDEO), $pid, $ret);
// echo "youtube-dl --no-part -x --output ".escapeshellarg($CACHEDIR."/".$FILENAME.".%(ext)s")." " .escapeshellarg($VIDEO); //, $pid, $ret);
if($ret != 0){
return false;
} else {
return true;
}
return true;
}
function convert_video($CACHEDIR, $FILENAME, $MIME){
$fp=fopen($CACHEDIR."/".$FILENAME.".webm.txt", "w");
$content="converting video ".$FILENAME." to .webm\n";
fputs($fp, $content);
fclose($fp);
/*
$fp=fopen($CACHEDIR."/".$FILENAME.".block.txt", "w");
$content="blocked because of extracting audio: ".$FILENAME."\n";
fputs($fp, $content);
fclose($fp);
*/
if(file_exists($CACHEDIR . "/" . $FILENAME.".webm"))
return true;
// rename($CACHEDIR . "/" . $FILENAME, $CACHEDIR . "/" . $FILENAME. ".mp4");
exec("ffmpeg -f ".escapeshellarg(preg_replace("/^video\//i", "", $MIME))." -i " . escapeshellarg($CACHEDIR . "/" . $FILENAME). " " . escapeshellarg($CACHEDIR . "/" . $FILENAME. ".webm"), $output, $ret);
// rename($CACHEDIR . "/" . $FILENAME . ".mp4", $CACHEDIR . "/" . $FILENAME);
if($ret != 0){
return false;
}
return true;
}
function pr_player($file, $thumb, $mime, $title, $vid, $html5 = false){
if($html5)
$WEBMVIDEO = "
".$reason."
"; exit; } if($_SERVER["REQUEST_METHOD"] == "GET"){ if(isset($_GET["ajax"]) && $_GET["ajax"] == 1){ header("HTTP/1.1 404 Not Found"); // TODO: make it prettier echo "".$reason."
"; exit; } } else if($_SERVER["REQUEST_METHOD"] == "POST"){ if($_POST["ajax"] == 1){ header("HTTP/1.1 404 Not Found"); // TODO: make it prettier echo "".$reason."
"; exit; } } if($ajax == true || $ajax == NULL){ $error = "Error. :/"; require("error.php"); exit; } } function get_all_yt_data($id){ $data = file_get_contents("https://gdata.youtube.com/feeds/api/videos/".$id.""); $data = preg_replace("/yt:statistics/", "ytstatistics", $data); $data = preg_replace("/media:group/", "mediagroup", $data); $data = preg_replace("/media:description/", "mediadescription", $data); $data = preg_replace("/gd:rating/", "gdrating", $data); $xmldata = simplexml_load_string($data); $title = $xmldata->title[0]; $viewCount = $xmldata->ytstatistics["viewCount"]; $author = $xmldata->author->name[0]; $desc = $xmldata->mediagroup->mediadescription[0]; $date = $xmldata->published[0]; $rate = $xmldata->gdrating["average"]; $res["title"] = $title; $res["viewCount"] = $viewCount; $res["author"] = $author; $res["desc"] = $desc; $res["date"] = $date; $res["rate"] = $rate; return $res; } function get_yt_title($id){ $data = file_get_contents("https://gdata.youtube.com/feeds/api/videos/".$id.""); $xmldata = simplexml_load_string($data); $title = $xmldata->title[0]; return $title; } function getId($video) { exec("youtube-dl --get-id " . escapeshellarg($video), $output, $ret); if($ret != 0) return false; $output = $output[0]; return $output; } function print_info($title, $vid, $thumb, $duration, $url){ //if($filesize > 50000000){ /* 50M */ // $filesize = $filesize/1000000; /* $size = "size: ".$filesize." (not supported!)
"; } else { $size = "size: ".$filesize."
"; } */ $size = "Size: checking...
"; echo "
".$title."Duration: ".$duration." ".$size." |
|
What do you want to do? Choose one option.
Stream! or Direct download or Extract the audio echo "Duration: ".$duration."
".$size."What do you want to do? Choose one option.
Stream! or Direct download or Extract the audio "; */ } function BytesHumanSize($Bytes){ $Type=array("", "kilo", "mega", "giga", "tera", "peta", "exa", "zetta", "yotta"); $Index=0; while($Bytes>=1024) { $Bytes/=1024; $Index++; } $Bytes = substr($Bytes, 0, 4); //return("".$Bytes." ".$Type[$Index]."bytes"); $string = "".$Bytes." ".$Type[$Index]."bytes"; if(preg_match("/[0-9]+\. /", $string)) $string = preg_replace("/([0-9]+)\. /", "$1 ", $string); return $string; }