Bugzilla – Attachment 75443 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]
Patch to embed youtube videos
Bug-20783-Cannot-embed-some-YouTube-videos-due-to-40.patch (text/plain), 8.85 KB, created by
Juan Romay Sieira
on 2018-05-18 18:48:38 UTC
(
hide
)
Description:
Patch to embed youtube videos
Filename:
MIME Type:
Creator:
Juan Romay Sieira
Created:
2018-05-18 18:48:38 UTC
Size:
8.85 KB
patch
obsolete
>From 11e80cb4f68b92d11bb8fa24b5f779467a652b05 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] =?UTF-8?q?Bug=2020783=20-=20Cannot=20embed=20some=20YouTu?= > =?UTF-8?q?be=20videos=20due=20to=20403=20errors=20Sponsored-by:=20UCA=20-?= > =?UTF-8?q?=20Universidad=20de=20C=C3=A1diz?= >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit >Content-Type: text/plain; charset="utf-8" > >YouTube videos are embeded instead of played with its videoplayback URL, that can throw a 403 error >--- > C4/HTML5Media.pm | 30 ++++++++++------------ > C4/Installer/PerlDependencies.pm | 6 ++--- > koha-tmpl/intranet-tmpl/prog/css/staff-global.css | 5 ++++ > .../prog/en/modules/catalogue/detail.tt | 12 ++++++--- > .../opac-tmpl/bootstrap/en/modules/opac-detail.tt | 14 ++++++---- > koha-tmpl/opac-tmpl/bootstrap/less/opac.less | 7 +++++ > 6 files changed, 45 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 130740c..3240b3d 100644 >--- a/C4/Installer/PerlDependencies.pm >+++ b/C4/Installer/PerlDependencies.pm >@@ -802,10 +802,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/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/css/staff-global.css >index c68bff6..d3231c0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css >+++ b/koha-tmpl/intranet-tmpl/prog/css/staff-global.css >@@ -2479,6 +2479,11 @@ video { > width: 480px; > } > >+.html5-embed-video { >+ width: 480px; >+ height: 300px; >+} >+ > /* Bootstrap overrides */ > button, > .btn { >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 ec6695c..ea76058 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -795,10 +795,14 @@ > <div id="html5media"> > [% FOREACH HTML5MediaSet IN HTML5MediaSets %] > <p> >- <[% HTML5MediaParent %] controls preload=none> >- <[% HTML5MediaSet.child %] src="[% HTML5MediaSet.srcblock %]"[% HTML5MediaSet.typeblock %] /> >- [[% HTML5MediaParent %] tag not supported by your browser.] >- </[% HTML5MediaParent %]> >+ [% IF (HTML5MediaSet.embed) %] >+ [% HTML5MediaSet.embed %] >+ [% ELSE %] >+ <[% HTML5MediaParent %] controls preload=none> >+ <[% HTML5MediaSet.child %] src="[% HTML5MediaSet.srcblock %]"[% HTML5MediaSet.typeblock %] /> >+ [[% HTML5MediaParent %] tag not supported by your browser.] >+ </[% HTML5MediaParent %]> >+ [% END %] > </p> > [% END %] > </div> >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 121fe6d..e2b105b 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >@@ -1031,11 +1031,15 @@ > <div id="html5media"> > [% FOREACH HTML5MediaSet IN HTML5MediaSets %] > <p> >- [% SET ctrl_preload = ' controls preload=none' #translatability %] >- <[% HTML5MediaParent _ ctrl_preload %] > >- <[% HTML5MediaSet.child _ ' src="' _ HTML5MediaSet.srcblock _'"' _ HTML5MediaSet.typeblock %] /> >- <span>[[% HTML5MediaParent %] tag not supported by your browser.]</span> >- </[% HTML5MediaParent %]> >+ [% IF (HTML5MediaSet.embed) %] >+ [% HTML5MediaSet.embed %] >+ [% ELSE %] >+ [% SET ctrl_preload = ' controls preload=none' #translatability %] >+ <[% HTML5MediaParent _ ctrl_preload %] > >+ <[% HTML5MediaSet.child _ ' src="' _ HTML5MediaSet.srcblock _'"' _ HTML5MediaSet.typeblock %] /> >+ <span>[[% HTML5MediaParent %] tag not supported by your browser.]</span> >+ </[% HTML5MediaParent %]> >+ [% END %] > </p> > [% END %] > </div> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/less/opac.less b/koha-tmpl/opac-tmpl/bootstrap/less/opac.less >index 3cbfdb8..ed0b94d 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/less/opac.less >+++ b/koha-tmpl/opac-tmpl/bootstrap/less/opac.less >@@ -2636,6 +2636,13 @@ a.reviewlink:visited { > } > } > >+video { >+ width: 480px; >+} > >+.html5-embed-video { >+ width: 480px; >+ height: 300px; >+} > > @import "responsive.less"; >-- >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