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

(-)a/C4/HTML5Media.pm (-3 / +25 lines)
Lines 23-28 use warnings; Link Here
23
use C4::Context;
23
use C4::Context;
24
use MARC::Field;
24
use MARC::Field;
25
use Koha::Upload;
25
use Koha::Upload;
26
use WWW::YouTube::Download qw(playback_url);
26
27
27
=head1 HTML5Media
28
=head1 HTML5Media
28
29
Lines 48-54 sub gethtml5media { Link Here
48
    my $HTML5MediaParent;
49
    my $HTML5MediaParent;
49
    my $HTML5MediaWidth;
50
    my $HTML5MediaWidth;
50
    my @HTML5MediaExtensions = split( /\|/, C4::Context->preference("HTML5MediaExtensions") );
51
    my @HTML5MediaExtensions = split( /\|/, C4::Context->preference("HTML5MediaExtensions") );
52
    my $HTML5MediaYouTube    = C4::Context->preference("HTML5MediaYouTube");
51
    my $marcflavour          = C4::Context->preference("marcflavour");
53
    my $marcflavour          = C4::Context->preference("marcflavour");
54
    my $isyoutube            = 0;
52
    foreach my $HTML5Media_field (@HTML5Media_fields) {
55
    foreach my $HTML5Media_field (@HTML5Media_fields) {
53
        my %HTML5Media;
56
        my %HTML5Media;
54
        # protocol
57
        # protocol
Lines 96-107 sub gethtml5media { Link Here
96
        # src
99
        # src
97
        if ( $HTML5Media_field->subfield('u') ) {
100
        if ( $HTML5Media_field->subfield('u') ) {
98
            $HTML5Media{srcblock} = $HTML5Media_field->subfield('u');
101
            $HTML5Media{srcblock} = $HTML5Media_field->subfield('u');
102
            if (grep /youtube/, $HTML5Media_field->subfield('u') ) { # TODO is there an official YT URL shortener? Can we use that too?
103
                if ($HTML5MediaYouTube == 1) {
104
                    my $youtube           = WWW::YouTube::Download->new;
105
                    $HTML5Media{srcblock} = $youtube->playback_url(
106
                        $HTML5Media_field->subfield('u'), {
107
                            'fmt' => '43' #webm is the only format compatible to all modern browsers. maybe check for available qualities
108
                        }
109
                    );
110
                    # TODO handle error if format not availabe. Does that ever occur?
111
                    $isyoutube = 1;
112
                }
113
               else {
114
                   next; # do not embed youtube videos
115
               }
116
            }
99
        }
117
        }
100
        elsif ( $HTML5Media_field->subfield('a') && $HTML5Media_field->subfield('d') && $HTML5Media_field->subfield('f') ) {
118
        elsif ( $HTML5Media_field->subfield('a') && $HTML5Media_field->subfield('d') && $HTML5Media_field->subfield('f') ) {
101
            $HTML5Media{host}        = $HTML5Media_field->subfield('a');
119
            $HTML5Media{host}        = $HTML5Media_field->subfield('a');
102
            $HTML5Media{host}        =~ s/(^\/|\/$)//g;
120
            $HTML5Media{host}        =~ s/(^\/|\/$)//g;
103
            $HTML5Media{path}        = $HTML5Media_field->subfield('d');
121
            $HTML5Media{path}        = $HTML5Media_field->subfield('d');
104
            $HTML5Media{path}        =~ s/(^\/|\/$)//g;
122
            $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');
123
            $HTML5Media{file}        = $HTML5Media_field->subfield('f');
106
            $HTML5Media{srcblock}    = $HTML5Media{protocol} . '://' . $HTML5Media{loginblock} . $HTML5Media{host} . $HTML5Media{portblock} . '/' . $HTML5Media{path} . '/' . $HTML5Media{file};
124
            $HTML5Media{srcblock}    = $HTML5Media{protocol} . '://' . $HTML5Media{loginblock} . $HTML5Media{host} . $HTML5Media{portblock} . '/' . $HTML5Media{path} . '/' . $HTML5Media{file};
107
        }
125
        }
Lines 122-130 sub gethtml5media { Link Here
122
        else {
140
        else {
123
            $HTML5Media{extension} = ($HTML5Media{srcblock} =~ m/([^.]+)$/)[0];
141
            $HTML5Media{extension} = ($HTML5Media{srcblock} =~ m/([^.]+)$/)[0];
124
        }
142
        }
125
        if ( !grep /\Q$HTML5Media{extension}\E/, @HTML5MediaExtensions ) {
143
        if ( ( !grep /\Q$HTML5Media{extension}\E/, @HTML5MediaExtensions ) && ( $isyoutube != 1) ) {
126
            next; # not a specified media file
144
            next; # not a specified media file
127
        }
145
        }
146
        # youtube
147
        if ($isyoutube == 1) {
148
                $HTML5Media{mime} = 'video/webm';
149
        }
128
        # mime
150
        # mime
129
        if ( $HTML5Media_field->subfield('c') ) {
151
        if ( $HTML5Media_field->subfield('c') ) {
130
            $HTML5Media{codecs} = $HTML5Media_field->subfield('c');
152
            $HTML5Media{codecs} = $HTML5Media_field->subfield('c');
Lines 156-162 sub gethtml5media { Link Here
156
            }
178
            }
157
            if ( $HTML5Media{extension} eq 'oga' ) {
179
            if ( $HTML5Media{extension} eq 'oga' ) {
158
                $HTML5Media{mime} = 'audio/ogg';
180
                $HTML5Media{mime} = 'audio/ogg';
159
              $HTML5Media{codecs} = 'vorbis';
181
                $HTML5Media{codecs} = 'vorbis';
160
            }
182
            }
161
            elsif ( $HTML5Media{extension} eq 'spx' ) {
183
            elsif ( $HTML5Media{extension} eq 'spx' ) {
162
                $HTML5Media{mime} = 'audio/ogg';
184
                $HTML5Media{mime} = 'audio/ogg';
(-)a/C4/Installer/PerlDependencies.pm (+5 lines)
Lines 822-827 our $PERL_DEPS = { Link Here
822
        'required' => '0',
822
        'required' => '0',
823
        'min_ver'  => '0.03',
823
        'min_ver'  => '0.03',
824
    },
824
    },
825
    'WWW::YouTube::Download' => {
826
        'usage'    => 'HTML5Media streaming from YouTube',
827
        'required' => '0',
828
        'min_ver'  => '0.56',
829
    },
825
};
830
};
826
831
827
1;
832
1;
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 163-168 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
163
('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'),
163
('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'),
164
('HTML5MediaEnabled','not','not|opac|staff|both','Show a tab with a HTML5 media player for files catalogued in field 856','Choice'),
164
('HTML5MediaEnabled','not','not|opac|staff|both','Show a tab with a HTML5 media player for files catalogued in field 856','Choice'),
165
('HTML5MediaExtensions','webm|ogg|ogv|oga|vtt','','Media file extensions','free'),
165
('HTML5MediaExtensions','webm|ogg|ogv|oga|vtt','','Media file extensions','free'),
166
('HTML5MediaYouTube',0','Embed|Don\'t embed','YouTube links as videos','YesNo'),
166
('IDreamBooksReadometer','0','','Display Readometer from IDreamBooks.com','YesNo'),
167
('IDreamBooksReadometer','0','','Display Readometer from IDreamBooks.com','YesNo'),
167
('IDreamBooksResults','0','','Display IDreamBooks.com rating in search results','YesNo'),
168
('IDreamBooksResults','0','','Display IDreamBooks.com rating in search results','YesNo'),
168
('IDreamBooksReviews','0','','Display book review snippets from IDreamBooks.com','YesNo'),
169
('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