aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2019-05-25 16:12:17 -0500
committerJesús <heckyel@hyperbola.info>2019-05-25 16:12:17 -0500
commit8ec10f183b15486e1786a5135a43bce5ebb0daa8 (patch)
tree8798f5ea12e1134c4a43503ebf408e09790bb39f
parent27ef7aafcf88fc4b29d097fd95c6a9c999be8989 (diff)
downloadytlibre-8ec10f183b15486e1786a5135a43bce5ebb0daa8.tar.lz
ytlibre-8ec10f183b15486e1786a5135a43bce5ebb0daa8.tar.xz
ytlibre-8ec10f183b15486e1786a5135a43bce5ebb0daa8.zip
improve standar syntax
-rw-r--r--tools/init.php18
-rw-r--r--tools/processor.php34
2 files changed, 26 insertions, 26 deletions
diff --git a/tools/init.php b/tools/init.php
index 51d4ee8..095f43d 100644
--- a/tools/init.php
+++ b/tools/init.php
@@ -34,13 +34,13 @@ function url_exists( $url = NULL ) {
}
}
-function video_exists($url) {
- @$headers = get_headers($url);
+function video_exists( $url ) {
+ @$headers = get_headers( $url );
$result = FALSE;
- foreach ($headers as $hdr) {
- if (preg_match('/^HTTP\/\d\.\d\s+(403)/', $hdr)){
+ foreach ( $headers as $hdr ) {
+ if ( preg_match( '/^HTTP\/\d\.\d\s+(403)/', $hdr ) ) {
$result = TRUE; // Found 403 Error
}
}
@@ -51,18 +51,18 @@ function video_exists($url) {
}
}
-function secToDuration($seconds){
- $minutes = intval($seconds/60);
- $seconds = ($seconds - ($minutes * 60));
+function secToDuration( $seconds ) {
+ $minutes = intval( $seconds/60 );
+ $seconds = ( $seconds - ( $minutes * 60 ) );
return $minutes . ' minutes ' . $seconds . ' seconds';
}
-function bytes($a) {
+function bytes( $a ) {
$unim = array("","K","M","G","T","P");
$c = 0;
while ($a>=1000) {
$c++;
$a = $a/1000;
}
- return number_format($a,($c ? 2 : 0),",",".")." ".$unim[$c];
+ return number_format( $a,( $c ? 2 : 0 ),",","." )." ".$unim[$c];
}
diff --git a/tools/processor.php b/tools/processor.php
index e38a8ef..5487fca 100644
--- a/tools/processor.php
+++ b/tools/processor.php
@@ -1,14 +1,14 @@
<?php
require_once "init.php";
-if (empty($_GET['link'])){
- header('Location: index.php');
+if ( empty( $_GET['link'] ) ){
+ header( 'Location: index.php' );
}
-$baselink = htmlspecialchars($_GET['link']);
+$baselink = htmlspecialchars( $_GET['link'] );
$urlexists = url_exists( $baselink );
-if ($urlexists === TRUE) {
+if ( $urlexists === TRUE ) {
// Regex - filter URL id is match[5]
$rx = '/^((?:https?:)?\/\/)? # Optional protocol
((?:www|m)[.])? # Optional sub-domain
@@ -21,31 +21,31 @@ if ($urlexists === TRUE) {
(\/(?:[\w\-]+\?v=|embed\/|v\/)?) # Parameters (embed, v)
([\w\-]+) # Video id of 11
(\S+)?$/mx';
- preg_match($rx, $baselink, $match);
+ preg_match( $rx, $baselink, $match );
// Testing if id → 11 characters
- if (strlen($match[5]) == 11) {
+ if ( strlen( $match[5] ) == 11 ) {
$video_id = $match[5];
} else {
- header('Location: index.php');
+ header( 'Location: index.php' );
}
} else {
- header('Location: index.php');
+ header( 'Location: index.php' );
}
-$video_string = file_get_contents("https://invidio.us/api/v1/videos/{$video_id}");
+$video_string = file_get_contents( "https://invidio.us/api/v1/videos/{$video_id}" );
-$video_info = json_decode($video_string);
+$video_info = json_decode( $video_string );
$videoTitle = $video_info->title;
$videoAuthor = $video_info->author;
$videoDurationSecs = $video_info->lengthSeconds;
-$videoDuration = secToDuration($videoDurationSecs);
+$videoDuration = secToDuration( $videoDurationSecs );
$videoChannel = $video_info->author;
// Begin_ViewCount
$extract_video_view = $video_info->viewCount;
-$videoViews = bytes($extract_video_view);
+$videoViews = bytes( $extract_video_view );
// End_ViewCount
// change hqdefault.jpg to default.jpg for downgrading the thumbnail quality
@@ -60,7 +60,7 @@ $downloads = $video_info->formatStreams;
///// Beaking DRM!!!
// Check standar video into URL
-$url_standar = video_exists($streamFormats[0]->url);
+$url_standar = video_exists( $streamFormats[0]->url );
// format video DRM
$formatdrm = $streamFormats[0]->type;
@@ -70,8 +70,8 @@ $node1 = "https://invidious.snopyta.org/latest_version?id={$video_id}&itag=18&lo
// explain DRM
$drmv = "https://archive.org/download/libreweb/rms-drm.webm";
-$node0on = video_exists($node0);
-$node1on = video_exists($node1);
+$node0on = video_exists( $node0 );
+$node1on = video_exists( $node1 );
// check nodes
if ( $node0on === TRUE ) {
@@ -83,9 +83,9 @@ if ( $node0on === TRUE ) {
$formatdrm = 'video/webm';
}
-if ($url_standar === FALSE) {
+if ( $url_standar === FALSE ) {
// Liberty data
- $breakquality = trim($streamFormats[0]->resolution, 'p');
+ $breakquality = trim( $streamFormats[0]->resolution, 'p' );
$breaklink = <<<EOT
<source data-res="{$breakquality}" src="{$breakurl}" type='{$formatdrm}'/>
EOT;