Sami
Sami

Reputation: 492

How to change start-index and max-results parameters by Java

As usual, I want to get more than 25 comment of a video by using Youtube API v2. Documents say that with start-index parameter, I can decide the interval and with maxresults parameter I can decide the max result. maxresults parameter is default 25 and is maximum 50. Iteratively i can get comments up to 1000. But, How can i change the maxresults parameter and star-index parameter in this code :

    YouTubeService service = new YouTubeService(key);
    String videoEntryUrl = "http://gdata.youtube.com/feeds/api/videos/0nvfsNzV3Vc";

    VideoEntry videoEntry = service.getEntry(new URL(videoEntryUrl), VideoEntry.class);
    String commentUrl = videoEntry.getComments().getFeedLink().getHref();

    CommentFeed commentFeed = service.getFeed(new URL(commentUrl),
            CommentFeed.class);
    for (CommentEntry comment : commentFeed.getEntries()) {
        System.out.println(comment.getPlainTextContent());
    }

Upvotes: 1

Views: 1061

Answers (1)

Tempus
Tempus

Reputation: 785

Off memory, I think it is ( well should be )

String videoEntryUrl = "http://gdata.youtube.com/feeds/api/videos/0nvfsNzV3Vc?v=2&start-index=1&max-results=25";

Just set your start index to where you want to start from and then set how many results up to 50.

Upvotes: 1

Related Questions