FileGetter: Use full blown HTTP::UserAgent to set the User-Agent
[videosite.git] / videosite / YouTubeGrabber.pm
index ebb2f69..c23b17d 100644 (file)
@@ -20,12 +20,15 @@ use videosite::JSArrayParser;
 use strict;
 
 my %preflist = (
-    'insane' => [38, 37, 22, 35, 18, 34, 6, 5],
-    'hd' => [37, 22, 35, 18, 34, 6, 5, 38],
-    'h264' => [18, 34, 37, 22, 35, 6, 5, 38],
-    'high' => [34, 35, 18, 37, 22, 6, 5, 38],
-    'normal' => [6, 5, 34, 35, 18, 22, 37, 38]);
+    'insane' => [38, 37, 22, 35, 18, 34, 6, 5, 43],
+    'hd' => [37, 22, 35, 18, 34, 6, 5, 38, 43],
+    'h264' => [18, 34, 37, 22, 35, 6, 5, 38, 43],
+    'high' => [34, 35, 18, 37, 22, 6, 5, 38, 43],
+    'normal' => [6, 5, 34, 35, 18, 22, 37, 38, 43]);
 my %videoformats = (
+    43 => 'webm,360p',
+    44 => 'webm,480p',
+    45 => 'webm,720p',
     38 => 'mp4,h264,4k',
     37 => 'mp4,h264,1080p',
     35 => 'flv,h264,large',
@@ -146,6 +149,7 @@ sub _parse_by_video_info {
     $metadata->{'TITLE'} = $content->{'title'};
     $metadata->{'TITLE'} =~ s/\+/ /g;
     $metadata->{'TITLE'} =~ s/%(..)/chr(hex($1))/ge;
+    $metadata->{'TITLE'} = decode("utf8", $metadata->{'TITLE'});
 
     $self->debug('Title found: %s', $metadata->{'TITLE'});
 
@@ -211,9 +215,8 @@ sub _parse_by_scrape {
             if (exists($tag->[1]->{'name'}) and ('title' eq $tag->[1]->{'name'})) {
                 $metadata->{'TITLE'} = $tag->[1]->{'content'};
                 # Convert HTML entities in the title. This is a bit convoluted.
-                $metadata->{'TITLE'} = encode("utf8",
-                                         decode_entities(
-                                           decode("utf8", $metadata->{'TITLE'})));
+                $metadata->{'TITLE'} = decode_entities(
+                                           decode("utf8", $metadata->{'TITLE'}));
                     
                 $self->debug('Title found: %s', $metadata->{'TITLE'});
             }