如果给出了视频 ID,我知道如何检索所有统计信息。 但如果我必须根据查询标题检索搜索结果的视频 ID (20),那么我就无法做到这一点。 任何人都可以帮助我如何使用JAVA API来处理它。
提前非常感谢。
最佳答案
您是否搜索过 Google 文档? 他们的指南正是您所寻找的:YouTube API - Searching for Videos
它甚至给了你一个例子:
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
}
关于java - 如何使用java检索youtube搜索结果及其视频ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11528960/