diff --git a/YTMusicAPI/Helpers.pm b/YTMusicAPI/Helpers.pm index 6cea621..9759de8 100644 --- a/YTMusicAPI/Helpers.pm +++ b/YTMusicAPI/Helpers.pm @@ -11,6 +11,7 @@ use HTTP::Cookies; use Digest::SHA qw(sha1_hex); use Time::HiRes qw(time); use Unicode::Normalize; +use Encode 'encode_utf8', 'is_utf8'; use locale; use YTMusicAPI::Constants qw(YTM_DOMAIN USER_AGENT); @@ -47,7 +48,9 @@ sub get_visitor_id { my $visitor_id = ""; if (@matches) { - my $ytcfg = decode_json( $matches[0] ); + my $encoded_match = + is_utf8( $matches[0] ) ? encode_utf8( $matches[0] ) : $matches[0]; + my $ytcfg = decode_json($encoded_match); $visitor_id = $ytcfg->{"VISITOR_DATA"} // ""; }