Bugzilla – Attachment 79833 Details for
Bug 20783
Cannot embed some YouTube videos due to 403 errors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20783: Cannot embed some YouTube videos due to 403 errors
Bug-20783-Cannot-embed-some-YouTube-videos-due-to-.patch (text/plain), 8.95 KB, created by
Owen Leonard
on 2018-10-02 16:44:02 UTC
(
hide
)
Description:
Bug 20783: Cannot embed some YouTube videos due to 403 errors
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2018-10-02 16:44:02 UTC
Size:
8.95 KB
patch
obsolete
>From fbab4aebac0e01837a8afc1e921c6791f8fb7109 Mon Sep 17 00:00:00 2001 >From: Juan Romay Sieira <juan.sieira@xercode.es> >Date: Fri, 18 May 2018 20:47:20 +0200 >Subject: [PATCH] Bug 20783: Cannot embed some YouTube videos due to 403 errors >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >YouTube videos are embeded instead of played with its videoplayback >URL, that can throw a 403 error > >To test the patch you have to: > * Install a new package: HTML::Video::Embed > * Rebuild the OPAC CSS (https://wiki.koha-community.org/wiki/Working_with_SCSS_in_the_OPAC_and_staff_client) > * Enable the syspref HTML5MediaEnabled to some interface, and > HTML5MediaYouTube to embed videos. > * Edit a biblio and put some youtube video in a 856u field. > * Check it in OPAC or INTRANET. > >The video https://www.youtube.com/watch?v=haT8g7oKnns can not be played >before the patch, but after it has no problems. > >Sponsored-by: UCA - Universidad de Cádiz >--- > C4/HTML5Media.pm | 30 ++++++++++------------ > C4/Installer/PerlDependencies.pm | 6 ++--- > .../prog/en/modules/catalogue/detail.tt | 12 ++++++--- > koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss | 9 +++++++ > .../opac-tmpl/bootstrap/en/modules/opac-detail.tt | 14 ++++++---- > 5 files changed, 42 insertions(+), 29 deletions(-) > >diff --git a/C4/HTML5Media.pm b/C4/HTML5Media.pm >index 1ac22f1..af03bdb 100644 >--- a/C4/HTML5Media.pm >+++ b/C4/HTML5Media.pm >@@ -50,7 +50,7 @@ sub gethtml5media { > my @HTML5MediaExtensions = split( /\|/, C4::Context->preference("HTML5MediaExtensions") ); > my $HTML5MediaYouTube = C4::Context->preference("HTML5MediaYouTube"); > my $marcflavour = C4::Context->preference("marcflavour"); >- my $isyoutube = 0; >+ my $is_embed = 0; > foreach my $HTML5Media_field (@HTML5Media_fields) { > my %HTML5Media; > # protocol >@@ -99,19 +99,19 @@ sub gethtml5media { > if ( $HTML5Media_field->subfield('u') ) { > $HTML5Media{srcblock} = $HTML5Media_field->subfield('u'); > if (grep /youtu\.?be/, $HTML5Media_field->subfield('u') ) { >+ $HTML5Media{srcblock} = ""; > if ($HTML5MediaYouTube == 1) { >- require WWW::YouTube::Download; >- import WWW::YouTube::Download qw(playback_url); >- my $youtube = WWW::YouTube::Download->new; >+ use HTML::Video::Embed; >+ my $embedder = HTML::Video::Embed->new({ >+ class => 'html5-embed-video' >+ }); >+ > eval { >- $HTML5Media{srcblock} = $youtube->playback_url( >- $HTML5Media_field->subfield('u'), { >- 'fmt' => '43' #webm is the only format compatible to all modern browsers. maybe check for available qualities >- } >- ); >+ my $html_embed_code = $embedder->url_to_embed( $HTML5Media_field->subfield('u') ); >+ $HTML5Media{embed} = $html_embed_code; > }; > if ($@) { warn $@; } >- else { $isyoutube = 1;} >+ else { $is_embed = 1;} > } > else { > next; # do not embed youtube videos >@@ -145,13 +145,9 @@ sub gethtml5media { > else { > $HTML5Media{extension} = ($HTML5Media{srcblock} =~ m/([^.]+)$/)[0]; > } >- if ( ( !grep /\Q$HTML5Media{extension}\E/, @HTML5MediaExtensions ) && ( $isyoutube != 1) ) { >+ if ( ( !grep /\Q$HTML5Media{extension}\E/, @HTML5MediaExtensions ) && ( $is_embed != 1) ) { > next; # not a specified media file > } >- # youtube >- if ($isyoutube == 1) { >- $HTML5Media{mime} = 'video/webm'; >- } > # mime > if ( $HTML5Media_field->subfield('c') ) { > $HTML5Media{codecs} = $HTML5Media_field->subfield('c'); >@@ -222,7 +218,7 @@ sub gethtml5media { > $HTML5Media{type} = 'track'; > } > # push >- if ( $HTML5Media{srcblock} && $HTML5Media{type} ) { >+ if ( ($HTML5Media{srcblock} && $HTML5Media{type}) || $HTML5Media{embed} ) { > push (@HTML5Media_sets, \%HTML5Media); > } > } >@@ -252,7 +248,7 @@ sub gethtml5media { > } > > return ( >- HTML5MediaEnabled => ( (scalar(@HTML5Media_sets) > 0) && ($HTML5MediaParent) ), >+ HTML5MediaEnabled => ( (scalar(@HTML5Media_sets) > 0 && $HTML5MediaParent) || $is_embed ), > HTML5MediaSets => \@HTML5Media_sets, > HTML5MediaParent => $HTML5MediaParent, > HTML5MediaWidth => $HTML5MediaWidth, >diff --git a/C4/Installer/PerlDependencies.pm b/C4/Installer/PerlDependencies.pm >index 2525a6b..ff1e2b5 100644 >--- a/C4/Installer/PerlDependencies.pm >+++ b/C4/Installer/PerlDependencies.pm >@@ -782,10 +782,10 @@ our $PERL_DEPS = { > 'required' => '1', > 'min_ver' => '1.10', > }, >- 'WWW::YouTube::Download' => { >- 'usage' => 'HTML5Media streaming from YouTube', >+ 'HTML::Video::Embed' => { >+ 'usage' => 'Convert a url into a html embed string', > 'required' => '0', >- 'min_ver' => '0.56', >+ 'min_ver' => '0.016000', > }, > 'Net::SFTP::Foreign' => { > 'usage' => 'Edifact', >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >index 4dddbe4..0bc9b53 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -828,10 +828,14 @@ > <div id="html5media"> > [% FOREACH HTML5MediaSet IN HTML5MediaSets %] > <p> >- <[% HTML5MediaParent | html %] controls preload=none> >- <[% HTML5MediaSet.child | html %] src="[% HTML5MediaSet.srcblock | html %]"[% HTML5MediaSet.typeblock | html %] /> >- [[% HTML5MediaParent | html %] tag not supported by your browser.] >- </[% HTML5MediaParent | html %]> >+ [% IF (HTML5MediaSet.embed) %] >+ [% HTML5MediaSet.embed | $raw %] >+ [% ELSE %] >+ <[% HTML5MediaParent | html %] controls preload=none> >+ <[% HTML5MediaSet.child | html %] src="[% HTML5MediaSet.srcblock | html %]"[% HTML5MediaSet.typeblock | html %] /> >+ [[% HTML5MediaParent | html %] tag not supported by your browser.] >+ </[% HTML5MediaParent | html %]> >+ [% END %] > </p> > [% END %] > </div> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss >index c5075d5..ca7ea89 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss >+++ b/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss >@@ -3016,4 +3016,13 @@ button.closebtn { > } > } > >+video { >+ width: 480px; >+} >+ >+.html5-embed-video { >+ width: 480px; >+ height: 300px; >+} >+ > @import "responsive"; >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >index 5decf72..dcaff50 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >@@ -1003,11 +1003,15 @@ > <div id="html5media"> > [% FOREACH HTML5MediaSet IN HTML5MediaSets %] > <p> >- [% SET ctrl_preload = ' controls preload=none' #translatability %] >- <[% HTML5MediaParent _ ctrl_preload | html %] > >- <[% HTML5MediaSet.child | html %] src="[% HTML5MediaSet.srcblock | html %]"[% HTML5MediaSet.typeblock | html %] /> >- <span>[[% HTML5MediaParent | html %] tag not supported by your browser.]</span> >- </[% HTML5MediaParent | html %]> >+ [% IF (HTML5MediaSet.embed) %] >+ [% HTML5MediaSet.embed | $raw %] >+ [% ELSE %] >+ [% SET ctrl_preload = ' controls preload=none' #translatability %] >+ <[% HTML5MediaParent _ ctrl_preload | html %] > >+ <[% HTML5MediaSet.child | html %] src="[% HTML5MediaSet.srcblock | html %]"[% HTML5MediaSet.typeblock | html %] /> >+ <span>[[% HTML5MediaParent | html %] tag not supported by your browser.]</span> >+ </[% HTML5MediaParent | html %]> >+ [% END %] > </p> > [% END %] > </div> >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20783
:
75441
|
75442
|
75443
|
79829
|
79833
|
104747
|
104748
|
104771
|
104774
|
104779
|
104780
|
104781
|
104799
|
104800
|
105198
|
105210
|
105211
|
105212
|
105213
|
111177
|
111178
|
111179