Search in sources :

Example 11 with Scrobble

use of com.github.hakko.musiccabinet.domain.model.aggr.Scrobble in project musiccabinet by hakko.

the class UpdateNowPlayingService method addScrobble.

private void addScrobble(Scrobble scrobble) {
    ConcurrentLinkedDeque<Scrobble> deque = userScrobbles.get(scrobble.getLastFmUser());
    Scrobble tail;
    while ((tail = deque.peekLast()) != null && tooClose(tail, scrobble)) {
        // indicates the occurrence of a previous track that was played for a few
        // seconds, and that should be removed
        deque.pollLast();
    }
    deque.add(scrobble);
}
Also used : Scrobble(com.github.hakko.musiccabinet.domain.model.aggr.Scrobble)

Example 12 with Scrobble

use of com.github.hakko.musiccabinet.domain.model.aggr.Scrobble in project musiccabinet by hakko.

the class UpdateNowPlayingClientTest method validateParameters.

@Test
public void validateParameters() throws ApplicationException {
    final Track track = browserDao.getTracks(browserDao.getRandomTrackIds(1)).get(0);
    final LastFmUser user = new LastFmUser("lastFmUser", "sessionKey");
    final Scrobble scrobble = new Scrobble(user, track, false);
    final String method = UpdateNowPlayingClient.METHOD;
    new UpdateNowPlayingClient() {

        @Override
        protected WSResponse executeWSRequest(List<NameValuePair> params) throws ApplicationException {
            assertHasParameter(params, PARAM_METHOD, method);
            assertHasParameter(params, PARAM_ARTIST, track.getArtist().getName());
            assertHasParameter(params, PARAM_ALBUM, track.getMetaData().getAlbum());
            assertHasParameter(params, PARAM_TRACK, track.getName());
            assertHasParameter(params, PARAM_DURATION, "" + track.getMetaData().getDuration());
            assertHasParameter(params, PARAM_SK, user.getSessionKey());
            return null;
        }
    }.updateNowPlaying(scrobble);
}
Also used : NameValuePair(org.apache.http.NameValuePair) ApplicationException(com.github.hakko.musiccabinet.exception.ApplicationException) LastFmUser(com.github.hakko.musiccabinet.domain.model.library.LastFmUser) Scrobble(com.github.hakko.musiccabinet.domain.model.aggr.Scrobble) Track(com.github.hakko.musiccabinet.domain.model.music.Track) Test(org.junit.Test)

Aggregations

Scrobble (com.github.hakko.musiccabinet.domain.model.aggr.Scrobble)12 Test (org.junit.Test)5 Message (org.springframework.integration.Message)5 WSResponse (com.github.hakko.musiccabinet.ws.lastfm.WSResponse)4 PollableChannel (org.springframework.integration.core.PollableChannel)4 GenericMessage (org.springframework.integration.message.GenericMessage)4 LastFmUser (com.github.hakko.musiccabinet.domain.model.library.LastFmUser)3 ApplicationException (com.github.hakko.musiccabinet.exception.ApplicationException)2 Track (com.github.hakko.musiccabinet.domain.model.music.Track)1 NameValuePair (org.apache.http.NameValuePair)1 DateTime (org.joda.time.DateTime)1