Skip to content

Commit

Permalink
add apple music invalid token check
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Sep 22, 2024
1 parent b2f23ce commit ae8f3d1
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ public AudioItem loadItem(String identifier, boolean preview) {
}

public void parseTokenData() throws IOException {
var json = JsonBrowser.parse(new String(Base64.getDecoder().decode(this.token.split("\\.")[1])));
var parts = this.token.split("\\.");
if (parts.length < 3) {
throw new IllegalArgumentException("Invalid Apple Music API token provided");
}
var json = JsonBrowser.parse(new String(Base64.getDecoder().decode(parts[1]), StandardCharsets.UTF_8));
this.tokenExpire = Instant.ofEpochSecond(json.get("exp").asLong(0));
this.origin = json.get("root_https_origin").index(0).text();
}
Expand Down

0 comments on commit ae8f3d1

Please sign in to comment.