Skip to content

Commit

Permalink
ignore tracks with readable: false
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed May 22, 2023
1 parent 39e27ba commit 349dfb1
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public JsonBrowser getJson(String uri) throws IOException {
private List<AudioTrack> parseTracks(JsonBrowser json) {
var tracks = new ArrayList<AudioTrack>();
for (var track : json.get("data").values()) {
if (!track.get("type").text().equals("track")) {
if (!track.get("type").text().equals("track") || !track.get("readable").as(Boolean.class)) {
continue;
}
tracks.add(this.parseTrack(track));
Expand All @@ -145,7 +145,7 @@ private AudioTrack parseTrack(JsonBrowser json) {

private AudioItem getTrackByISRC(String isrc) throws IOException {
var json = this.getJson(PUBLIC_API_BASE + "/track/isrc:" + isrc);
if (json == null || json.get("id").isNull()) {
if (json == null || json.get("id").isNull() || !json.get("readable").as(Boolean.class)) {
return AudioReference.NO_TRACK;
}
return this.parseTrack(json);
Expand All @@ -171,7 +171,7 @@ private AudioItem getAlbum(String id) throws IOException {

private AudioItem getTrack(String id) throws IOException {
var json = this.getJson(PUBLIC_API_BASE + "/track/" + id);
if (json == null) {
if (json == null || !json.get("readable").as(Boolean.class)) {
return AudioReference.NO_TRACK;
}
return this.parseTrack(json);
Expand Down

0 comments on commit 349dfb1

Please sign in to comment.