aboutsummaryrefslogtreecommitdiffstats
path: root/tools/processor.php
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2019-05-21 22:31:18 -0500
committerJesús <heckyel@hyperbola.info>2019-05-21 22:31:18 -0500
commit403def35b11d2dba5e596662ebdd0c9dd2438772 (patch)
treeef1fbae8d7968e120aa30c3c947d267cb1ee3ffb /tools/processor.php
parent0c10774cd262d3b038691567684861e191100733 (diff)
downloadytlibre-403def35b11d2dba5e596662ebdd0c9dd2438772.tar.lz
ytlibre-403def35b11d2dba5e596662ebdd0c9dd2438772.tar.xz
ytlibre-403def35b11d2dba5e596662ebdd0c9dd2438772.zip
Extract data from invidio
This migration allows users to extract videos with DRM and without DRM. All this without non-free JS
Diffstat (limited to 'tools/processor.php')
-rw-r--r--tools/processor.php71
1 files changed, 43 insertions, 28 deletions
diff --git a/tools/processor.php b/tools/processor.php
index f4e6d2b..89a37f6 100644
--- a/tools/processor.php
+++ b/tools/processor.php
@@ -18,23 +18,18 @@ if (strpos($baselink,$yturl) !== false){
parse_str($link, $urlData);
$video_id = array_values($urlData)[0];
-$videoFetchURL = file_get_contents("https://www.youtube.com/get_video_info?html5=1&video_id={$video_id}");
-parse_str($videoFetchURL, $video_info);
+$video_string = file_get_contents("https://invidio.us/api/v1/videos/{$video_id}");
+
+$video_info = json_decode($video_string);
-$video_info = json_decode(json_encode($video_info));
-if (!$video_info->status === "ok") {
- die("error in fetching youtube video data");
-}
$videoTitle = $video_info->title;
$videoAuthor = $video_info->author;
-$videoDurationSecs = $video_info->length_seconds;
+$videoDurationSecs = $video_info->lengthSeconds;
$videoDuration = secToDuration($videoDurationSecs);
-$videoChannel = $video_info->ucid;
+$videoChannel = $video_info->author;
// Begin_ViewCount
-$api_key = 'AIzaSyB9TLn5HvT614SjzBv8ZOj3wL2tc7PM3M4'; // API KEY only view_count
-$data_all = json_decode(file_get_contents("https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,statistics&id={$video_id}&key={$api_key}"));
-$video_view = $data_all->items[0]->statistics->viewCount;
+$extract_video_view = $video_info->viewCount;
function bytes($a) {
$unim = array("","K","M","G","T","P");
@@ -46,25 +41,45 @@ function bytes($a) {
return number_format($a,($c ? 2 : 0),",",".")." ".$unim[$c];
}
-$videoViews = bytes($video_view);
+$videoViews = bytes($extract_video_view);
// End_ViewCount
-//change hqdefault.jpg to default.jpg for downgrading the thumbnail quality
+// change hqdefault.jpg to default.jpg for downgrading the thumbnail quality
$videoThumbURL = "https://i1.ytimg.com/vi/{$video_id}/hqdefault.jpg";
-$librethumb = "https://i1.ytimg.com/vi/{$video_id}/maxresdefault.jpg";
-
-if (!isset($video_info->url_encoded_fmt_stream_map)) {
- die('No data found');
-}
-
-$streamFormats = explode(",", $video_info->url_encoded_fmt_stream_map);
-
-if (isset($video_info->adaptive_fmts)) {
- $streamSFormats = explode(",", $video_info->adaptive_fmts);
- $pStreams = parseStream($streamSFormats);
+$librethumb = $video_info->videoThumbnails[0]->url;
+
+// Extract videos from JSON
+$streamFormats = $video_info->formatStreams;
+
+// Downloads
+$downloads = $video_info->formatStreams;
+
+// Breaking DRM!!!
+$url_drm = $streamFormats[0]->url;
+@$headers = get_headers($url_drm);
+if (preg_match('/^HTTP\/\d\.\d\s+(403)/', $headers[0])){
+ // Liberty data
+ $breakquality = trim($streamFormats[0]->resolution, 'p');
+ $breakurl = "https://invidio.us/latest_version?id={$video_id}&itag=18&local=true";
+ $breaklink = <<<EOT
+ <source data-res="{$breakquality}" src="{$breakurl}" type='{$streamFormats[0]->type}'/>
+EOT;
+ $downloadFormat = $downloads[0]->container;
+ $downloadQuality = $streamFormats[0]->resolution;
+ $breakdownload = <<<EOT
+<div class="row">
+ <div class="col">{$downloadFormat}</div>
+ <div class="col">{$downloadQuality}</div>
+ <div class="col">
+ <a class="boton-descarga" href="{$breakurl}" download>Descarga Habilitada</a>
+ </div>
+</div>
+EOT;
+} else {
+ $breaklink = '';
+ $breakdownload = '';
}
+// End Breaking DRM!!!
-$cStreams = parseStream($streamFormats);
-
-// Aquí selecciona solo 2 vídeos principales.
-$videosStream = array_slice($cStreams, 0, 2);
+// // Captions
+// $streamCaptions = $video_info->captions;