Fix wide character error

This commit is contained in:
mschuepbach
2024-03-26 21:17:05 +01:00
parent 2c81a2c3de
commit 088fdb2b16

View File

@@ -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"} // "";
}