use of com.github.hakko.musiccabinet.parser.lastfm.ArtistSimilarityParserImpl in project musiccabinet by hakko.
the class ArtistRelationService method updateSearchIndex.
@Override
protected void updateSearchIndex() throws ApplicationException {
Set<String> artistNames = webserviceHistoryService.getArtistNamesScheduledForUpdate(ARTIST_GET_SIMILAR);
setTotalOperations(artistNames.size());
for (String artistName : artistNames) {
try {
WSResponse wsResponse = artistSimilarityClient.getArtistSimilarity(new Artist(artistName));
if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
ArtistSimilarityParser asParser = new ArtistSimilarityParserImpl(stringUtil.getInputStream());
artistRelationDao.createArtistRelations(asParser.getArtist(), asParser.getArtistRelations());
}
} catch (ApplicationException e) {
LOG.warn("Fetching artist relations for " + artistName + " failed.", e);
}
addFinishedOperation();
}
}
use of com.github.hakko.musiccabinet.parser.lastfm.ArtistSimilarityParserImpl in project musiccabinet by hakko.
the class JdbcPlaylistGeneratorDaoTest method prepareTestdataForArtist.
private int prepareTestdataForArtist() throws ApplicationException {
ArtistSimilarityParser asParser = new ArtistSimilarityParserImpl(new ResourceUtil(CHER_SIMILAR_ARTISTS).getInputStream());
artistRelationDao.createArtistRelations(asParser.getArtist(), asParser.getArtistRelations());
ArtistTopTracksParser attParser = new ArtistTopTracksParserImpl(new ResourceUtil(CHER_TOP_TRACKS).getInputStream());
artistTopTracksDao.createTopTracks(attParser.getArtist(), attParser.getTopTracks());
List<File> files = new ArrayList<>();
for (Track topTrack : attParser.getTopTracks()) {
files.add(UnittestLibraryUtil.getFile(topTrack));
}
UnittestLibraryUtil.submitFile(additionDao, files);
int artistId = musicDao.getArtistId(asParser.getArtist());
playlistGeneratorDao.updateSearchIndex();
return artistId;
}
Aggregations