Examples of WSResponse


Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse

    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();
View Full Code Here

Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse

    List<UserTopArtists> userTopArtists = new ArrayList<>();
   
    for (LastFmUser user : users) {
      for (Period period : Period.values()) {
        try {
          WSResponse wsResponse = userTopArtistsClient.getUserTopArtists(user, period);
          if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
            StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
            UserTopArtistsParser parser =
                new UserTopArtistsParserImpl(stringUtil.getInputStream());
            userTopArtists.add(new UserTopArtists(user, period, parser.getArtists()));
          }
        } catch (ApplicationException e) {
View Full Code Here

Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse

      if (previous != null && tooClose(scrobble, previous) &&
          scrobble.getTrack().getId() == previous.getTrack().getId()) {
        LOG.debug("Same track was scrobbled just recently, ignore.");
      } else {
        addScrobble(scrobble);
        WSResponse wsResponse = nowPlayingClient.updateNowPlaying(scrobble);
        if (!wsResponse.wasCallSuccessful()) {
          LOG.debug("Could not update now playing status at last.fm.");
          LOG.debug("Nowplaying response: " + wsResponse);
        }
      }
    }
View Full Code Here

Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse

    Scrobble head;
    for (LastFmUser lastFmUser : userScrobbles.keySet()) {
      ConcurrentLinkedDeque<Scrobble> deque = userScrobbles.get(lastFmUser);
      while ((head = deque.peekFirst()) != null && !tooClose(head, new DateTime())) {
        playCountDao.addPlayCount(head.getLastFmUser(), head.getTrack());
        WSResponse wsResponse = scrobbleClient.scrobble(head);
        if (!wsResponse.wasCallSuccessful()) {
          LOG.warn("scrobbling " + head + " failed! Add for re-sending.");
          LOG.debug("Scrobble response: " + wsResponse);
          failedScrobbles.add(head);
        }
        deque.pollFirst();
View Full Code Here

Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse

  protected void scrobbleFailedTracks() throws ApplicationException {
    while (failedScrobbles.size() > 0) {
      LOG.debug("Queue of failed scrobbles consists of " + failedScrobbles.size() + " elements.");
      Scrobble firstFailed = failedScrobbles.get(0);
      WSResponse wsResponse = scrobbleClient.scrobble(firstFailed);
      if (wsResponse.wasCallSuccessful()) {
        LOG.debug("Failed scrobble was re-sent.");
        failedScrobbles.remove(0);
      } else {
        LOG.debug("Failed scrobble could not be re-sent. Wait a minute before trying again.");
        LOG.debug("Response: " + wsResponse);
View Full Code Here

Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse

        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());
        }
View Full Code Here

Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse

    List<UserRecommendedArtists> artists = new ArrayList<>();
   
    for (LastFmUser user : users) {
      try {
        WSResponse wsResponse = userRecommendedArtistsClient.
            getUserRecommendedArtists(user.getLastFmUsername());
        LOG.debug(wsResponse);
        if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
          StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
          UserRecommendedArtistsParser parser =
              new UserRecommendedArtistsParserImpl(stringUtil.getInputStream());
          artists.add(new UserRecommendedArtists(user, parser.getArtists()));
        }
      } catch (ApplicationException e) {
View Full Code Here

Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse

   
    setTotalOperations(groups.size());
   
    for (LastFmGroup group : groups) {
      try {
        WSResponse wsResponse = client.getWeeklyArtistChart(group);
        if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
          StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
          GroupWeeklyArtistChartParser parser =
              new GroupWeeklyArtistChartParserImpl(stringUtil.getInputStream());
          artistCharts.add(new GroupWeeklyArtistChart(
              group.getName(), parser.getArtistPlayCount()));
        }
View Full Code Here

Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse

    List<AlbumInfo> albumInfos = new ArrayList<>();
    setTotalOperations(albums.size());
   
    for (Album album : albums) {
      try {
        WSResponse wsResponse = albumInfoClient.getAlbumInfo(album);
        if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
          StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
          AlbumInfoParser aiParser =
            new AlbumInfoParserImpl(stringUtil.getInputStream());
          albumInfos.add(aiParser.getAlbumInfo());
         
          if (albumInfos.size() == BATCH_SIZE) {
View Full Code Here

Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse

    resendFailedUpdates();
    ArtistUserTag aut;
    while (failedUpdates.isEmpty() && (aut = artistUserTags.poll()) != null) {
      if ((aut.isIncrease() && aut.getTagCount() >= MAX_THRESHOLD)
          || (!aut.isIncrease() && aut.getTagCount() <= MIN_THRESHOLD)) {
        WSResponse wsResponse = tagUpdateClient.updateTag(aut);
        if (!wsResponse.wasCallSuccessful()) {
          LOG.warn("updating " + aut + " failed! Add for re-sending.");
          LOG.debug("Response: " + wsResponse);
          failedUpdates.add(aut);
        }
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.