Skip to content

Commit

Permalink
fix apple music partially url encoded track urls
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed May 23, 2024
1 parent 7b77708 commit 6be24fc
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.DataInput;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.security.KeyFactory;
Expand Down Expand Up @@ -432,7 +433,8 @@ private List<AudioTrack> parseTracks(JsonBrowser json, boolean preview) throws I

private AudioTrack parseTrack(JsonBrowser json, boolean preview, String artistArtwork) {
var attributes = json.get("attributes");
var trackUrl = attributes.get("url").text();
// sometimes apple music returns a url which is partially url encoded (only the album name part)
var trackUrl = URLDecoder.decode(attributes.get("url").text(), StandardCharsets.UTF_8);
var artistUrl = json.get("artistUrl").text();
if (artistUrl != null && (artistUrl.isEmpty() || artistUrl.startsWith("https://music.apple.com/WebObjects/MZStore.woa/wa/viewCollaboration"))) {
artistUrl = null;
Expand Down

0 comments on commit 6be24fc

Please sign in to comment.