Search in sources :

Example 1 with ScrobbledTracksParserImpl

use of com.github.hakko.musiccabinet.parser.lastfm.ScrobbledTracksParserImpl in project musiccabinet by hakko.

the class ScrobbledTracksService method updateSearchIndex.

@Override
protected void updateSearchIndex() throws ApplicationException {
    short page = 0, totalPages = 0;
    do {
        WSResponse wsResponse = client.getLibraryTracks(page, lastFmSettingsService.getLastFmUsername());
        if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
            StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
            ScrobbledTracksParser parser = new ScrobbledTracksParserImpl(stringUtil.getInputStream());
            totalPages = parser.getTotalPages();
            trackPlayCountDao.createTrackPlayCounts(parser.getTrackPlayCounts());
            setTotalOperations(totalPages);
            addFinishedOperation();
        }
    } while (++page < totalPages);
}
Also used : ScrobbledTracksParser(com.github.hakko.musiccabinet.parser.lastfm.ScrobbledTracksParser) WSResponse(com.github.hakko.musiccabinet.ws.lastfm.WSResponse) StringUtil(com.github.hakko.musiccabinet.util.StringUtil) ScrobbledTracksParserImpl(com.github.hakko.musiccabinet.parser.lastfm.ScrobbledTracksParserImpl)

Aggregations

ScrobbledTracksParser (com.github.hakko.musiccabinet.parser.lastfm.ScrobbledTracksParser)1 ScrobbledTracksParserImpl (com.github.hakko.musiccabinet.parser.lastfm.ScrobbledTracksParserImpl)1 StringUtil (com.github.hakko.musiccabinet.util.StringUtil)1 WSResponse (com.github.hakko.musiccabinet.ws.lastfm.WSResponse)1