From 088fdb2b16c218cd049691627d821e3654ce0800 Mon Sep 17 00:00:00 2001 From: mschuepbach Date: Tue, 26 Mar 2024 21:17:05 +0100 Subject: [PATCH] Fix wide character error --- YTMusicAPI/Helpers.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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"} // ""; }