View | Details | Raw Unified | Return to bug 14168
Collapse All | Expand All

(-)a/C4/HTML5Media.pm (-6 / +27 lines)
Lines 1-6 Link Here
1
package C4::HTML5Media;
1
package C4::HTML5Media;
2
2
3
# Copyright 2012 Mirko Tietgen
3
# Copyright 2012/2015 Mirko Tietgen
4
#
4
#
5
# This file is part of Koha.
5
# This file is part of Koha.
6
#
6
#
Lines 22-28 use warnings; Link Here
22
22
23
use C4::Context;
23
use C4::Context;
24
use MARC::Field;
24
use MARC::Field;
25
25
use WWW::YouTube::Download qw(playback_url);
26
26
27
=head1 HTML5Media
27
=head1 HTML5Media
28
28
Lines 48-54 sub gethtml5media { Link Here
48
    my $HTML5MediaParent;
48
    my $HTML5MediaParent;
49
    my $HTML5MediaWidth;
49
    my $HTML5MediaWidth;
50
    my @HTML5MediaExtensions = split( /\|/, C4::Context->preference("HTML5MediaExtensions") );
50
    my @HTML5MediaExtensions = split( /\|/, C4::Context->preference("HTML5MediaExtensions") );
51
    my $HTML5MediaYouTube    = C4::Context->preference("HTML5MediaYouTube");
51
    my $marcflavour          = C4::Context->preference("marcflavour");
52
    my $marcflavour          = C4::Context->preference("marcflavour");
53
    my $isyoutube            = 0;
52
    foreach my $HTML5Media_field (@HTML5Media_fields) {
54
    foreach my $HTML5Media_field (@HTML5Media_fields) {
53
        my %HTML5Media;
55
        my %HTML5Media;
54
        # protocol
56
        # protocol
Lines 96-118 sub gethtml5media { Link Here
96
        # src
98
        # src
97
        if ( $HTML5Media_field->subfield('u') ) {
99
        if ( $HTML5Media_field->subfield('u') ) {
98
            $HTML5Media{srcblock} = $HTML5Media_field->subfield('u');
100
            $HTML5Media{srcblock} = $HTML5Media_field->subfield('u');
101
            if (grep /youtube/, $HTML5Media_field->subfield('u') ) { # TODO is there an official YT URL shortener? Can we use that too?
102
                if ($HTML5MediaYouTube == 1) {
103
                    my $youtube           = WWW::YouTube::Download->new;
104
                    $HTML5Media{srcblock} = $youtube->playback_url(
105
                        $HTML5Media_field->subfield('u'), { 
106
                            'fmt' => '43' #webm is the only format compatible to all modern browsers. maybe check for available qualities
107
                        }
108
                    );
109
                    # TODO handle error if format not availabe. Does that ever occur?
110
                    $isyoutube = 1;
111
                }
112
               else {
113
                   next; # do not embed youtube videos
114
               }
115
            }
99
        }
116
        }
100
        elsif ( $HTML5Media_field->subfield('a') && $HTML5Media_field->subfield('d') && $HTML5Media_field->subfield('f') ) {
117
        elsif ( $HTML5Media_field->subfield('a') && $HTML5Media_field->subfield('d') && $HTML5Media_field->subfield('f') ) {
101
            $HTML5Media{host}        = $HTML5Media_field->subfield('a');
118
            $HTML5Media{host}        = $HTML5Media_field->subfield('a');
102
            $HTML5Media{host}        =~ s/(^\/|\/$)//g;
119
            $HTML5Media{host}        =~ s/(^\/|\/$)//g;
103
            $HTML5Media{path}        = $HTML5Media_field->subfield('d');
120
            $HTML5Media{path}        = $HTML5Media_field->subfield('d');
104
            $HTML5Media{path}        =~ s/(^\/|\/$)//g;
121
            $HTML5Media{path}        =~ s/(^\/|\/$)//g; # TODO we could check for youtube here too, but nobody uses these fields anyway…
105
            $HTML5Media{file}        = $HTML5Media_field->subfield('f');
122
            $HTML5Media{file}        = $HTML5Media_field->subfield('f');
106
            $HTML5Media{srcblock}    = $HTML5Media{protocol} . '://' . $HTML5Media{loginblock} . $HTML5Media{host} . $HTML5Media{portblock} . '/' . $HTML5Media{path} . '/' . $HTML5Media{file};
123
            $HTML5Media{srcblock}    = $HTML5Media{protocol} . '://' . $HTML5Media{loginblock} . $HTML5Media{host} . $HTML5Media{portblock} . '/' . $HTML5Media{path} . '/' . $HTML5Media{file};
107
        }
124
        }
108
        else {
125
        else {
109
            next; # no file to play
126
            next; # no file to play
110
        }
127
        }
111
        # extension
128
        # extension or youtube
112
        $HTML5Media{extension} = ($HTML5Media{srcblock} =~ m/([^.]+)$/)[0];
129
        $HTML5Media{extension} = ($HTML5Media{srcblock} =~ m/([^.]+)$/)[0];
113
        if ( !grep /\Q$HTML5Media{extension}\E/, @HTML5MediaExtensions ) {
130
        if ( ( !grep /\Q$HTML5Media{extension}\E/, @HTML5MediaExtensions ) && ( $isyoutube != 1) ) {
114
            next; # not a specified media file
131
            next; # not a specified media file
115
        }
132
        }
133
        # youtube
134
        if ($isyoutube == 1) {
135
                $HTML5Media{mime} = 'video/webm';
136
        }
116
        # mime
137
        # mime
117
        if ( $HTML5Media_field->subfield('c') ) {
138
        if ( $HTML5Media_field->subfield('c') ) {
118
            $HTML5Media{codecs} = $HTML5Media_field->subfield('c');
139
            $HTML5Media{codecs} = $HTML5Media_field->subfield('c');
Lines 144-150 sub gethtml5media { Link Here
144
            }
165
            }
145
            if ( $HTML5Media{extension} eq 'oga' ) {
166
            if ( $HTML5Media{extension} eq 'oga' ) {
146
                $HTML5Media{mime} = 'audio/ogg';
167
                $HTML5Media{mime} = 'audio/ogg';
147
              $HTML5Media{codecs} = 'vorbis';
168
                $HTML5Media{codecs} = 'vorbis';
148
            }
169
            }
149
            elsif ( $HTML5Media{extension} eq 'spx' ) {
170
            elsif ( $HTML5Media{extension} eq 'spx' ) {
150
                $HTML5Media{mime} = 'audio/ogg';
171
                $HTML5Media{mime} = 'audio/ogg';
(-)a/C4/Installer/PerlDependencies.pm (+5 lines)
Lines 782-787 our $PERL_DEPS = { Link Here
782
        'required' => '1',
782
        'required' => '1',
783
        'min_ver'  => '1.10',
783
        'min_ver'  => '1.10',
784
    },
784
    },
785
    'WWW::YouTube::Download' => {
786
        'usage'    => 'HTML5Media streaming from YouTube',
787
        'required' => '0',
788
        'min_ver'  => '0.56',
789
    },
785
};
790
};
786
791
787
1;
792
1;
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 156-161 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
156
('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'),
156
('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'),
157
('HTML5MediaEnabled','not','not|opac|staff|both','Show a tab with a HTML5 media player for files catalogued in field 856','Choice'),
157
('HTML5MediaEnabled','not','not|opac|staff|both','Show a tab with a HTML5 media player for files catalogued in field 856','Choice'),
158
('HTML5MediaExtensions','webm|ogg|ogv|oga|vtt','','Media file extensions','free'),
158
('HTML5MediaExtensions','webm|ogg|ogv|oga|vtt','','Media file extensions','free'),
159
('HTML5MediaYouTube',0','Embed|Don\'t embed','YouTube links as videos','YesNo'),
159
('IDreamBooksReadometer','0','','Display Readometer from IDreamBooks.com','YesNo'),
160
('IDreamBooksReadometer','0','','Display Readometer from IDreamBooks.com','YesNo'),
160
('IDreamBooksResults','0','','Display IDreamBooks.com rating in search results','YesNo'),
161
('IDreamBooksResults','0','','Display IDreamBooks.com rating in search results','YesNo'),
161
('IDreamBooksReviews','0','','Display book review snippets from IDreamBooks.com','YesNo'),
162
('IDreamBooksReviews','0','','Display book review snippets from IDreamBooks.com','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref (-1 / +6 lines)
Lines 319-324 Enhanced Content: Link Here
319
            - pref: HTML5MediaExtensions
319
            - pref: HTML5MediaExtensions
320
              class: multi
320
              class: multi
321
            - (separated with |).
321
            - (separated with |).
322
        -
323
            - pref: HTML5MediaYouTube
324
              choices:
325
                  yes: "Embed"
326
                  no: "Don't embed"
327
            - YouTube links as videos.
322
    Plugins:
328
    Plugins:
323
        -
329
        -
324
            - pref: UseKohaPlugins
330
            - pref: UseKohaPlugins
325
- 

Return to bug 14168