本文整理汇总了Java中com.google.gdata.client.youtube.YouTubeService.query方法的典型用法代码示例。如果您正苦于以下问题:Java YouTubeService.query方法的具体用法?Java YouTubeService.query怎么用?Java YouTubeService.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gdata.client.youtube.YouTubeService
的用法示例。
在下文中一共展示了YouTubeService.query方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: youTubeSearch
import com.google.gdata.client.youtube.YouTubeService; //导入方法依赖的package包/类
/** returns an Item object given a keyword */
private Item youTubeSearch(String kw) throws Exception {
// init service
YouTubeService service = new YouTubeService(APP_NAME);
YouTubeQuery query = new YouTubeQuery(new URL(FEED_URL));
// order results by the relevance
query.setOrderBy(ORDER_BY_PARAM);
// search for keyword
query.setFullTextQuery(kw);
query.setMaxResults(MAX_SEARCH_RESULTS);
query.setSafeSearch(SAFE_SEARCH_PARAM);
// retrieve results
VideoFeed videoFeed = service.query(query, VideoFeed.class);
String content = localizeVideoFeed(videoFeed);
return new Item(kw, content);
}
示例2: retrieveVideos
import com.google.gdata.client.youtube.YouTubeService; //导入方法依赖的package包/类
public List<YouTubeVideo> retrieveVideos(String textQuery, int maxResults, boolean filter, int timeout, int startIndex) throws Exception {
YouTubeService service = new YouTubeService(clientID);
service.setConnectTimeout(timeout); // millis
YouTubeQuery query = new YouTubeQuery(new URL(YOUTUBE_URL));
query.setOrderBy(YouTubeQuery.OrderBy.RELEVANCE);
query.setFullTextQuery(textQuery);
query.setSafeSearch(YouTubeQuery.SafeSearch.NONE);
query.setMaxResults(maxResults);
query.setStartIndex(startIndex);
query.addCustomParameter(new Query.CustomParameter("hd", "true"));
VideoFeed videoFeed = service.query(query, VideoFeed.class);
List<VideoEntry> videos = videoFeed.getEntries();
return convertVideos(videos);
}
示例3: lookupVideo
import com.google.gdata.client.youtube.YouTubeService; //导入方法依赖的package包/类
public List<String> lookupVideo(String searchTerm) throws IOException, ServiceException {
List<String> results = new ArrayList<String>();
YouTubeService service = new YouTubeService("savetheenvironment");
YouTubeQuery query = new YouTubeQuery(new URL("http://gdata.youtube.com/feeds/api/videos"));
query.setOrderBy(YouTubeQuery.OrderBy.VIEW_COUNT);
query.setFullTextQuery(searchTerm);
query.setSafeSearch(YouTubeQuery.SafeSearch.NONE);
VideoFeed videoFeed = service.query(query, VideoFeed.class);
for (VideoEntry videoEntry : videoFeed.getEntries()) {
results.add(videoEntry.getTitle().getPlainText());
}
return results;
}