use of com.github.hakko.musiccabinet.parser.musicbrainz.ReleaseParserImpl in project musiccabinet by hakko.
the class MusicBrainzService method updateArtistDiscographies.
protected void updateArtistDiscographies() {
List<MBArtist> outdatedArtists = artistDao.getOutdatedArtists();
List<MBRelease> mbReleases = new ArrayList<>();
ReleaseParser parser;
discographies = outdatedArtists.size();
for (MBArtist artist : outdatedArtists) {
try {
int offset = 0;
do {
StringUtil response = new StringUtil(releaseClient.get(artist.getName(), artist.getMbid(), offset));
parser = new ReleaseParserImpl(response.getInputStream());
for (MBRelease album : parser.getReleases()) {
album.setArtistId(artist.getId());
}
mbReleases.addAll(parser.getReleases());
offset += 100;
} while (offset < parser.getTotalReleases());
++discography;
if (mbReleases.size() > 1000) {
albumDao.createAlbums(mbReleases);
mbReleases.clear();
}
} catch (ApplicationException e) {
LOG.warn("Couldn't read discography for " + artist.getName(), e);
}
}
albumDao.createAlbums(mbReleases);
}
Aggregations