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

(-)a/C4/HTML5Media.pm (-9 / +10 lines)
Lines 98-115 sub gethtml5media { Link Here
98
        # src
98
        # src
99
        if ( $HTML5Media_field->subfield('u') ) {
99
        if ( $HTML5Media_field->subfield('u') ) {
100
            $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?
101
            if (grep /youtube|youtu[.]be/, $HTML5Media_field->subfield('u') ) {
102
                if ($HTML5MediaYouTube == 1) {
102
                if ($HTML5MediaYouTube == 1) {
103
                    require WWW::YouTube::Download;
103
                    require WWW::YouTube::Download;
104
                    import  WWW::YouTube::Download qw(playback_url);
104
                    import  WWW::YouTube::Download qw(playback_url);
105
                    my $youtube           = WWW::YouTube::Download->new;
105
                    my $youtube           = WWW::YouTube::Download->new;
106
                    $HTML5Media{srcblock} = $youtube->playback_url(
106
                    eval {
107
                        $HTML5Media_field->subfield('u'), {
107
                        $HTML5Media{srcblock} = $youtube->playback_url(
108
                            'fmt' => '43' #webm is the only format compatible to all modern browsers. maybe check for available qualities
108
                            $HTML5Media_field->subfield('u'), {
109
                        }
109
                                'fmt' => '43' #webm is the only format compatible to all modern browsers. maybe check for available qualities
110
                    );
110
                            }
111
                    # TODO handle error if format not available. Does that ever occur?
111
                        );
112
                    $isyoutube = 1;
112
                    };
113
                    if ($@) { warn $@; }
114
                    else  { $isyoutube = 1;}
113
                }
115
                }
114
               else {
116
               else {
115
                   next; # do not embed youtube videos
117
                   next; # do not embed youtube videos
116
- 

Return to bug 17231