aboutsummaryrefslogtreecommitdiffstats
path: root/tools/init.php
diff options
context:
space:
mode:
Diffstat (limited to 'tools/init.php')
-rw-r--r--tools/init.php73
1 files changed, 0 insertions, 73 deletions
diff --git a/tools/init.php b/tools/init.php
index d822c1e..2627811 100644
--- a/tools/init.php
+++ b/tools/init.php
@@ -14,76 +14,3 @@ function secToDuration($seconds){
$seconds = ($seconds - ($minutes * 60));
return $minutes . ' minutes ' . $seconds . ' seconds';
}
-
-function parseStream($stream){
- $available_formats = [];
- foreach ($stream as $format) {
- parse_str($format, $format_info);
- if (isset($format_info['bitrate'])) $quality = isset($format_info['quality_label'])?$format_info['quality_label']:round($format_info['bitrate']/1000). 'k';
- else $quality = isset($format_info['quality'])?$format_info['quality']:'';
-
- switch ($quality){
- case 'hd720':
- $quality = "720";
- break;
- case 'medium':
- $quality = "360";
- break;
- case 'small':
- $quality = "240"; // May Less
- break;
- }
- $type = explode(";", $format_info['type']);
- $type= $type[0];
- switch ($type) {
- case 'video/3gpp':
- $type = "3GP";
- break;
- case 'video/mp4':
- $type = "MP4";
- break;
- case 'video/webm':
- $type = "WEBM";
- break;
- }
-
- $libretype = explode(";", $format_info['type']);
- $libretype= $libretype[0];
- switch ($libretype) {
- case 'video/webm':
- $libretype = "video/webm";
- break;
- }
-
- $available_formats[] = [
- 'itag' => $format_info['itag'],
- 'quality' => $quality,
- 'type' => $type,
- 'libretype' => $libretype,
- 'url' => $format_info['url'],
- 'size' => getSize($format_info['url']),
-
- ];
- }
-
- return $available_formats;
-}
-
-function getSize($url)
-{
-
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_HEADER, true);
- curl_setopt($ch, CURLOPT_NOBODY, true);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_TIMEOUT, 10);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- $r = curl_exec($ch);
-
- foreach (explode("\n", $r) as $header) {
- if (strpos($header, 'Content-Length:') === 0) {
- return intval(intval(trim(substr($header, 16)))/ (1024*1024)) . " MB";
- }
- }
-}