2010-10-10 12 views
6

¿Alguien sabe cómo comprobar si un video de Youtube se puede integrar usando la API de Youtube? He intentado usar esta URL:¿Cómo uso la API de Youtube para verificar si un video es incrustable?

http://gdata.youtube.com/feeds/api/videos/47z7i79NuK8 

pero la respuesta que recibo, pegado a continuación, no parecen tener un campo para integrable?

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 

Respuesta

8

Mirando el YouTube API reference, parece que tienes un par de opciones:

especificar el parámetro "Formato" en la búsqueda de un clip:

El parámetro de formato especifica que los videos deben estar disponibles en una formato de video particular. Su solicitud puede especificar cualquiera de los siguientes formatos:

- HTTP URL del reproductor incrustable (SWF) para este video. Este formato no está disponible para un video que no se puede incrustar. Los desarrolladores comúnmente agregan & formato = 5 a sus consultas para restringir los resultados a videos que se pueden incrustar en sus sitios.

o referencia del yt: elemento AccessControl:

La etiqueta <yt:accessControl> indica si los usuarios pueden calificar un vídeo, añadir comentarios sobre un vídeo, comentarios de tasa sobre el vídeo, añadir una respuesta en vídeo a el video o incrusta el video en sitios web de terceros. Otra configuración indica si YouTube puede mostrar el video en propiedades de YouTube que no sean el sitio web de YouTube.com.

sintaxis sería algo así como <yt:accessControl action='embed' permission='allowed'/>

Así que en su ejemplo se ve como la línea yt:format: "5" te dice el clip puede ser embebido.

1

El XML debe incluir <yt:noembed/> si el vídeo no es integrable. Example.

+0

Esto no siempre parece ser el caso. Por ejemplo, http://gdata.youtube.com/feeds/api/videos/-KYUPJIzCyM no tiene esta etiqueta, pero en un reproductor sin bordes no puedo hacer que se incruste. ¿Tal vez solo soy yo, sin embargo? –

2

Si puede usar la nueva forma libre de objetos de mostrar un video, verá que casi todos los videos que no se pueden ver con la etiqueta de objeto ahora funcionan sin problemas.

sintaxis es:

< clase iframe = "youtube-jugador" width = "340" height = "220" src = "http://www.youtube.com/embed/YER_VIDEO_ID_HERE" frameborder = "0" > </iframe >

no se puede confiar en yt: AccessControl en este momento.

+0

Hey, estoy usando el mismo a buscar vídeos de YouTube API que estoy golpeando es: http://gdata.youtube.com/feeds/api/charts/movies/trending?v=2&paid-content=false&hl=en&alt = json & format = 5 ¿Puede sugerir alguna manera para que pueda enviar algunos parámetros en esta api que puedan filtrar los resultados en base a yt: accsessControl incrustar y sindicar campos ... entonces cómo incrustar estos campos en api para filtrar resultados – Bhupendra

6

A partir de la API de YouTube V3, hay un campo embeddable en la parte de estado.

E.g.https://www.googleapis.com/youtube/v3/videos?id=6CQEZ_kas0I&key=[yourkey]&part=snippet,contentDetails,status

"status": { 
    "uploadStatus": "processed", 
    "privacyStatus": "public", 
    "license": "youtube", 
    "embeddable": true, 
    "publicStatsViewable": true 
} 
+0

¡Gracias, esto era exactamente lo que estaba buscando! Lamentablemente, la API no nos dice de inmediato dónde están estas cosas, nunca pensé que estaría bajo estado. –

4

En la API de YouTube V3, para devolver sólo los vídeos que son integrables, añadir videoEmbeddable=true parámetro. También debe usar type=video para que esto funcione.

Cuestiones relacionadas