1

I`m Student I am using current last.fm Developer api at java eclipse. But the problem occurred during use. I wanted metadata values of a large amount. But result is only 50 pieces. I know that the default value is 50. So, I have adjusted Page or limit but the result still shows 50 pieces.

What is reason?

public static void main(String[] args) {

    String key="#########";
    String tag = "ballad";
    int limit = 100;
    int page = 2;
    int i = 1;

    Chart<Artist> I3 = Tag.getWeeklyArtistChart(tag, page, key);
    Iterable<Artist> tag3 = I3.getTopArtists(page, key);


    for (Artist artist : tag3) {
        System.out.println("["+i+"]"+""+artist.getName());
        i++;
    }
}

result

[1]Drake [2]Ellie Goulding . . . . [50]One Direction

1 Answers1

0

Yes, the default is "50" and always "50", because you don't even set or use the items per page limit. see chart.getTopArtist(page, limit, api_key)

You need to add item per pages limit in:

Iterable<Artist> tag3 = I3.getTopArtists(page, limit, key)

Full Code:

public static void main(String[] args) {

    String key="#########";
    String tag = "ballad";
    int limit = 100;
    int page = 2;
    int i = 1;

    Chart<Artist> I3 = Tag.getWeeklyArtistChart(tag, page, key); // You can also set the limit here. (optional)
    Iterable<Artist> tag3 = I3.getTopArtists(page, limit, key); // Try to add the limit here. (optional)(Default 50)


    for (Artist artist : tag3) {
        System.out.println("["+i+"]"+""+artist.getName());
        i++;
    }
}
Onel Sarmiento
  • 1,608
  • 3
  • 20
  • 46