因此,我尝试通过JSON格式从单个youtube视频中获取信息。像标题描述类别一样,除了评论之外,我还能得到什么。我正在尝试使用Javascript执行此操作。我注意到下面的链接,但是他们的所有示例都是如何从Feed中获取视频信息。我想从一个视频中获取信息,前提是我知道它的ID。
https://developers.google.com/youtube/2.0/developers_guide_json
我也在看这个Stackoverflow问题,但是get请求有一个问题,它说“ test.js(第10行)GET http://gdata.youtube.com/feeds/api/videos/VA770w...v= 2&alt = json-in-script&callback = listInfo
200 OK 9ms”
简而言之,如果我只有一个youtube视频ID(例如VA770wpLX-Q),则该URL看起来像什么才能以JSON格式获取视频信息?
谢谢
2015年5月更新:
该解决方案无法正常运行,YouTube API v2正在进行中,即将停用。
尝试这样的事情:
var video_id='VA770wpLX-Q'; $.getJSON('http://gdata.youtube.com/feeds/api/videos/'+video_id+'?v=2&alt=jsonc',function(data,status,xhr){ alert(data.data.title); // data contains the JSON-Object below });
演示:http://jsfiddle.net/wqwxg/
返回的JSON如下所示:
{ "apiVersion": "2.1", "data": { "id": "VA770wpLX-Q", "uploaded": "2011-02-24T22:31:02.000Z", "updated": "2012-04-08T21:37:06.000Z", "uploader": "drdrevevo", "category": "Music", "title": "Dr. Dre - I Need A Doctor (Explicit) ft. Eminem, Skylar Grey", "description": "Music video by Dr. Dre performing I Need A Doctor featuring Eminem and Skylar Grey (Explicit). © 2011 Aftermath Records", "tags": ["Dr", "Dre", "Eminem", "New", "Song", "Skylar", "Grey", "GRAMMYs", "Dr.", "Need", "Doctor", "video", "Eazy", "N.W.A.", "NWA", "easy", "drdre", "and", "em"], "thumbnail": { "sqDefault": "http://i.ytimg.com/vi/VA770wpLX-Q/default.jpg", "hqDefault": "http://i.ytimg.com/vi/VA770wpLX-Q/hqdefault.jpg" }, "player": { "default": "http://www.youtube.com/watch?v=VA770wpLX-Q&feature=youtube_gdata_player" }, "content": { "5": "http://www.youtube.com/v/VA770wpLX-Q?version=3&f=videos&app=youtube_gdata" }, "duration": 457, "aspectRatio": "widescreen", "rating": 4.902695, "likeCount": "430519", "ratingCount": 441253, "viewCount": 88270796, "favoriteCount": 306556, "commentCount": 270597, "status": { "value": "restricted", "reason": "requesterRegion" }, "restrictions": [{ "type": "country", "relationship": "deny", "countries": "DE" }], "accessControl": { "comment": "allowed", "commentVote": "allowed", "videoRespond": "allowed", "rate": "allowed", "embed": "allowed", "list": "allowed", "autoPlay": "denied", "syndicate": "allowed" } } }