Bugzilla – Attachment 47369 Details for
Bug 14168
enhance streaming cataloging to include youtube
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 14168 - enhance streaming cataloging to include youtube
SIGNED-OFF-Bug-14168---enhance-streaming-catalogin.patch (text/plain), 6.97 KB, created by
Aleisha Amohia
on 2016-01-28 00:38:26 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 14168 - enhance streaming cataloging to include youtube
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2016-01-28 00:38:26 UTC
Size:
6.97 KB
patch
obsolete
>From ed28a5a4e9adb26c7472c874fd9e6daf8b76098a Mon Sep 17 00:00:00 2001 >From: Mirko Tietgen <mirko@abunchofthings.net> >Date: Thu, 22 Oct 2015 19:39:37 +0200 >Subject: [PATCH] [SIGNED-OFF] Bug 14168 - enhance streaming cataloging to > include youtube > >Add optional embedding of YouTube videos via HTML5Media. >New syspref: HTML5MediaYouTube: Embed/Don't embed videos. >Format WEBM is hardcoded as it is the only format accepted by all >modern browsers. > >Test plan: >- apply patch >- catalogue a YouTube link in 856$u >- turn on HTML5MediaEnabled and HTML5MediaYouTube >- open the record in OPAC and staff client, check that the > 'Play media' tab is showing and playing the video works. > >Possible enhancements for followups: >- check available formats, offer quality choice >- accept official YT URL shortener > >Signed-off-by: Aleisha <aleishaamohia@hotmail.com> >Works perfectly! >--- > C4/HTML5Media.pm | 28 +++++++++++++++++--- > C4/Installer/PerlDependencies.pm | 5 ++++ > installer/data/mysql/sysprefs.sql | 1 + > .../admin/preferences/enhanced_content.pref | 6 +++++ > 4 files changed, 37 insertions(+), 3 deletions(-) > >diff --git a/C4/HTML5Media.pm b/C4/HTML5Media.pm >index a53922e..1094aa9 100644 >--- a/C4/HTML5Media.pm >+++ b/C4/HTML5Media.pm >@@ -23,6 +23,7 @@ use warnings; > use C4::Context; > use MARC::Field; > use Koha::Upload; >+use WWW::YouTube::Download qw(playback_url); > > =head1 HTML5Media > >@@ -48,7 +49,9 @@ sub gethtml5media { > my $HTML5MediaParent; > my $HTML5MediaWidth; > my @HTML5MediaExtensions = split( /\|/, C4::Context->preference("HTML5MediaExtensions") ); >+ my $HTML5MediaYouTube = C4::Context->preference("HTML5MediaYouTube"); > my $marcflavour = C4::Context->preference("marcflavour"); >+ my $isyoutube = 0; > foreach my $HTML5Media_field (@HTML5Media_fields) { > my %HTML5Media; > # protocol >@@ -96,12 +99,27 @@ sub gethtml5media { > # src > if ( $HTML5Media_field->subfield('u') ) { > $HTML5Media{srcblock} = $HTML5Media_field->subfield('u'); >+ if (grep /youtube/, $HTML5Media_field->subfield('u') ) { # TODO is there an official YT URL shortener? Can we use that too? >+ if ($HTML5MediaYouTube == 1) { >+ my $youtube = WWW::YouTube::Download->new; >+ $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 >+ } >+ ); >+ # TODO handle error if format not availabe. Does that ever occur? >+ $isyoutube = 1; >+ } >+ else { >+ next; # do not embed youtube videos >+ } >+ } > } > elsif ( $HTML5Media_field->subfield('a') && $HTML5Media_field->subfield('d') && $HTML5Media_field->subfield('f') ) { > $HTML5Media{host} = $HTML5Media_field->subfield('a'); > $HTML5Media{host} =~ s/(^\/|\/$)//g; > $HTML5Media{path} = $HTML5Media_field->subfield('d'); >- $HTML5Media{path} =~ s/(^\/|\/$)//g; >+ $HTML5Media{path} =~ s/(^\/|\/$)//g; # TODO we could check for youtube here too, but nobody uses these fields anyway⦠> $HTML5Media{file} = $HTML5Media_field->subfield('f'); > $HTML5Media{srcblock} = $HTML5Media{protocol} . '://' . $HTML5Media{loginblock} . $HTML5Media{host} . $HTML5Media{portblock} . '/' . $HTML5Media{path} . '/' . $HTML5Media{file}; > } >@@ -122,9 +140,13 @@ sub gethtml5media { > else { > $HTML5Media{extension} = ($HTML5Media{srcblock} =~ m/([^.]+)$/)[0]; > } >- if ( !grep /\Q$HTML5Media{extension}\E/, @HTML5MediaExtensions ) { >+ if ( ( !grep /\Q$HTML5Media{extension}\E/, @HTML5MediaExtensions ) && ( $isyoutube != 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'); >@@ -156,7 +178,7 @@ sub gethtml5media { > } > if ( $HTML5Media{extension} eq 'oga' ) { > $HTML5Media{mime} = 'audio/ogg'; >- $HTML5Media{codecs} = 'vorbis'; >+ $HTML5Media{codecs} = 'vorbis'; > } > elsif ( $HTML5Media{extension} eq 'spx' ) { > $HTML5Media{mime} = 'audio/ogg'; >diff --git a/C4/Installer/PerlDependencies.pm b/C4/Installer/PerlDependencies.pm >index 778e101..21b4f03 100644 >--- a/C4/Installer/PerlDependencies.pm >+++ b/C4/Installer/PerlDependencies.pm >@@ -787,6 +787,11 @@ our $PERL_DEPS = { > 'required' => '0', > 'min_ver' => '0.03', > }, >+ 'WWW::YouTube::Download' => { >+ 'usage' => 'HTML5Media streaming from YouTube', >+ 'required' => '0', >+ 'min_ver' => '0.56', >+ }, > }; > > 1; >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index aa53139..fc3efcb 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -163,6 +163,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('HomeOrHoldingBranch','holdingbranch','holdingbranch|homebranch','Used by Circulation to determine which branch of an item to check with independent branches on, and by search to determine which branch to choose for availability ','Choice'), > ('HTML5MediaEnabled','not','not|opac|staff|both','Show a tab with a HTML5 media player for files catalogued in field 856','Choice'), > ('HTML5MediaExtensions','webm|ogg|ogv|oga|vtt','','Media file extensions','free'), >+('HTML5MediaYouTube',0','Embed|Don\'t embed','YouTube links as videos','YesNo'), > ('IDreamBooksReadometer','0','','Display Readometer from IDreamBooks.com','YesNo'), > ('IDreamBooksResults','0','','Display IDreamBooks.com rating in search results','YesNo'), > ('IDreamBooksReviews','0','','Display book review snippets from IDreamBooks.com','YesNo'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref >index 1e68153..8b8ca2b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref >@@ -319,6 +319,12 @@ Enhanced Content: > - pref: HTML5MediaExtensions > class: multi > - (separated with |). >+ - >+ - pref: HTML5MediaYouTube >+ choices: >+ yes: "Embed" >+ no: "Don't embed" >+ - YouTube links as videos. > Plugins: > - > - pref: UseKohaPlugins >-- >1.7.10.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 14168
:
45331
|
45333
|
45339
|
47327
|
47369
|
47403
|
47459
|
47460
|
48542
|
48586
|
48587
|
48637
|
48643
|
48644