JSONArray tracks = json.getJSONArray("tracklist");
for (int i = 0; i < tracks.length(); i++) {
JSONObject track = tracks.getJSONObject(i);
DataSet ds = new DataSet();
// set the album title
ds.setAlbum(a.getTitle());
// set the artist
ds.setArtist(a.getArtist());
// set the track number
String position = track.getString("position");
for (char delim : POSITION_DELIMS) {
int n = position.indexOf(delim);
if (n >= 0) {
String partOfSet = position.substring(0, n);
ds.setPartOfSet(partOfSet);
position = position.substring(n + 1);
break;
}
}
ds.setTrack(position);
// set the title
ds.setTitle(track.getString("title"));
// is there an artist object?
if (track.has("artists")) {
JSONArray artists = track.getJSONArray("artists");
ds.setArtist(artists.getJSONObject(0).getString("name"));
}
// release date
if (!a.getYear().isEmpty()) {
ds.setYear(a.getYear());
} else {
if (json.has("year")) {
ds.setYear(((Integer) json.getInt("year")).toString());
}
}
// set compilation flag
ds.setPartOfCompilation(discogsAlbum.isCompilation());
datasets.add(ds);
}
/*