Search in sources :

Example 51 with Artist

use of com.github.hakko.musiccabinet.domain.model.music.Artist in project musiccabinet by hakko.

the class AlbumNameRowMapper method mapRow.

@Override
public Album mapRow(ResultSet rs, int rowNum) throws SQLException {
    int artistId = rs.getInt(1);
    String artistName = rs.getString(2);
    int albumId = rs.getInt(3);
    String albumName = rs.getString(4);
    return new Album(new Artist(artistId, artistName), albumId, albumName);
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) Album(com.github.hakko.musiccabinet.domain.model.music.Album)

Example 52 with Artist

use of com.github.hakko.musiccabinet.domain.model.music.Artist in project musiccabinet by hakko.

the class ArtistInfoService method updateSearchIndex.

@Override
protected void updateSearchIndex() throws ApplicationException {
    Set<String> artistNames = webserviceHistoryService.getArtistNamesScheduledForUpdate(ARTIST_GET_INFO);
    List<ArtistInfo> artistInfos = new ArrayList<>(artistNames.size());
    setTotalOperations(artistNames.size());
    for (String artistName : artistNames) {
        try {
            WSResponse wsResponse = artistInfoClient.getArtistInfo(new Artist(artistName), lastFmSettingsService.getLang());
            if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
                StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
                ArtistInfoParser aiParser = new ArtistInfoParserImpl(stringUtil.getInputStream());
                if (aiParser.getArtistInfo() != null) {
                    artistInfos.add(aiParser.getArtistInfo());
                } else {
                    LOG.warn("Artist info response for " + artistName + " not parsed correctly. Response was " + wsResponse.getResponseBody());
                }
                if (artistInfos.size() == BATCH_SIZE) {
                    artistInfoDao.createArtistInfo(artistInfos);
                    artistInfos.clear();
                }
            }
        } catch (ApplicationException e) {
            LOG.warn("Fetching artist info for " + artistName + " failed.", e);
        }
        addFinishedOperation();
    }
    artistInfoDao.createArtistInfo(artistInfos);
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) ApplicationException(com.github.hakko.musiccabinet.exception.ApplicationException) ArtistInfoParserImpl(com.github.hakko.musiccabinet.parser.lastfm.ArtistInfoParserImpl) ArrayList(java.util.ArrayList) ArtistInfoParser(com.github.hakko.musiccabinet.parser.lastfm.ArtistInfoParser) WSResponse(com.github.hakko.musiccabinet.ws.lastfm.WSResponse) StringUtil(com.github.hakko.musiccabinet.util.StringUtil) ArtistInfo(com.github.hakko.musiccabinet.domain.model.music.ArtistInfo)

Example 53 with Artist

use of com.github.hakko.musiccabinet.domain.model.music.Artist 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();
    }
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) ArtistSimilarityParser(com.github.hakko.musiccabinet.parser.lastfm.ArtistSimilarityParser) ApplicationException(com.github.hakko.musiccabinet.exception.ApplicationException) ArtistSimilarityParserImpl(com.github.hakko.musiccabinet.parser.lastfm.ArtistSimilarityParserImpl) WSResponse(com.github.hakko.musiccabinet.ws.lastfm.WSResponse) StringUtil(com.github.hakko.musiccabinet.util.StringUtil)

Example 54 with Artist

use of com.github.hakko.musiccabinet.domain.model.music.Artist in project musiccabinet by hakko.

the class ArtistTopTracksService method updateSearchIndex.

@Override
protected void updateSearchIndex() throws ApplicationException {
    Set<String> artistNames = webserviceHistoryService.getArtistNamesScheduledForUpdate(ARTIST_GET_TOP_TRACKS);
    setTotalOperations(artistNames.size());
    for (String artistName : artistNames) {
        try {
            WSResponse wsResponse = artistTopTracksClient.getTopTracks(new Artist(artistName));
            if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
                StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
                ArtistTopTracksParser attParser = new ArtistTopTracksParserImpl(stringUtil.getInputStream());
                artistTopTracksDao.createTopTracks(attParser.getArtist(), attParser.getTopTracks());
            }
        } catch (ApplicationException e) {
            LOG.warn("Fetching top tracks for " + artistName + " failed.", e);
        }
        addFinishedOperation();
    }
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) ApplicationException(com.github.hakko.musiccabinet.exception.ApplicationException) ArtistTopTracksParser(com.github.hakko.musiccabinet.parser.lastfm.ArtistTopTracksParser) WSResponse(com.github.hakko.musiccabinet.ws.lastfm.WSResponse) StringUtil(com.github.hakko.musiccabinet.util.StringUtil) ArtistTopTracksParserImpl(com.github.hakko.musiccabinet.parser.lastfm.ArtistTopTracksParserImpl)

Example 55 with Artist

use of com.github.hakko.musiccabinet.domain.model.music.Artist in project musiccabinet by hakko.

the class ArtistTopTagsHandler method startElement.

@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    if (TAG_TOP_TAGS.equals(qName)) {
        artistName = attributes.getValue(TAG_ARTIST);
        sourceArtist = new Artist(artistName);
    } else if (TAG_NAME.equals(qName)) {
        currentTag = new Tag();
        state = NAME;
        characterData = new StringBuilder();
    } else if (TAG_COUNT.equals(qName)) {
        state = COUNT;
        characterData = new StringBuilder();
    } else {
        state = null;
    }
}
Also used : Artist(com.github.hakko.musiccabinet.domain.model.music.Artist) Tag(com.github.hakko.musiccabinet.domain.model.music.Tag)

Aggregations

Artist (com.github.hakko.musiccabinet.domain.model.music.Artist)66 Test (org.junit.Test)33 WebserviceInvocation (com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation)19 ArrayList (java.util.ArrayList)13 Album (com.github.hakko.musiccabinet.domain.model.music.Album)11 ArtistInfo (com.github.hakko.musiccabinet.domain.model.music.ArtistInfo)11 ApplicationException (com.github.hakko.musiccabinet.exception.ApplicationException)10 Track (com.github.hakko.musiccabinet.domain.model.music.Track)9 File (com.github.hakko.musiccabinet.domain.model.library.File)8 NameValuePair (org.apache.http.NameValuePair)8 Calltype (com.github.hakko.musiccabinet.domain.model.library.WebserviceInvocation.Calltype)7 Before (org.junit.Before)6 WebserviceHistoryService (com.github.hakko.musiccabinet.service.lastfm.WebserviceHistoryService)5 StringUtil (com.github.hakko.musiccabinet.util.StringUtil)5 UnittestLibraryUtil.getFile (com.github.hakko.musiccabinet.util.UnittestLibraryUtil.getFile)5 WSResponse (com.github.hakko.musiccabinet.ws.lastfm.WSResponse)5 LastFmUser (com.github.hakko.musiccabinet.domain.model.library.LastFmUser)4 Tag (com.github.hakko.musiccabinet.domain.model.music.Tag)4 ResourceUtil (com.github.hakko.musiccabinet.util.ResourceUtil)4 ResultSet (java.sql.ResultSet)4