Youtube: decode UTF8 video titles to the internal perl format
authorRalf Ertzinger <ralf@skytale.net>
Sat, 18 Jun 2011 12:55:20 +0000 (14:55 +0200)
committerRalf Ertzinger <ralf@skytale.net>
Sat, 18 Jun 2011 12:55:20 +0000 (14:55 +0200)
videosite/YouTubeGrabber.pm

index ebb2f69..a70993e 100644 (file)
@@ -146,6 +146,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 +212,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'});
             }