Package com.github.hakko.musiccabinet.ws.lastfm

Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse.wasCallSuccessful()


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


    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

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

    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

    while (failedUpdates.size() > 0) {
      LOG.debug("Queue of failed updates consists of "
          + failedUpdates.size() + " elements.");
      ArtistUserTag firstFailed = failedUpdates.get(0);
      WSResponse wsResponse = tagUpdateClient.updateTag(firstFailed);
      if (wsResponse.wasCallSuccessful()) {
        LOG.debug("Failed tag update was re-sent.");
        failedUpdates.remove(0);
      } else {
        LOG.debug("Failed tag update could not be re-sent. Wait a minute before trying again.");
        LOG.debug("Response: " + wsResponse);
View Full Code Here

    setTotalOperations(artistNames.size());
   
    for (String artistName : artistNames) {
      try {
        WSResponse wsResponse = artistTopTagsClient.getTopTags(new Artist(artistName));
        if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
          StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
          ArtistTopTagsParser attParser =
            new ArtistTopTagsParserImpl(stringUtil.getInputStream());
          removeTagsWithLowTagCount(attParser.getTopTags());
          artistTopTagsDao.createTopTags(attParser.getArtist(),
View Full Code Here

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

   
    setTotalOperations(tags.size());
   
    for (String tag : tags) {
      WSResponse wsResponse = tagInfoClient.getTagInfo(tag, lastFmSettingsService.getLang());
      if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
        StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
        TagInfoParser tiParser = new TagInfoParserImpl(stringUtil.getInputStream());
        tagInfos.add(tiParser.getTagInfo());
      }
      addFinishedOperation();
View Full Code Here

  private static final Logger LOG = Logger.getLogger(LastFmService.class);

  public LastFmUser identifyLastFmUser(String token) throws ApplicationException {
    LOG.debug("identifyLastFmUser(" + token + ")");
    WSResponse wsResponse = authSessionClient.getAuthSession(token);
    if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
      StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
      AuthSessionParser authSessionParser =
          new AuthSessionParserImpl(stringUtil.getInputStream());
      return authSessionParser.getLastFmUser();
    } else {
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.