我想检测视频是否可以在 Youtube 之外播放。我目前正在检测侵犯版权、可嵌入和“可联合”的限制。我调用了两次 API,一次在版本 3 中,一次在版本 2 中,使用这些:
http://gdata.youtube.com/feeds/api/videos/{videoId}?v=2&alt=jsonc
https://www.googleapis.com/youtube/v3/videos?id={videoId}&key={key}&part=status
对于视频(https://www.youtube.com/watch?v=TzmyOT1kcfc),我得到以下答案:
{
"kind": "youtube#videoListResponse",
"etag": "\"kjEFmP90GvrCl8BObMQtGoRfgaQ/yoB7kT2xS4cnv1zDF-EiUrfidKQ\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"kjEFmP90GvrCl8BObMQtGoRfgaQ/mk9sFeT7lpR0qthcrYeJssWlayY\"",
"id": "TzmyOT1kcfc",
"status": {
"uploadStatus": "processed",
"privacyStatus": "public",
"license": "youtube",
"embeddable": true,
"publicStatsViewable": true
}
"player": {
"embedHtml": "<iframe type='text/html' src='http://www.youtube.com/embed/TzmyOT1kcfc' width='640' height='360' frameborder='0' allowfullscreen='true'/>"
}
}
]
}
和 :
{
"apiVersion": "2.1",
"data": {
"id": "TzmyOT1kcfc",
"uploaded": "2014-08-07T11:13:03.000Z",
"updated": "2014-09-22T01:13:46.000Z",
"uploader": "topgear",
"category": "Autos",
"title": "Aston Martin: DBS vs DB9 and Vanquish (HQ) - Top Gear - Series 10 - BBC",
"description": "Jeremy test drives the flashy Aston Martin DBS. Clip taken from series 10, episode 6.\n\nSubscribe for more awesome Top Gear videos: http://www.youtube.com/subscription_center?add_user=Topgear\n\nTop Gear YouTube channel: http://www.youtube.com/topgear\nTopGear.com website: http://www.topgear.com\n\nTop Gear Facebook: http://www.facebook.com/topgear\nTop Gear Twitter: http://twitter.com/BBC_topgear\n\nThis is a channel from BBC Worldwide who help fund new BBC programmes.",
"thumbnail": {
"sqDefault": "http://i.ytimg.com/vi/TzmyOT1kcfc/default.jpg",
"hqDefault": "http://i.ytimg.com/vi/TzmyOT1kcfc/hqdefault.jpg"
},
"player": {
"default": "http://www.youtube.com/watch?v=TzmyOT1kcfc&feature=youtube_gdata_player",
"mobile": "http://m.youtube.com/details?v=TzmyOT1kcfc"
},
"content": {
"1": "rtsp://r6---sn-5hn7su7k.c.youtube.com/CiILENy73wIaGQn3cWQ9ObI5TxMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp",
"5": "http://www.youtube.com/v/TzmyOT1kcfc?version=3&f=videos&app=youtube_gdata",
"6": "rtsp://r6---sn-5hn7su7k.c.youtube.com/CiILENy73wIaGQn3cWQ9ObI5TxMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp"
},
"duration": 438,
"aspectRatio": "widescreen",
"rating": 4.917057,
"likeCount": "2928",
"ratingCount": 2990,
"viewCount": 320436,
"favoriteCount": 0,
"commentCount": 143,
"accessControl": {
"comment": "allowed",
"commentVote": "allowed",
"videoRespond": "moderated",
"rate": "allowed",
"embed": "allowed",
"list": "allowed",
"autoPlay": "allowed",
"syndicate": "allowed"
}
}
}
所以我看到的是视频既可以“syndicatable”(可以在手机上观看)又可以嵌入,但它不能嵌入(https://www.youtube.com/embed/TzmyOT1kcfc?autoplay=true ==> 刷新页面)。该视频正在我的 Android 应用程序中播放,因为我使用的是官方的 Youtube SDK,所以我猜测,对于 Google,我的应用程序的这一部分是 Youtube 的一部分。
问题是:为什么在两个调用中,API 都告诉我它是可嵌入的,而它绝对不是?
我发现我可以在通过以“autoplay=true”作为参数启动嵌入式播放器返回的 HTML 中查找类“ytp-error html5-stop-propagation”,但是为每个解析 HTML 会非常昂贵优酷视频。您是否有其他方法可以确定视频是否真的可嵌入?
最后一个问题:我点击了我提供给你的关于这个主题的嵌入式播放器,它第一次工作,但当你刷新页面时就不行了。为什么?