use of com.github.hakko.musiccabinet.parser.musicbrainz.ArtistQueryParserImpl in project musiccabinet by hakko.
the class MusicBrainzService method updateArtistIds.
protected void updateArtistIds() {
List<Artist> missingArtists = artistDao.getMissingArtists();
List<MBArtist> mbArtists = new ArrayList<>();
mbids = missingArtists.size();
for (Artist artist : artistDao.getMissingArtists()) {
try {
StringUtil response = new StringUtil(artistQueryClient.get(artist.getName()));
ArtistQueryParser parser = new ArtistQueryParserImpl(response.getInputStream());
if (parser.getArtist() != null) {
mbArtists.add(parser.getArtist());
if (mbArtists.size() > 100) {
artistDao.createArtists(mbArtists);
mbArtists.clear();
}
}
++mbid;
} catch (ApplicationException e) {
LOG.warn("Couldn't read mbid for " + artist.getName(), e);
}
}
artistDao.createArtists(mbArtists);
}
Aggregations