aboutsummaryrefslogtreecommitdiffstats
path: root/init.php
diff options
context:
space:
mode:
authorJesús Eduardo <heckyel@hyperbola.info>2017-12-25 16:58:41 -0500
committerJesús Eduardo <heckyel@hyperbola.info>2017-12-25 16:58:41 -0500
commit49d54c0c3199fb8e380ce68f8fb08a308ddf56a7 (patch)
tree87e9be319452d75241476853a3b240aabdcbd7e2 /init.php
parent6a844225b3b63b89926e136cf65c140df01a4677 (diff)
downloadytlibre-49d54c0c3199fb8e380ce68f8fb08a308ddf56a7.tar.lz
ytlibre-49d54c0c3199fb8e380ce68f8fb08a308ddf56a7.tar.xz
ytlibre-49d54c0c3199fb8e380ce68f8fb08a308ddf56a7.zip
migración mayor a smarty PHP
Diffstat (limited to 'init.php')
-rw-r--r--init.php89
1 files changed, 0 insertions, 89 deletions
diff --git a/init.php b/init.php
deleted file mode 100644
index 65de424..0000000
--- a/init.php
+++ /dev/null
@@ -1,89 +0,0 @@
-<?php
-
-function get($url) {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $data = curl_exec($ch);
- curl_close($ch);
- return $data;
-}
-
-function secToDuration($seconds){
- $minutes = intval($seconds/60);
- $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 = "720p";
- break;
- case 'medium':
- $quality = "360p";
- break;
- case 'small':
- $quality = "240p"; // 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";
- }
- }
-}