2

im using the java google gdata client api for retrieving youtube videos which works fine so far. But today i faced a problem. Im trying to receive videos from a channel but getting no results. The (example) url of a channel im trying to find videos: http://www.youtube.com/channel/HCrrUf3dKG1Gw

I tried to use the YouTubeQuery setAuthor method with "HCrrUf3dKG1Gw" (no matter if setPartner was false or true) and setFullTextQuery "PERSONA 4"-> no results

Getting videos from url containing the "user" works fine with setting the author in the query.

Thats the code im using (slightly modified):

YouTubeService service = new YouTubeService(<clientId>)
service.setConnectTimeout(2000)
YouTubeQuery query = new YouTubeQuery(new URL(<url>)
query.setOrderBy(YouTubeQuery.OrderBy.RELEVANCE)
query.setTime(Time.ALL_TIME)
query.setFullTextQuery(<query>)
query.setSafeSearch(YouTubeQuery.SafeSearch.NONE)
query.setMaxResults(50)
if (isPartner) {
   query.setUploader(Uploader.PARTNER)
}
if (author) {
   query.setAuthor(<author>)
}
VideoFeed videoFeed = service.query(query, VideoFeed.class)
List<VideoEntry> videos = videoFeed.getEntries()

Does anybody have a clue what im missing here? Are channels different handled than user?

4

2 回答 2

1

首先解决 HTTP URL,然后考虑 java API。

当 URL 以“videos”结尾时,可以在“?”后面添加查询参数:

http://gdata.youtube.com/feeds/api/videos?q=puppy&safeSearch=none&orderby=viewCount

当 URL 以“channels”/channelID 结尾时,您不能。

在您的频道页面 http://www.youtube.com/channel/HCrrUf3dKG1Gw上,在“搜索频道”框中输入“MODOK”并进行搜索。结果页面是
http://www.youtube.com/channel/HCrrUf3dKG1Gw/videos?query=MODOK

即在您可以添加查询参数之前,基于通道的 URL 必须如下所示:

http://www.youtube.com/channel/HCrrUf3dKG1Gw/videos

Java API 生成 HTTP URL 并通过基于 HTTP 的套接字发送它们 - 与上述相同。

解决方案:

 YouTubeQuery query = 
 new YouTubeQuery(new URL("http://www.youtube.com/channel/HCrrUf3dKG1Gw/videos");
于 2012-11-07T00:51:26.930 回答
1

我遇到了同样的问题。网址错误。在 gdata 库中调用这个

https://GDATA.youtube.com/feeds/api/channels

如果使用 Data API 2.0,则必须用于通道查询。

https://GDATA.youtube.com/feeds/api/videos

用于视频查询。

https://developers.google.com/youtube/2.0/developers_guide_protocol_channel_search

在数据 API 3.0 的情况下

https://www.googleapis.com/youtube/v3/channels
https://www.googleapis.com/youtube/v3/videos
https://developers.google.com/youtube/v3/docs/channels/list

试试这个例子 https://developers.google.com/youtube/v3/code_samples/java#retrieve_my_uploads

于 2013-10-13T09:37:51.440 回答