From 1d73e28a3613d8f7b96d5da8904e3ee30c2ee353 Mon Sep 17 00:00:00 2001 From: devoxin Date: Sun, 12 May 2024 19:22:59 +0100 Subject: [PATCH] Support isrc extraction from bandcamp tracks --- .../source/bandcamp/BandcampAudioSourceManager.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/main/src/main/java/com/sedmelluq/discord/lavaplayer/source/bandcamp/BandcampAudioSourceManager.java b/main/src/main/java/com/sedmelluq/discord/lavaplayer/source/bandcamp/BandcampAudioSourceManager.java index c2cc3414..89273f84 100644 --- a/main/src/main/java/com/sedmelluq/discord/lavaplayer/source/bandcamp/BandcampAudioSourceManager.java +++ b/main/src/main/java/com/sedmelluq/discord/lavaplayer/source/bandcamp/BandcampAudioSourceManager.java @@ -163,7 +163,7 @@ private AudioItem loadTrack(UrlInfo urlInfo) { String artist = trackListInfo.get("artist").safeText(); String artworkUrl = extractArtwork(trackListInfo); - return extractTrack(trackListInfo.get("trackinfo").index(0), urlInfo.baseUrl, artist, artworkUrl); + return extractTrack(trackListInfo.get("trackinfo").index(0), urlInfo.baseUrl, artist, artworkUrl, trackListInfo.get("current").get("isrc").text()); }); } @@ -175,7 +175,8 @@ private AudioItem loadAlbum(UrlInfo urlInfo) { List tracks = new ArrayList<>(); for (JsonBrowser trackInfo : trackListInfo.get("trackinfo").values()) { - tracks.add(extractTrack(trackInfo, urlInfo.baseUrl, artist, artworkUrl)); + // album track json does not include isrc + tracks.add(extractTrack(trackInfo, urlInfo.baseUrl, artist, artworkUrl, null)); } JsonBrowser albumInfo = readAlbumInformation(text); @@ -183,7 +184,7 @@ private AudioItem loadAlbum(UrlInfo urlInfo) { }); } - private AudioTrack extractTrack(JsonBrowser trackInfo, String bandUrl, String artist, String artworkUrl) { + private AudioTrack extractTrack(JsonBrowser trackInfo, String bandUrl, String artist, String artworkUrl, String isrc) { String trackPageUrl = bandUrl + trackInfo.get("title_link").text(); return new BandcampAudioTrack(new AudioTrackInfo( @@ -194,7 +195,7 @@ private AudioTrack extractTrack(JsonBrowser trackInfo, String bandUrl, String ar false, trackPageUrl, artworkUrl, - null + isrc ), this); }