1

I am trying to get a list of tracks listened to by a user in a specific time range.

According the the last.fm api this is possible with getRecentTracks (see here).

But I am using the Java API and the method getRecentTracks does not have input arguments for from and to range:

public static de.umass.lastfm.PaginatedResult<de.umass.lastfm.Track> getRecentTracks(java.lang.String user, java.lang.String apiKey) 

public static de.umass.lastfm.PaginatedResult<de.umass.lastfm.Track> getRecentTracks(java.lang.String user, int page, int limit, java.lang.String apiKey)

Is this not implemented int java API and how could I extract this?

Thanks,

Matthieu Brucher
  • 21,634
  • 7
  • 38
  • 62
dorien
  • 5,265
  • 10
  • 57
  • 116
  • User and key are the only required params; everything else is optional. Are you sure the method isn't overridden with the optional params? – Anubian Noob Mar 31 '14 at 16:08
  • I am not sure, These are the only two functions I find in the class of the lastfm.jar. It's not user, limit, apiKey or page and I don't see any others defined. – dorien Mar 31 '14 at 16:11

1 Answers1

1

It is not implemented.

You can write your own implementation handling from and to UNIX timestamp:

public static PaginatedResult<Track> getRecentTracks(String user, int page, 
    int limit, String apiKey, int from, int to) {
    Map<String, String> params = new HashMap<String, String>();
    params.put("user", user);
    params.put("limit", String.valueOf(limit));
    params.put("page", String.valueOf(page));
    params.put("from", String.valueOf(from));
    params.put("to", String.valueOf(to));
    Result result = Caller.getInstance().call("user.getRecentTracks", apiKey, params);
    return ResponseBuilder.buildPaginatedResult(result, Track.class);
}
Jean Logeart
  • 52,687
  • 11
  • 83
  • 118