Package com.github.hakko.musiccabinet.util

Examples of com.github.hakko.musiccabinet.util.StringUtil


    discographies = outdatedArtists.size();
    for (MBArtist artist : outdatedArtists) {
      try {
        int offset = 0;
        do {
          StringUtil response = new StringUtil(releaseClient.get(
            artist.getName(), artist.getMbid(), offset));
          parser = new ReleaseParserImpl(response.getInputStream());
          for (MBRelease album : parser.getReleases()) {
            album.setArtistId(artist.getId());
          }
          mbReleases.addAll(parser.getReleases());
          offset += 100;
View Full Code Here


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

      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) {
        LOG.warn("Fetching top artist for " + user.getLastFmUsername() + " failed.", e);
      }
View Full Code Here

   
    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()));
        }
      } catch (ApplicationException e) {
        LOG.warn("Fetching weekly artist chart for " + group.getName() + " failed.", e);
View Full Code Here

   
    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) {
            albumInfoDao.createAlbumInfo(albumInfos);
            albumInfos.clear();
View Full Code Here

   
    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(),
              attParser.getTopTags());
        }
      } catch (ApplicationException e) {
View Full Code Here

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

  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 {
      LOG.debug("wsResponse: " + wsResponse.getResponseBody());
      throw new ApplicationException("Could not get session key for user! (code "
          + wsResponse.getErrorCode() + ", " + wsResponse.getErrorMessage() + ")");
View Full Code Here

TOP

Related Classes of com.github.hakko.musiccabinet.util.StringUtil

Copyright © 2018 www.massapicom. 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.