1

如果给出了视频 ID,我知道如何检索所有统计信息。但是,如果我必须根据查询标题检索搜索结果 (20) 的视频 ID,那么我将无法做到这一点。任何人都可以帮助我如何使用JAVA API处理它。

提前非常感谢。

4

1 回答 1

4

您是否搜索过 Google 文档?他们的指南正是您正在寻找的内容:YouTube API - 搜索视频

它甚至给你一个例子:

YouTubeQuery query = new YouTubeQuery(new URL("http://gdata.youtube.com/feeds/api/videos"));
// order results by the number of views (most viewed first)
query.setOrderBy(YouTubeQuery.OrderBy.VIEW_COUNT);

// search for puppies and include restricted content in the search results
query.setFullTextQuery("puppy");
query.setSafeSearch(YouTubeQuery.SafeSearch.NONE);

VideoFeed videoFeed = service.query(query, VideoFeed.class);

从返回的 VideoFeed 中,您可以轻松获取视频 id。

for(VideoEntry videoEntry : videoFeed.getEntries() ) {
     YouTubeMediaGroup mediaGroup = videoEntry.getMediaGroup();
     mediaGroup.getVideoId(); // the video ID
}
于 2012-07-17T19:01:10.517 回答