public static Collection<Tag> getTopTags(String user, int limit, String apiKey) {
   Map<String, String> params = new HashMap<String, String>();
   params.put("user", user);
   MapUtilities.nullSafePut(params, "limit", limit);
   Result result = Caller.getInstance().call("user.getTopTags", apiKey, params);
   return ResponseBuilder.buildCollection(result, Tag.class);
 }
 /**
  * Get shouts for a user.
  *
  * @param user The username to fetch shouts for
  * @param page The page number to fetch
  * @param limit An integer used to limit the number of shouts returned per page or -1 for default
  * @param apiKey A Last.fm API key.
  * @return a page of <code>Shout</code>s
  */
 public static PaginatedResult<Shout> getShouts(String user, int page, int limit, String apiKey) {
   Map<String, String> params = new HashMap<String, String>();
   params.put("user", user);
   MapUtilities.nullSafePut(params, "limit", limit);
   MapUtilities.nullSafePut(params, "page", page);
   Result result = Caller.getInstance().call("user.getShouts", apiKey, params);
   return ResponseBuilder.buildPaginatedResult(result, Shout.class);
 }
 /**
  * Gets a list of a user's playlists on Last.fm. Note that this method only fetches metadata
  * regarding the user's playlists. If you want to retrieve the list of tracks in a playlist use
  * {@link Playlist#fetch(String, String) Playlist.fetch()}.
  *
  * @param user The last.fm username to fetch the playlists of.
  * @param apiKey A Last.fm API key.
  * @return a list of Playlists
  */
 public static Collection<Playlist> getPlaylists(String user, String apiKey) {
   Result result = Caller.getInstance().call("user.getPlaylists", apiKey, "user", user);
   if (!result.isSuccessful()) return Collections.emptyList();
   Collection<Playlist> playlists = new ArrayList<Playlist>();
   for (DomElement element : result.getContentElement().getChildren("playlist")) {
     playlists.add(Playlist.playlistFromElement(element));
   }
   return playlists;
 }
 public static PaginatedResult<Track> getRecentTracks(
     String user, int page, int limit, String apiKey) {
   Map<String, String> params = new HashMap<String, String>();
   params.put("user", user);
   params.put("limit", String.valueOf(limit));
   params.put("page", String.valueOf(page));
   Result result = Caller.getInstance().call("user.getRecentTracks", apiKey, params);
   return ResponseBuilder.buildPaginatedResult(result, Track.class);
 }
Esempio n. 5
0
 public static PaginatedResult<Event> getEvents(
     double latitude, double longitude, int page, int limit, String apiKey) {
   Map<String, String> params = new HashMap<String, String>();
   params.put("page", String.valueOf(page));
   params.put("lat", String.valueOf(latitude));
   params.put("long", String.valueOf(longitude));
   MapUtilities.nullSafePut(params, "limit", limit);
   Result result = Caller.getInstance().call("geo.getEvents", apiKey, params);
   return ResponseBuilder.buildPaginatedResult(result, Event.class);
 }
 /**
  * Get a list of tracks by a given artist scrobbled by this user, including scrobble time. Can be
  * limited to specific timeranges, defaults to all time.
  *
  * @param user The last.fm username to fetch the recent tracks of
  * @param artist The artist name you are interested in
  * @param page An integer used to fetch a specific page of tracks
  * @param startTimestamp An unix timestamp to start at
  * @param endTimestamp An unix timestamp to end at
  * @param apiKey A Last.fm API key
  * @return a list of Tracks
  */
 public static PaginatedResult<Track> getArtistTracks(
     String user, String artist, int page, long startTimestamp, long endTimestamp, String apiKey) {
   Map<String, String> params = new HashMap<String, String>();
   params.put("user", user);
   params.put("artist", artist);
   params.put("page", String.valueOf(page));
   params.put("startTimestamp", String.valueOf(startTimestamp));
   params.put("endTimestamp", String.valueOf(endTimestamp));
   Result result = Caller.getInstance().call("user.getArtistTracks", apiKey, params);
   return ResponseBuilder.buildPaginatedResult(result, Track.class);
 }
Esempio n. 7
0
 /**
  * Get a list of valid countries and {@link de.umass.lastfm.Geo.Metro}s for use in the other
  * webservices.
  *
  * @param country Optionally restrict the results to those Metros from a particular country, as
  *     defined by the ISO 3166-1 country names standard
  * @param apiKey A Last.fm API key
  * @return a List of {@link de.umass.lastfm.Geo.Metro}s
  */
 public static Collection<Metro> getMetros(String country, String apiKey) {
   Map<String, String> params = new HashMap<String, String>();
   MapUtilities.nullSafePut(params, "country", country);
   Result result = Caller.getInstance().call("geo.getMetros", apiKey, params);
   if (!result.isSuccessful()) return Collections.emptyList();
   Collection<DomElement> children = result.getContentElement().getChildren("metro");
   Collection<Metro> metros = new ArrayList<Metro>(children.size());
   for (DomElement child : children) {
     metros.add(new Metro(child.getChildText("name"), child.getChildText("country")));
   }
   return metros;
 }
 public static PaginatedResult<Event> getRecommendedEvents(int page, Session session) {
   Result result =
       Caller.getInstance()
           .call(
               "user.getRecommendedEvents",
               session,
               "page",
               String.valueOf(page),
               "user",
               session.getUsername());
   return ResponseBuilder.buildPaginatedResult(result, Event.class);
 }
 /**
  * Gets a list of forthcoming releases based on a user's musical taste.
  *
  * @param user The Last.fm username
  * @param useRecommendations If <code>true</code>, the feed contains new releases based on
  *     Last.fm's artist recommendations for this user. Otherwise, it is based on their library
  *     (the default)
  * @param apiKey A Last.fm API key
  * @return a Collection of new {@link Album} releases
  */
 public static Collection<Album> getNewReleases(
     String user, boolean useRecommendations, String apiKey) {
   Result result =
       Caller.getInstance()
           .call(
               "user.getNewReleases",
               apiKey,
               "user",
               user,
               "userecs",
               useRecommendations ? "1" : "0");
   return ResponseBuilder.buildCollection(result, Album.class);
 }
Esempio n. 10
0
 public static PaginatedResult<User> getFriends(
     String user, boolean recenttracks, int page, int limit, String apiKey) {
   Result result =
       Caller.getInstance()
           .call(
               "user.getFriends",
               apiKey,
               "user",
               user,
               "recenttracks",
               String.valueOf(recenttracks ? 1 : 0),
               "limit",
               String.valueOf(limit),
               "page",
               String.valueOf(page));
   return ResponseBuilder.buildPaginatedResult(result, User.class);
 }
Esempio n. 11
0
 /**
  * GetS a list of upcoming events that this user is attending.
  *
  * @param user The user to fetch the events for.
  * @param apiKey A Last.fm API key.
  * @return a list of upcoming events
  */
 public static Collection<Event> getEvents(String user, String apiKey) {
   Result result = Caller.getInstance().call("user.getEvents", apiKey, "user", user);
   return ResponseBuilder.buildCollection(result, Event.class);
 }
Esempio n. 12
0
 /**
  * Returns the tracks banned by the user.
  *
  * @param user The user name
  * @param page The page number to fetch
  * @param apiKey A Last.fm API key
  * @return the banned tracks
  */
 public static PaginatedResult<Track> getBannedTracks(String user, int page, String apiKey) {
   Result result =
       Caller.getInstance()
           .call("user.getBannedTracks", apiKey, "user", user, "page", String.valueOf(page));
   return ResponseBuilder.buildPaginatedResult(result, Track.class);
 }
Esempio n. 13
0
 /**
  * Shout on this user's shoutbox
  *
  * @param user The name of the user to shout on
  * @param message The message to post to the shoutbox
  * @param session A Session instance
  * @return the result of the operation
  */
 public static Result shout(String user, String message, Session session) {
   return Caller.getInstance().call("user.shout", session, "user", user, "message", message);
 }
Esempio n. 14
0
 /**
  * Get Last.fm artist recommendations for a user.
  *
  * @param page The page to fetch
  * @param session A Session instance
  * @return a list of {@link Artist}s
  */
 public static PaginatedResult<Artist> getRecommendedArtists(int page, Session session) {
   Result result =
       Caller.getInstance()
           .call("user.getRecommendedArtists", session, "page", String.valueOf(page));
   return ResponseBuilder.buildPaginatedResult(result, Artist.class);
 }
Esempio n. 15
0
 /**
  * Retrieves profile information about the specified user.
  *
  * @param user A username
  * @param apiKey A Last.fm API key.
  * @return User info
  */
 public static User getInfo(String user, String apiKey) {
   Result result = Caller.getInstance().call("user.getInfo", apiKey, "user", user);
   return ResponseBuilder.buildItem(result, User.class);
 }
Esempio n. 16
0
 /**
  * Gets a paginated list of all events a user has attended in the past.
  *
  * @param user The username to fetch the events for.
  * @param page The page number to scan to.
  * @param apiKey A Last.fm API key.
  * @return a list of past {@link Event}s
  */
 public static PaginatedResult<Event> getPastEvents(String user, int page, String apiKey) {
   Result result =
       Caller.getInstance()
           .call("user.getPastEvents", apiKey, "user", user, "page", String.valueOf(page));
   return ResponseBuilder.buildPaginatedResult(result, Event.class);
 }
Esempio n. 17
0
 /**
  * Get the most popular tracks on Last.fm by country
  *
  * @param country A country name, as defined by the ISO 3166-1 country names standard
  * @param apiKey A Last.fm API key.
  * @return a list of Tracks
  */
 public static Collection<Track> getTopTracks(String country, String apiKey) {
   Result result = Caller.getInstance().call("geo.getTopTracks", apiKey, "country", country);
   return ResponseBuilder.buildCollection(result, Track.class);
 }
Esempio n. 18
0
 public static Collection<Track> getTopTracks(String user, Period period, String apiKey) {
   Result result =
       Caller.getInstance()
           .call("user.getTopTracks", apiKey, "user", user, "period", period.getString());
   return ResponseBuilder.buildCollection(result, Track.class);
 }
Esempio n. 19
0
 public static Collection<User> getNeighbours(String user, int limit, String apiKey) {
   Result result =
       Caller.getInstance()
           .call("user.getNeighbours", apiKey, "user", user, "limit", String.valueOf(limit));
   return ResponseBuilder.buildCollection(result, User.class);
 }