From: Ralf Ertzinger Date: Sat, 18 Jun 2011 12:55:20 +0000 (+0200) Subject: Youtube: decode UTF8 video titles to the internal perl format X-Git-Url: https://git.camperquake.de/gitweb.cgi?p=videosite.git;a=commitdiff_plain;h=0f81249e945336a480456645a710f04589af9437 Youtube: decode UTF8 video titles to the internal perl format --- diff --git a/videosite/YouTubeGrabber.pm b/videosite/YouTubeGrabber.pm index ebb2f69..a70993e 100644 --- a/videosite/YouTubeGrabber.pm +++ b/videosite/YouTubeGrabber.pm @@ -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'}); }