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

私は同じ問題に直面しました。URLが間違っています。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

Data 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 に答える
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 に答える