From 8103275cffa5aeb2a38a46b6121545f622178c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Thu, 26 Nov 2020 20:37:46 -0500 Subject: Fix when live video --- index.php | 1 + templates/video.tpl | 5 +++-- tools/init.php | 9 ++++++--- tools/processor.php | 41 ++++++++++++++++++++++++++++------------- 4 files changed, 38 insertions(+), 18 deletions(-) diff --git a/index.php b/index.php index 93c1659..fabb62f 100644 --- a/index.php +++ b/index.php @@ -41,6 +41,7 @@ else // URL DRM $video_decode->assign("breakurl", $breakurl); + $video_decode->assign("islive", $islive); // Download DRM $video_decode->assign("downloadbreak", $downloadbreak); diff --git a/templates/video.tpl b/templates/video.tpl index 3d1cf49..dc818b8 100644 --- a/templates/video.tpl +++ b/templates/video.tpl @@ -108,14 +108,15 @@ oncontextmenu='{$videoTitle}' onmouseenter='{$videoTitle}' title='{$videoTitle}'> - {if $breaklink === TRUE} + {if $islive === True} +

Livestream videos are not yet supported.

+ {elseif $breaklink === TRUE} {else} {foreach $streamFormats as $stream} {/foreach} {/if} -

Lo siento, este navegador no soporta vĂ­deo en HTML5. Por favor, cambia o actualiza tu navegador web

diff --git a/tools/init.php b/tools/init.php index ce87fd8..4a0da64 100644 --- a/tools/init.php +++ b/tools/init.php @@ -39,11 +39,14 @@ function video_exists( $url ) { $result = FALSE; - foreach ( $headers as $hdr ) { - if ( preg_match( '/^HTTP\/\d\.\d\s+(403)/', $hdr ) ) { - $result = TRUE; // Found 403 Error + if (is_array($headers) || is_object($headers)) { + foreach ( $headers as $hdr ) { + if ( preg_match( '/^HTTP\/\d\.\d\s+(403|404)/', $hdr ) ) { + $result = TRUE; // Found 403 Error + } } } + if ( $result === TRUE ) { return FALSE; // Not exist video } else { diff --git a/tools/processor.php b/tools/processor.php index 85b4ff0..c3afdd1 100644 --- a/tools/processor.php +++ b/tools/processor.php @@ -15,17 +15,18 @@ $baselink = htmlspecialchars( $_GET['link'] ); $urlexists = url_exists( $baselink ); if ( $urlexists === TRUE ) { // Regex - filter URL id is match[5] - $rx = '/^((?:https?:)?\/\/)? # Optional protocol - ((?:www|m)[.])? # Optional sub-domain + $rx = '/^((?:https?:)?\/\/)? # Optional protocol + ((?:www|m)[.])? # Optional sub-domain ((?:youtube[.]com| youtu[.]be| invidio[.]us| invidiou[.]sh| invidious[.]kabi[.]tk| invidious[.]glie[.]town| - invidious[.]snopyta[.]org)) # URL supports - (\/(?:[\w\-]+\?v=|embed\/|v\/)?) # Parameters (embed, v) - ([\w\-]+) # Video id of 11 + yotter[.]conocimientoslibres[.]ga| + invidious[.]snopyta[.]org)) # URL supports + (\/(?:[\w\-]+\?v=|embed\/|v\/)?) # Parameters (embed, v) + ([\w\-]+) # Video id of 11 (\S+)?$/mx'; preg_match( $rx, $baselink, $match ); @@ -78,9 +79,16 @@ $streamFormats = $video_info->formatStreams; // Downloads $downloads = $video_info->formatStreams; +// Live +$islive = $video_info->liveNow; + ///// Beaking DRM!!! // Check standar video into URL -$url_standar = video_exists( $streamFormats[0]->url ); +if ( $islive === FALSE ) { + $url_standar = $streamFormats[0]->url; +} else { + $url_standar = FALSE; +} if ( $url_standar === FALSE ) { // nodes @@ -93,9 +101,6 @@ if ( $url_standar === FALSE ) { $node0on = video_exists( $node0 ); $node1on = video_exists( $node1 ); - // format video DRM - $formatdrm = $streamFormats[0]->type; - // check nodes if ( $node0on === TRUE ) { $breakurl = $node0; @@ -106,12 +111,22 @@ if ( $url_standar === FALSE ) { $formatdrm = 'video/webm'; } - // liberty data - $breakquality = trim( $streamFormats[0]->resolution, 'p' ); + // 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; - $downloadFormat = $downloads[0]->container; - $downloadQuality = $streamFormats[0]->resolution; $downloadbreak = TRUE; + } else { // clean variables $breakurl = NULL; -- cgit v1.2.3