去年有时,我只需附加 /uploads?alt=rss
即可检索 YouTube 用户的(可公开访问的)视频源。例如http://gdata.youtube.com/feeds/base/users/NTVKenya
给出了 http://gdata.youtube.com/feeds/base/users/NTVKenya/uploads?alt= rss
。但该服务不再可用。
我想现在推荐的方法是使用GData库。但是,使用此服务给我带来了 com.google.gdata.util.NoLongerAvailableException
异常:
YouTubeService service = new YouTubeService("service");
ArrayList<String> urls = new ArrayList<String>();
VideoFeed videoFeed = service.getFeed(new URL('http://gdata.youtube.com/feeds/base/users/NTVKenya'), VideoFeed.class);
for (VideoEntry videoEntry : videoFeed.getEntries() ) {
urls.add( videoEntry.getHtmlLink().getHref() );
}
这给出:
com.google.gdata.util.NoLongerAvailableException: No longer available
<errors xmlns='http://schemas.google.com/g/2005'><error><domain>GData</domain><code>NoLongerAvailableException</code><internalReason>No longer available</internalReason></error></errors>
我哪里出错了?
谢谢。
最佳答案
这比我想象的要难得多!
关键是您现在需要 YouTube 开发者 API key 。 您可以在以下位置获取 key : https://console.developers.google.com
一旦我创建了一个应用程序并获得了 key ,我就对此处找到的新 V3 API 进行了修改: https://developers.google.com/youtube/v3/sample_requests
我能够构建一个似乎有效的 URL...您可能需要进一步研究和完善它。这是我尝试过的(将 MYAPIKEYHERE 替换为您的 key ): https://www.googleapis.com/youtube/v3/search?part=snippet&q=NTVKenya&order=viewCount&type=video&key=MYAPIKEYHERE
这是它返回的内容:
{
"kind": "youtube#searchListResponse",
"etag": "\"oqbvhYxBE6fAbRk6m7aLlHf5s1I/8Pwx4tA-oE0lcjEgrRoqOeaeu4w\"",
"nextPageToken": "CAUQAA",
"pageInfo": {
"totalResults": 484531,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "\"oqbvhYxBE6fAbRk6m7aLlHf5s1I/RzPtjac7Nh1ggOliIdOlMbB_qls\"",
"id": {
"kind": "youtube#video",
"videoId": "PywWIHqiwD0"
},
"snippet": {
"publishedAt": "2011-11-18T15:57:15.000Z",
"channelId": "UCekTpzKodObpOcmvVCFUvTw",
"title": "Turkana woman breastfeeds orphaned goat",
"description": "http://www.ntv.co.ke A woman in Turkana has been taking care of an orphaned she goat for five months in an unorthodox manner. The woman rescued the kid ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/PywWIHqiwD0/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/PywWIHqiwD0/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/PywWIHqiwD0/hqdefault.jpg"
}
},
"channelTitle": "NTVKenya",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"oqbvhYxBE6fAbRk6m7aLlHf5s1I/boF8bbeOYRKjwV6Y_dmUEwIMD9Y\"",
"id": {
"kind": "youtube#video",
"videoId": "mmLD5ztBEp4"
},
"snippet": {
"publishedAt": "2014-06-06T22:38:02.000Z",
"channelId": "UCekTpzKodObpOcmvVCFUvTw",
"title": "#theTrend: Socialite Vera Sidika's new look",
"description": "Vera Sidika tells Larry Madowo about her skin lightening procedure, what she does for a living and her expensive lifestyle For more news visit ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/mmLD5ztBEp4/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/mmLD5ztBEp4/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/mmLD5ztBEp4/hqdefault.jpg"
}
},
"channelTitle": "NTVKenya",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"oqbvhYxBE6fAbRk6m7aLlHf5s1I/Bt6PHnNvhHX1COI1T3SPm9DVwUE\"",
"id": {
"kind": "youtube#video",
"videoId": "fQOmP8bNjqw"
},
"snippet": {
"publishedAt": "2013-04-27T19:23:09.000Z",
"channelId": "UCekTpzKodObpOcmvVCFUvTw",
"title": "Kenyan Spirit: Kenyan athlete gave up winning to help colleague",
"description": "http://www.ntv.co.ke And now to a story about selflessness and sacrifice and its about a Kenyan athlete. A picture they say is worth a thousand words and when a ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/fQOmP8bNjqw/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/fQOmP8bNjqw/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/fQOmP8bNjqw/hqdefault.jpg"
}
},
"channelTitle": "NTVKenya",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"oqbvhYxBE6fAbRk6m7aLlHf5s1I/ReuOIGBmLl_r53O88M9HMNlEwI4\"",
"id": {
"kind": "youtube#video",
"videoId": "LeyBaXQPe1E"
},
"snippet": {
"publishedAt": "2013-11-03T20:39:58.000Z",
"channelId": "UCekTpzKodObpOcmvVCFUvTw",
"title": "NTV Investigates: Seeds of Sin",
"description": "Religion has and will always be an emotive subject to many Kenyans. The constitution guarantees freedom of worship, but some are taking advantage of the ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/LeyBaXQPe1E/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/LeyBaXQPe1E/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/LeyBaXQPe1E/hqdefault.jpg"
}
},
"channelTitle": "NTVKenya",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"oqbvhYxBE6fAbRk6m7aLlHf5s1I/E5tUCJn1PIsHvXyaUiRT9-ENiI8\"",
"id": {
"kind": "youtube#video",
"videoId": "zMtzSqLgkP8"
},
"snippet": {
"publishedAt": "2012-04-23T19:15:19.000Z",
"channelId": "UCekTpzKodObpOcmvVCFUvTw",
"title": "Naked injustice:Ugandan women protest activist's arrest",
"description": "http://www.ntv.co.ke Hundreds of women activists in Uganda stripped to protest the arrest of a fellow activist. The women accused the police of mishandling the ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/zMtzSqLgkP8/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/zMtzSqLgkP8/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/zMtzSqLgkP8/hqdefault.jpg"
}
},
"channelTitle": "NTVKenya",
"liveBroadcastContent": "none"
}
}
]
}
关于java - 检索 YouTube 用户的供稿(上传),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34888878/