/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){ //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 pr_player($file, $thumb, $mime, $title, $vid){ echo "
".$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; }