Question

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,

Was it helpful?

Solution

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);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top