Then I decode the JSON response and load what I want into variables:#!/usr/bin/perl use LWP::Simple; use lib 'JSON253/lib/'; use JSON qw( decode_json ); use CGI::Carp qw(fatalsToBrowser set_message warningsToBrowser); use strict; use warnings; my $url = "https://www.googleapis.com/youtube/v3/playlistItems?part=sn +ippet&key=$API_KEY"; my $result = get($url); die "Could not get $url!" unless defined $result;
This all works, except that some video descriptions have weird characters in them. Some are emoticons. Here's an example from a description with an emoticon smiley at the end:$jsonstuff = decode_json($result); $description = $jsonstuff->{items}->{snippet}->{description};
Another quirk is that some apostrophes get mangled. Here's another printed description:"Happy with everything at the moment \x{1f60a}."
I know it's a character encoding issue.. but is Youtube using a mix of encodings? I once got the apostrophe to print correctly by changing Windows-1252 to UTF-8 in one step. But the emoticons were still mangled. I should add that not all apostrophes are mangled. On some videos they come through fine. I wondered if it had to do with the uploader's text processing method. I've been searching most the day and trying various fixes, even from a number of perlmonks.org threads. But I haven't been able to make it work yet. Thanks"It’s the fans who make it worthwhile."
In reply to JSON character encoding by Bman70
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |