* @throws ServiceException Problem communicating with the server.
*/
public static void countUniques(YouTubeService service, String searchTerm) throws MalformedURLException, IOException, ServiceException {
YouTubeQuery query = null;
VideoFeed videoFeed = null;
HashSet<String> uniques = null;
uniques = new HashSet<String>(1000);
query = new YouTubeQuery(
new URL("http://gdata.youtube.com/feeds/api/videos"));
System.out.print("Querying for " + searchTerm);
query.setVideoQuery(searchTerm);
query.setMaxResults(25);
String queryUrl = query.getUrl().toString();
do {
videoFeed = service.getFeed(new URL(queryUrl), VideoFeed.class);
for(VideoEntry entry : videoFeed.getEntries() ) {
uniques.add(entry.getId());
}
//check if we have more results
Link nextLink = videoFeed.getLink("next", "application/atom+xml");
if(nextLink != null) {
queryUrl = nextLink.getHref();
}
else {
queryUrl = null;