aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/extract.php518
-rw-r--r--tools/processor.php114
-rw-r--r--tools/sig.php1
3 files changed, 533 insertions, 100 deletions
diff --git a/tools/extract.php b/tools/extract.php
new file mode 100644
index 0000000..2b06a5f
--- /dev/null
+++ b/tools/extract.php
@@ -0,0 +1,518 @@
+<?php
+
+$id = $video_id;
+
+function getc($url) {
+ $ch = curl_init($url);
+ curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 10);
+ $data = curl_exec($ch);
+ curl_close($ch);
+
+ return $data;
+}
+
+function cut_yt($ganti) {
+ $arayganti = array('Youtube','youtube','YouTube');
+ $ganti = str_replace($arayganti,'',$ganti);
+ return $ganti;
+}
+
+function exformat($itag) {
+ switch ($itag) {
+ case "5":
+ return "flv, video, 240p, audio";
+ break;
+ case "6":
+ return "flv, video, 270p, audio";
+ break;
+ case "13":
+ return "3gp, video, audio";
+ break;
+ case "17":
+ return "3gp, video, 144p, audio";
+ break;
+ case "18":
+ return "mp4, video, 360p, audio";
+ break;
+ case "22":
+ return "mp4, video, 720p, audio";
+ break;
+ case "34":
+ return "flv, video, 360p, audio";
+ break;
+ case "35":
+ return "flv, video, 480p, audio";
+ break;
+ case "36":
+ return "3gp, video, audio";
+ break;
+ case "37":
+ return "mp4, video, 1080p, audio";
+ break;
+ case "38":
+ return "mp4, video, 3072p, audio";
+ break;
+ case "43":
+ return "webm, video, 360p, audio";
+ break;
+ case "44":
+ return "webm, video, 480p, audio";
+ break;
+ case "45":
+ return "webm, video, 720p, audio";
+ break;
+ case "46":
+ return "webm, video, 1080p, audio";
+ break;
+ case "59":
+ return "mp4, video, 480p, audio";
+ break;
+ case "78":
+ return "mp4, video, 480p, audio";
+ break;
+ case "82":
+ return "mp4, video, 360p, audio";
+ break;
+ case "83":
+ return "mp4, video, 480p, audio";
+ break;
+ case "84":
+ return "mp4, video, 720p, audio";
+ break;
+ case "85":
+ return "mp4, video, 1080p, audio";
+ break;
+ case "100":
+ return "webm, video, 360p, audio";
+ break;
+ case "101":
+ return "webm, video, 480p, audio";
+ break;
+ case "102":
+ return "webm, video, 720p, audio";
+ break;
+ case "91":
+ return "mp4, video, 144p, audio";
+ break;
+ case "92":
+ return "mp4, video, 240p, audio";
+ break;
+ case "93":
+ return "mp4, video, 360p, audio";
+ break;
+ case "94":
+ return "mp4, video, 480p, audio";
+ break;
+ case "95":
+ return "mp4, video, 720p, audio";
+ break;
+ case "96":
+ return "mp4, video, 1080p, audio";
+ break;
+ case "132":
+ return "mp4, video, 240p, audio";
+ break;
+ case "151":
+ return "mp4, video, 72p, audio";
+ break;
+ case "133":
+ return "mp4, video, 240p";
+ break;
+ case "134":
+ return "mp4, video, 360p";
+ break;
+ case "135":
+ return "mp4, video, 480p";
+ break;
+ case "136":
+ return "mp4, video, 720p";
+ break;
+ case "137":
+ return "mp4, video, 1080p";
+ break;
+ case "138":
+ return "mp4, video";
+ break;
+ case "160":
+ return "mp4, video, 144p";
+ break;
+ case "212":
+ return "mp4, video, 480p";
+ break;
+ case "264":
+ return "mp4, video, 1440p";
+ break;
+ case "298":
+ return "mp4, video, 720p";
+ break;
+ case "299":
+ return "mp4, video, 1080p";
+ break;
+ case "266":
+ return "mp4, video, 2160p";
+ break;
+ case "139":
+ return "m4a, audio";
+ break;
+ case "140":
+ return "m4a, audio";
+ break;
+ case "141":
+ return "m4a, audio";
+ break;
+ case "256":
+ return "m4a, audio";
+ break;
+ case "258":
+ return "m4a, audio";
+ break;
+ case "325":
+ return "m4a, audio";
+ break;
+ case "328":
+ return "m4a, audio";
+ break;
+ case "167":
+ return "webm, video, 360p";
+ break;
+ case "168":
+ return "webm, video, 480p";
+ break;
+ case "169":
+ return "webm, video, 720p";
+ break;
+ case "170":
+ return "webm, video, 1080p";
+ break;
+ case "218":
+ return "webm, video, 480p";
+ break;
+ case "219":
+ return "webm, video, 480p";
+ break;
+ case "278":
+ return "webm, video, 144p";
+ break;
+ case "242":
+ return "webm, video, 240p";
+ break;
+ case "243":
+ return "webm, video, 360p";
+ break;
+ case "244":
+ return "webm, video, 480p";
+ break;
+ case "245":
+ return "webm, video, 480p";
+ break;
+ case "246":
+ return "webm, video, 480p";
+ break;
+ case "247":
+ return "webm, video, 720p";
+ break;
+ case "248":
+ return "webm, video, 1080p";
+ break;
+ case "271":
+ return "webm, video, 1440p";
+ break;
+ case "272":
+ return "webm, video, 2160p";
+ break;
+ case "302":
+ return "webm, video, 720p";
+ break;
+ case "303":
+ return "webm, video, 1080p";
+ break;
+ case "308":
+ return "webm, video, 1440p";
+ break;
+ case "313":
+ return "webm, video, 2160p";
+ break;
+ case "315":
+ return "webm, video, 2160p";
+ break;
+ case "171":
+ return "webm, audio";
+ break;
+ case "249":
+ return "webm, audio";
+ break;
+ case "250":
+ return "webm, audio";
+ break;
+ case "251":
+ return "webm, audio";
+ break;
+ case "394":
+ return "video";
+ break;
+ case "395":
+ return "video";
+ break;
+ case "396":
+ return "video";
+ break;
+ case "397":
+ return "video";
+ break;
+ default:
+ return $itag;
+ break;
+ }
+}
+
+$a = getc('https://www.youtube.com/embed/'.$id);
+
+$ccc=explode('s/player/', $a);
+$ddd=explode('/www-player.css', $ccc[1]);
+
+$gsts = file_get_contents('https://www.youtube.com/s/player/'.$ddd[0].'/player_ias.vflset/en_US/base.js');
+
+function getchiper($decipherScript) {
+ $decipherPatterns = explode('.split("")', $decipherScript);
+ unset($decipherPatterns[0]);
+ foreach ($decipherPatterns as $value) {
+ $value = explode('.join("")', explode('}', $value)[0]);
+ if (count($value) === 2) {
+ $value = explode(';', $value[0]);
+ array_pop($value);
+ unset($value[0]);
+ $decipherPatterns = implode(';', $value);
+ break;
+ }
+ }
+ preg_match_all('/(?<=;).*?(?=\[|\.)/', $decipherPatterns, $deciphers);
+ if ($deciphers && count($deciphers[0]) >= 2) {
+ $deciphers = $deciphers[0][0];
+ $deciphersObjectVar = $decipherPatterns ;
+ $decipher = explode($deciphers . '={', $decipherScript)[1];
+ $decipher = str_replace(["\n", "\r"], '', $decipher);
+ $decipher = explode('}};', $decipher)[0];
+ $decipher = explode('},', $decipher);
+ // Convert deciphers to object
+ $deciphers = [];
+
+ foreach ($decipher as &$function) {
+ $deciphers[explode(':function', $function)[0]] = explode('){', $function)[1];
+ }
+ // Convert pattern to array
+ $decipherPatterns = str_replace($deciphersObjectVar . '.', '', $decipherPatterns);
+ $decipherPatterns = str_replace($deciphersObjectVar . '[', '', $decipherPatterns);
+ $decipherPatterns = str_replace(['](a,', '(a,'], '->(', $decipherPatterns);
+ $decipherPatterns = explode(';', $decipherPatterns);
+ $patterns =$decipherPatterns;
+ $deciphers =$deciphers;
+
+ if (!file_exists(TOOLS_PATH.'sig.php')) {
+
+ for ($i=0; $i < count($patterns); $i++) {
+ $executes = explode('->', $patterns[$i]);
+ $execute=explode('.', $executes[0]);
+ $number = intval(str_replace(['(', ')'], '', $executes[1]));
+ $execute = $deciphers[$execute[1]];
+ switch ($execute) {
+ case 'a.reverse()':
+ $processSignature = '$reverse';
+ break;
+ case 'var c=a[0];a[0]=a[b%a.length];a[b]=c':
+ $processSignature= '$length';
+ break;
+ case 'var c=a[0];a[0]=a[b%a.length];a[b%a.length]=c':
+ $processSignature= '$lengtha';
+ break;
+ case 'a.splice(0,b)':
+ $processSignature= '$splice';
+ break;
+ default:
+ die("\n==== Decipher dictionary was not found ====");
+ break;
+ }
+ $myfile = fopen(TOOLS_PATH.'sig.php', "a+") or die("Unable to open file!");
+ if ($i==0) {
+ fwrite($myfile, '<?php $a = str_split($s);');
+ }
+ fwrite($myfile, $processSignature.'($a,'.$number.');');
+ fclose($myfile);
+ }
+
+ }
+ }
+}
+
+function sig($s){
+ $reverse=function(&$a){
+ $a = array_reverse($a);
+ };
+ $splice=function(&$a, $b){
+ $a = array_slice($a, $b);
+ };
+ $length = function(&$a, $b){
+ $c = $a[0];
+ $a[0] = $a[$b % count($a)];
+ $a[$b] = $c;
+ };
+ $lengtha = function(&$a, $b){
+ $c = $a[0];
+ $a[0] = $a[$b%count($a)];
+ $a[$b%count($a)] = $c;
+ };
+
+ include(TOOLS_PATH.'sig.php');
+ return join('', $a);
+}
+
+
+getchiper($gsts);
+$data = getc("https://www.youtube.com/get_video_info?video_id=".$id."&asv=3&el=detailpage&hl=en_US");
+parse_str($data,$info);
+$streams = $info['player_response'];
+$jsn_str = str_replace("\u0026","&", $streams);
+$streamin_data_json = json_decode($jsn_str, true);
+
+// Microdata
+$vidtitle = $streamin_data_json["videoDetails"]["title"];
+$vidId = $streamin_data_json["videoDetails"]["videoId"];
+$viddes = $streamin_data_json["microformat"]["playerMicroformatRenderer"]["description"]["simpleText"];
+$vidpub = $streamin_data_json["microformat"]["playerMicroformatRenderer"]["publishDate"];
+$vidviewCount = $streamin_data_json["videoDetails"]["viewCount"];
+$vidauthor = $streamin_data_json["videoDetails"]["author"];
+$vidauthorid = $streamin_data_json["videoDetails"]["channelId"];
+$vidauthourl = "channel/{$vidauthorid}";
+$vidtime = $streamin_data_json["videoDetails"]["lengthSeconds"];
+$vidisLiveContent = $streamin_data_json["videoDetails"]["isLiveContent"];
+
+// thumbs
+$vidthumb = array();
+foreach ($streamin_data_json["videoDetails"]["thumbnail"]["thumbnails"] as $data) {
+ $url = $data['url'];
+ $values = array(
+ 'url' => $url,
+ 'width' => $data['width'],
+ 'height' => $data['height']
+ );
+ array_push($vidthumb, $values);
+}
+
+// keywords
+$vidkeywords = array();
+if ( isset($streamin_data_json["videoDetails"]["keywords"]) ) {
+ foreach ($streamin_data_json["videoDetails"]["keywords"] as $data) {
+ array_push($vidkeywords, $data);
+ }
+}
+
+// streams
+if (isset($streamin_data_json["streamingData"])) {
+
+ $strF=$streamin_data_json["streamingData"]["formats"];
+ $strA=$streamin_data_json["streamingData"]["adaptiveFormats"];
+
+ $vdef = array();
+ foreach ($strF as $stream) {
+ if (isset($stream["signatureCipher"])) {
+ parse_str($stream["signatureCipher"],$dturl);
+ $values = array(
+ 'url' => $dturl['url'].'&sig='.sig($dturl['s']),
+ 'itag' => $stream['itag'],
+ 'type' => $stream['mimeType'],
+ 'quality' => $stream['quality'],
+ 'fps' => $stream['fps'],
+ 'resolution' => $stream['qualityLabel'],
+ 'qualityLabel' => $stream['qualityLabel'],
+ 'format' => exformat($stream['itag'])
+ );
+ array_push($vdef, $values);
+ } else {
+ if (!empty($strF['url'])) {
+ $values = array(
+ 'url' => $strF['url'],
+ );
+ array_push($vdef, $values);
+ }
+ }
+ }
+
+ $aud = array();
+ $vid = array();
+ foreach ($strF as $stream) {
+ if (isset( $stream['url'] )) {
+ if (preg_match('/video/', $stream['mimeType'])) {
+ $url = $stream['url'];
+ $values = array(
+ 'url' => $url,
+ 'itag' => $stream['itag'],
+ 'type' => $stream['mimeType'],
+ 'quality' => $stream['quality'],
+ 'fps' => $stream['fps'],
+ 'resolution' => $stream['qualityLabel'],
+ 'qualityLabel' => $stream['qualityLabel'],
+ 'format' => exformat($stream['itag']),
+ );
+ array_push($vid, $values);
+ }
+ }
+ }
+ foreach ($strA as $stream) {
+ if (isset($stream["signatureCipher"])) {
+ parse_str($stream["signatureCipher"],$dturl);
+ $stream['url']=$dturl['url'].'&sig='.sig($dturl['s']);
+ }
+
+ if (preg_match('/audio/', $stream['mimeType'])) {
+ $url = $stream['url'];
+ $values = array(
+ 'url' => $url,
+ 'itag' => $stream['itag'],
+ 'type' => $stream['mimeType'],
+ 'quality' => $stream['quality'],
+ 'format' => exformat($stream['itag']),
+ );
+ array_push($aud, $values);
+ }
+
+ if (preg_match('/video/', $stream['mimeType'])) {
+ $url = $stream['url'];
+ $values = array(
+ 'url' => $url,
+ 'itag' => $stream['itag'],
+ 'type' => $stream['mimeType'],
+ 'quality' => $stream['quality'],
+ 'fps' => $stream['fps'],
+ 'resolution' => $stream['qualityLabel'],
+ 'qualityLabel' => $stream['qualityLabel'],
+ 'format' => exformat($stream['itag']),
+ );
+ array_push($vid, $values);
+ }
+ }
+
+} else {
+ $vdef = array();
+ $aud = array();
+ $vid = array();
+}
+
+// $json['title']=$vidtitle;
+// $json['videoId']=$vidId;
+// $json['videoThumbnails']=$vidthumb;
+// $json['description']=$viddes;
+// $json['publishedText']=$vidpub;
+// $json['viewCount']=$vidviewCount;
+// $json['keywords']=$vidkeywords;
+// $json['author']=$vidauthor;
+// $json['authorId']=$vidauthorid;
+// $json['authorUrl']=$vidauthourl;
+// $json['lengthSeconds']=$vidtime;
+// $json['liveNow']=$vidisLiveContent;
+// $json['default']=$vdef;
+// $json['audio']=$aud;
+// $json['video']=$vid;
diff --git a/tools/processor.php b/tools/processor.php
index c3afdd1..a490d32 100644
--- a/tools/processor.php
+++ b/tools/processor.php
@@ -1,11 +1,6 @@
<?php
require_once "init.php";
-$instance = [
- "snopyta" => "https://invidious.snopyta.org",
- "glie" => "https://invidious.glie.town",
-];
-
if ( empty( $_GET['link'] ) ){
header( 'Location: index.php' );
}
@@ -23,6 +18,7 @@ if ( $urlexists === TRUE ) {
invidiou[.]sh|
invidious[.]kabi[.]tk|
invidious[.]glie[.]town|
+ invidious[.]zapashcanon[.]fr|
yotter[.]conocimientoslibres[.]ga|
invidious[.]snopyta[.]org)) # URL supports
(\/(?:[\w\-]+\?v=|embed\/|v\/)?) # Parameters (embed, v)
@@ -40,104 +36,22 @@ if ( $urlexists === TRUE ) {
header( 'Location: index.php' );
}
-// servers JSON
-$invidio0 = "{$instance['snopyta']}/api/v1/videos/{$video_id}";
-$invidio1 = "{$instance['glie']}/api/v1/videos/{$video_id}";
-
-$invidio0on = url_exists( $invidio0 );
-$invidio1on = url_exists( $invidio1 );
-
-// check servers
-if ( $invidio0on === TRUE ) {
- $video_string = file_get_contents( $invidio0 );
-} elseif ( $invidio1on === TRUE ) {
- $video_string = file_get_contents( $invidio1 );
-} else {
- header( 'Location: index.php' );
-}
-
-$video_info = json_decode( $video_string );
-
-$videoTitle = $video_info->title;
-$videoAuthor = $video_info->author;
-$videoDurationSecs = $video_info->lengthSeconds;
-$videoDuration = secToDuration( $videoDurationSecs );
-$videoChannel = $video_info->authorId;
-
-// Begin_ViewCount
-$extract_video_view = $video_info->viewCount;
-$videoViews = bytes( $extract_video_view );
-// End_ViewCount
-
-// change hqdefault.jpg to default.jpg for downgrading the thumbnail quality
-$videoThumbURL = "https://i1.ytimg.com/vi/{$video_id}/hqdefault.jpg";
-$librethumb = $video_info->videoThumbnails[0]->url;
-
-// Extract videos from JSON
-$streamFormats = $video_info->formatStreams;
-
-// Downloads
-$downloads = $video_info->formatStreams;
+// Core API
+require_once "extract.php";
-// Live
-$islive = $video_info->liveNow;
+$videoTitle=$vidtitle;
+$videoThumbURL = "https://i.ytimg.com/vi/{$video_id}/hqdefault.jpg";
+$videoDuration = secToDuration($vidtime);
+$videoViews = bytes( $vidviewCount );
+$islive = $vidisLiveContent;
-///// Beaking DRM!!!
-// Check standar video into URL
-if ( $islive === FALSE ) {
- $url_standar = $streamFormats[0]->url;
+if (!empty($vdef)) {
+ $streamFormats = $vdef;
} else {
- $url_standar = FALSE;
+ $streamFormats = $vid;
}
-if ( $url_standar === FALSE ) {
- // nodes
- $node0 = "{$instance['snopyta']}/latest_version?id={$video_id}&itag=18&local=true";
- $node1 = "{$instance['glie']}/latest_version?id={$video_id}&itag=18&local=true";
-
- // explain DRM
- $drmv = "https://archive.org/download/libreweb/rms-drm.webm";
-
- $node0on = video_exists( $node0 );
- $node1on = video_exists( $node1 );
-
- // check nodes
- if ( $node0on === TRUE ) {
- $breakurl = $node0;
- } elseif ( $node1on === TRUE ) {
- $breakurl = $node1;
- } else {
- $breakurl = $drmv;
- $formatdrm = 'video/webm';
- }
-
- // format video DRM
- if ( $islive === FALSE ) {
- $formatdrm = $streamFormats[0]->type;
- $breakquality = trim( $streamFormats[0]->resolution, 'p' );
- $downloadQuality = $streamFormats[0]->resolution;
- $downloadFormat = $downloads[0]->container;
- } else {
- $formatdrm = NULL;
- $breakquality = NULL;
- $downloadQuality = NULL;
- $downloadFormat = NULL;
- }
-
- $breaklink = TRUE;
- $downloadbreak = TRUE;
-
-} else {
- // clean variables
- $breakurl = NULL;
- $breaklink = NULL;
- $breakquality = NULL;
- $downloadbreak = NULL;
- $downloadFormat = NULL;
- $downloadQuality = NULL;
- $formatdrm = NULL;
-}
-///// End Beaking DRM!!!
+$videoAuthor = $vidauthor;
/* ---- ---- Generated URL and embed ---- ---- */
if ( isset( $_SERVER["HTTPS"] ) && $_SERVER["HTTPS"] == "on" ) {
@@ -151,5 +65,5 @@ $subject = $pro."://".$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME'];
// Local URL
$local_url = preg_replace( '/index.php/', '', $subject );
-/* ---- ---- Change to Freedom URL ---- ---- */
-$url_freedom = "{$instance['snopyta']}/watch?v={$video_id}";
+/* ---- ---- URL Query ---- ---- */
+$url_query = "{$baselink}";
diff --git a/tools/sig.php b/tools/sig.php
new file mode 100644
index 0000000..53b1336
--- /dev/null
+++ b/tools/sig.php
@@ -0,0 +1 @@
+<?php $a = str_split($s);$lengtha($a,26);$lengtha($a,1);$reverse($a,35);$splice($a,2);$reverse($a,57); \ No newline at end of file