diff options
author | Jesús <heckyel@hyperbola.info> | 2020-11-26 20:37:46 -0500 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2020-11-26 20:37:46 -0500 |
commit | 8103275cffa5aeb2a38a46b6121545f622178c41 (patch) | |
tree | ac878e10129cd7623f881778597b07cf9afa11ae | |
parent | c6cd7be07f72e3f437e61727962fa38229206a26 (diff) | |
download | ytlibre-8103275cffa5aeb2a38a46b6121545f622178c41.tar.lz ytlibre-8103275cffa5aeb2a38a46b6121545f622178c41.tar.xz ytlibre-8103275cffa5aeb2a38a46b6121545f622178c41.zip |
Fix when live video
-rw-r--r-- | index.php | 1 | ||||
-rw-r--r-- | templates/video.tpl | 5 | ||||
-rw-r--r-- | tools/init.php | 9 | ||||
-rw-r--r-- | tools/processor.php | 41 |
4 files changed, 38 insertions, 18 deletions
@@ -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} + <p> Livestream videos are not yet supported. </p> + {elseif $breaklink === TRUE} <source data-res="{$breakquality}" src="{$breakurl}" type='{$formatdrm}'/> {else} {foreach $streamFormats as $stream} <source data-res="{trim($stream->resolution, 'p')}" src="{$stream->url}" type='{$stream->type}'/> {/foreach} {/if} - <p>Lo siento, este navegador no soporta vídeo en HTML5. Por favor, cambia o actualiza tu navegador web</p> </video> </div> <!--Plyr--> 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; |