是否有人知道如何使用Youtube API检查Youtube视频是否可嵌入?我尝试过使用此网址:
http://gdata.youtube.com/feeds/api/videos/47z7i79NuK8
但我得到的答案,粘贴在下面,似乎没有嵌入字段?
entry:
rating:
rel: http://schemas.google.com/g/2005#overall
max: "5"
min: "1"
average: "4.744681"
numRaters: "94"
group:
duration:
seconds: "47"
player:
url: http://www.youtube.com/watch?v=47z7i79NuK8&feature=youtube_gdata_player
category: Entertainment
title: "Sesame Street: P is For Princess available everywhere on DVD!"
thumbnail:
- time: "00:00:23.500"
url: http://i.ytimg.com/vi/47z7i79NuK8/2.jpg
height: "90"
width: "120"
- time: "00:00:11.750"
url: http://i.ytimg.com/vi/47z7i79NuK8/1.jpg
height: "90"
width: "120"
- time: "00:00:35.250"
url: http://i.ytimg.com/vi/47z7i79NuK8/3.jpg
height: "90"
width: "120"
- time: "00:00:23.500"
url: http://i.ytimg.com/vi/47z7i79NuK8/0.jpg
height: "240"
width: "320"
content:
duration: "47"
medium: video
yt:format: "5"
isDefault: "true"
url: http://www.youtube.com/v/47z7i79NuK8?f=videos&app=youtube_gdata
expression: full
type: application/x-shockwave-flash
description: |-
"Once upon a time on Sesame Street, there lived a fairy-in-training named Abby Cadabby, and she loved playing princess with friends like Rosita. But what happens when a misguided Prince (actor Paul Rudd) tries to rescue them? Pretending and the Letter P are the focus of this enchanting title, which also features fun with Natalie Portman and Elmo in "The Princess and The Elephant." This DVD also includes two bonus episodes of Sesame Street's new animated show, Abby's Flying Fairy School."
www.sesamestreet.org/princess
keywords: sesame street, muppets, princess, dvd, abby, abby's flying fairy school
control:
state: Syndication of this video was restricted by its owner.
category:
- term: http://gdata.youtube.com/schemas/2007#video
scheme: http://schemas.google.com/g/2005#kind
- label: Entertainment
term: Entertainment
scheme: http://gdata.youtube.com/schemas/2007/categories.cat
- term: sesame street
scheme: http://gdata.youtube.com/schemas/2007/keywords.cat
- term: muppets
scheme: http://gdata.youtube.com/schemas/2007/keywords.cat
- term: princess
scheme: http://gdata.youtube.com/schemas/2007/keywords.cat
- term: dvd
scheme: http://gdata.youtube.com/schemas/2007/keywords.cat
- term: abby
scheme: http://gdata.youtube.com/schemas/2007/keywords.cat
- term: abby's flying fairy school
scheme: http://gdata.youtube.com/schemas/2007/keywords.cat
comments:
feedLink:
href: http://gdata.youtube.com/feeds/api/videos/47z7i79NuK8/comments
countHint: "80"
author:
name: SesameStreet
uri: http://gdata.youtube.com/feeds/api/users/sesamestreet
title: "Sesame Street: P is For Princess available everywhere on DVD!"
statistics:
favoriteCount: "43"
viewCount: "6003"
published: "2010-10-08T19:18:09.000Z"
xmlns:yt: http://gdata.youtube.com/schemas/2007
id: http://gdata.youtube.com/feeds/api/videos/47z7i79NuK8
xmlns:gd: http://schemas.google.com/g/2005
content: |-
"Once upon a time on Sesame Street, there lived a fairy-in-training named Abby Cadabby, and she loved playing princess with friends like Rosita. But what happens when a misguided Prince (actor Paul Rudd) tries to rescue them? Pretending and the Letter P are the focus of this enchanting title, which also features fun with Natalie Portman and Elmo in "The Princess and The Elephant." This DVD also includes two bonus episodes of Sesame Street's new animated show, Abby's Flying Fairy School."
www.sesamestreet.org/princess
link:
- href: http://www.youtube.com/watch?v=47z7i79NuK8&feature=youtube_gdata
rel: alternate
type: text/html
- href: http://gdata.youtube.com/feeds/api/videos/47z7i79NuK8/related
rel: http://gdata.youtube.com/schemas/2007#video.related
type: application/atom+xml
- href: http://gdata.youtube.com/feeds/api/videos/47z7i79NuK8
rel: self
type: application/atom+xml
xmlns:media: http://search.yahoo.com/mrss/
updated: "2010-10-10T06:36:39.000Z"
xmlns:app: http://purl.org/atom/app#
xmlns: http://www.w3.org/2005/Atom
答案 0 :(得分:8)
查看YouTube API reference,您似乎有两个选择:
搜索剪辑时指定“FORMAT”参数:
format参数指定视频必须以特定视频格式提供。您的请求可以指定以下任何格式:
5 - 此视频的嵌入播放器(SWF)的HTTP URL。此格式不适用于无法嵌入的视频。开发人员通常会在其查询中添加& format = 5,以将结果限制为可嵌入其网站的视频。
或者引用yt:accessControl元素:
<yt:accessControl>
代码表示是否允许用户为视频评分,添加视频评论,评价视频评论,为视频添加视频回复或将视频嵌入第三方网站。另一项设置表明YouTube是否可以在YouTube.com网站以外的YouTube媒体资源上显示该视频。
语法看起来像<yt:accessControl action='embed' permission='allowed'/>
因此,在您的示例中,看起来行yt:format: "5"
告诉您可以嵌入剪辑。
答案 1 :(得分:7)
自YouTube V3 API起,状态部分中有一个embeddable
字段。
"status": {
"uploadStatus": "processed",
"privacyStatus": "public",
"license": "youtube",
"embeddable": true,
"publicStatsViewable": true
}
答案 2 :(得分:6)
在YouTube V3 API中,要仅返回可嵌入的视频,请添加
videoEmbeddable=true
参数。您还必须使用type=video
才能生效。
答案 3 :(得分:2)
如果您可以使用新的无对象显示视频的方式,您会看到几乎所有无法使用对象标签查看的视频现在都可以正常运行。
语法是:
&lt; iframe class =“youtube-player” 宽度= “340” 高度= “220” SRC = “http://www.youtube.com/embed/YER_VIDEO_ID_HERE” FRAMEBORDER = “0” &GT;&LT; / iframe中&GT;
您目前无法信任yt:accessControl。
答案 4 :(得分:1)
如果视频无法嵌入,则XML应包含<yt:noembed/>
。 Example