从Youtube Data API搜索结果Feed中,如何确定视频是否会显示版权信息而不播放?

时间:2011-07-07 04:03:20

标签: youtube youtube-api

我正在使用Data API执行搜索。有时当我尝试显示视频结果时,我会收到以下类型的消息:

  

此视频包含来自EMI的内容,   谁在你的国家阻止它   版权理由。

如何确定视频是否无法播放,而是从搜索结果中显示此消息?

以下是我正在进行的搜索示例:

http://gdata.youtube.com/feeds/api/videos?q=Explosions+in+the+Sky+So+Long++Lonesome

这是第一个结果,我尝试显示并获取版权信息:

{"id"=>"http://gdata.youtube.com/feeds/api/videos/jotDBl1vilg", "published"=>"2009-01-24T00:08:01.000Z", "updated"=>"2011-07-05T21:57:58.000Z", "category"=>[{"scheme"=>"http://schemas.google.com/g/2005#kind", "term"=>"http://gdata.youtube.com/schemas/2007#video"}, {"scheme"=>"http://gdata.youtube.com/schemas/2007/categories.cat", "term"=>"Music", "label"=>"Music"}, {"scheme"=>"http://gdata.youtube.com/schemas/2007/keywords.cat", "term"=>"explosions"}, {"scheme"=>"http://gdata.youtube.com/schemas/2007/keywords.cat", "term"=>"in"}, {"scheme"=>"http://gdata.youtube.com/schemas/2007/keywords.cat", "term"=>"the"}, {"scheme"=>"http://gdata.youtube.com/schemas/2007/keywords.cat", "term"=>"sky"}, {"scheme"=>"http://gdata.youtube.com/schemas/2007/keywords.cat", "term"=>"so"}, {"scheme"=>"http://gdata.youtube.com/schemas/2007/keywords.cat", "term"=>"long"}, {"scheme"=>"http://gdata.youtube.com/schemas/2007/keywords.cat", "term"=>"lonesome"}, {"scheme"=>"http://gdata.youtube.com/schemas/2007/keywords.cat", "term"=>"eits"}, {"scheme"=>"http://gdata.youtube.com/schemas/2007/keywords.cat", "term"=>"indie"}, {"scheme"=>"http://gdata.youtube.com/schemas/2007/keywords.cat", "term"=>"rock"}, {"scheme"=>"http://gdata.youtube.com/schemas/2007/keywords.cat", "term"=>"instrumental"}, {"scheme"=>"http://gdata.youtube.com/schemas/2007/keywords.cat", "term"=>"austin"}, {"scheme"=>"http://gdata.youtube.com/schemas/2007/keywords.cat", "term"=>"texas"}, {"scheme"=>"http://gdata.youtube.com/schemas/2007/keywords.cat", "term"=>"music"}, {"scheme"=>"http://gdata.youtube.com/schemas/2007/keywords.cat", "term"=>"video"}, {"scheme"=>"http://gdata.youtube.com/schemas/2007/keywords.cat", "term"=>"solar"}, {"scheme"=>"http://gdata.youtube.com/schemas/2007/keywords.cat", "term"=>"system"}], "title"=>"explosions in the sky - \"so long, lonesome\"", "content"=>"jakefyfe.tumblr.com watch in high quality. \"so long, lonesome\" i didn't realize until now how many videos were already on youtube for this song. im going to leave it up anyway.", "link"=>[{"rel"=>"alternate", "type"=>"text/html", "href"=>"http://www.youtube.com/watch?v=jotDBl1vilg&feature=youtube_gdata"}, {"rel"=>"http://gdata.youtube.com/schemas/2007#video.responses", "type"=>"application/atom+xml", "href"=>"http://gdata.youtube.com/feeds/api/videos/jotDBl1vilg/responses"}, {"rel"=>"http://gdata.youtube.com/schemas/2007#video.related", "type"=>"application/atom+xml", "href"=>"http://gdata.youtube.com/feeds/api/videos/jotDBl1vilg/related"}, {"rel"=>"http://gdata.youtube.com/schemas/2007#mobile", "type"=>"text/html", "href"=>"http://m.youtube.com/details?v=jotDBl1vilg"}, {"rel"=>"self", "type"=>"application/atom+xml", "href"=>"http://gdata.youtube.com/feeds/api/videos/jotDBl1vilg"}], "author"=>{"name"=>"jakefyfe", "uri"=>"http://gdata.youtube.com/feeds/api/users/jakefyfe"}, "comments"=>{"feedLink"=>{"href"=>"http://gdata.youtube.com/feeds/api/videos/jotDBl1vilg/comments", "countHint"=>"43"}}, "group"=>{"category"=>"Music", "content"=>[{"url"=>"http://www.youtube.com/v/jotDBl1vilg?f=videos&app=youtube_gdata", "type"=>"application/x-shockwave-flash", "medium"=>"video", "isDefault"=>"true", "expression"=>"full", "duration"=>"247", "yt:format"=>"5"}, {"url"=>"rtsp://v6.cache1.c.youtube.com/CiILENy73wIaGQlYim9dBkOLjhMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp", "type"=>"video/3gpp", "medium"=>"video", "expression"=>"full", "duration"=>"247", "yt:format"=>"1"}, {"url"=>"rtsp://v6.cache1.c.youtube.com/CiILENy73wIaGQlYim9dBkOLjhMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp", "type"=>"video/3gpp", "medium"=>"video", "expression"=>"full", "duration"=>"247", "yt:format"=>"6"}], "description"=>"jakefyfe.tumblr.com watch in high quality. \"so long, lonesome\" i didn't realize until now how many videos were already on youtube for this song. im going to leave it up anyway.", "keywords"=>"explosions, in, the, sky, so, long, lonesome, eits, indie, rock, instrumental, austin, texas, music, video, solar, system", "player"=>{"url"=>"http://www.youtube.com/watch?v=jotDBl1vilg&feature=youtube_gdata_player"}, "restriction"=>"AU NZ","thumbnail"=>[{"url"=>"http://i.ytimg.com/vi/jotDBl1vilg/0.jpg", "height"=>"240", "width"=>"320", "time"=>"00:02:03.500"}, {"url"=>"http://i.ytimg.com/vi/jotDBl1vilg/1.jpg", "height"=>"90", "width"=>"120", "time"=>"00:01:01.750"}, {"url"=>"http://i.ytimg.com/vi/jotDBl1vilg/2.jpg", "height"=>"90", "width"=>"120", "time"=>"00:02:03.500"}, {"url"=>"http://i.ytimg.com/vi/jotDBl1vilg/3.jpg", "height"=>"90", "width"=>"120", "time"=>"00:03:05.250"}], "title"=>"explosions in the sky - \"so long, lonesome\"", "duration"=>{"seconds"=>"247"}}, "rating"=>{"average"=>"4.962766", "max"=>"5", "min"=>"1", "numRaters"=>"188", "rel"=>"http://schemas.google.com/g/2005#overall"}, "statistics"=>{"favoriteCount"=>"450", "viewCount"=>"57066"}}

该结果中的哪些内容表示无法播放视频?

2 个答案:

答案 0 :(得分:0)

我想你想要找"media:restriction" field

例如试试这个:

http://gdata.youtube.com/feeds/api/videos/jotDBl1vilg?fields=media:group/media:restriction&alt=json

答案 1 :(得分:0)

使用youtube api v3,videoLicense字段有三个可能的参数,请使用以下其中一个:

videoLicense=any
videoLicense=creativeCommon
videoLicense=youtube

开始了解你是否可以在youtube中播放它。如果您在youtube之外使用它,请尝试使用videoSyndicated查询。

videoSyndicated=true

允许您搜索可在youtube外播放的视频,例如在使用youtube的移动应用中播放。

请查看参考资料以获取更多信息:YouTube V3 search.list reference