2010-10-10 13 views
6

Qualcuno sa come controllare se un video di YouTube è integrabile utilizzando l'API di Youtube? Ho provato con questo URL:Come utilizzare l'API di YouTube per verificare se un video è integrabile?

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

ma la risposta che ricevo, incollato al di sotto, non sembra avere un campo per embeddable?

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 

risposta

8

Guardando il YouTube API reference, sembra di avere un paio di scelte:

specificare il parametro "FORMAT" durante la ricerca di una clip:

Il parametro formato specifica che i video devono essere disponibili in una formato video particolare. La tua richiesta può specificare uno dei seguenti formati:

- URL HTTP per il player integrabile (SWF) per questo video. Questo formato non è disponibile per un video che non è incorporabile. Gli sviluppatori aggiungono comunemente il formato & = 5 alle loro query per limitare i risultati ai video che possono essere incorporati nei loro siti.

o riferimento YT: elemento AccessControl:

Il tag <yt:accessControl> indica se gli utenti sono autorizzati a votare un video, aggiungere commenti su un video, i commenti dei tassi sul video, aggiungere un video di risposta a il video o incorporare il video su siti Web di terzi. Un'altra impostazione indica se YouTube può mostrare il video su proprietà di YouTube diverse dal sito Web YouTube.com.

sintassi sarebbe simile <yt:accessControl action='embed' permission='allowed'/>

Quindi nel tuo esempio sembra che la linea yt:format: "5" ti dice la clip può essere incorporato.

1

L'XML dovrebbe includere <yt:noembed/> se il video non è integrabile. Example.

+0

Questo non sembra essere sempre il caso. Ad esempio, http://gdata.youtube.com/feeds/api/videos/-KYUPJIzCyM non ha questo tag ma in un player chromeless non riesco a farlo incorporare. Forse sono solo io, però? –

2

Se è possibile utilizzare il nuovo modo di mostrare un oggetto senza oggetti, vedrete che quasi tutti i video non visualizzabili con il tag dell'oggetto ora funzionano in modo impeccabile.

La sintassi è:

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

non è possibile fidarsi di YT: AccessControl in questo momento.

+0

Ehi, sto usando lo stesso per recuperare i video di YouTube API che sto colpendo è: http://gdata.youtube.com/feeds/api/charts/movies/trending?v=2&paid-content=false&hl=it&alt = json & format = 5 Puoi suggerire qualche modo in modo da poter inviare alcuni parametri in questa API che può filtrare i risultati sulla base di yt: accsessControl incorporare e sindacare i campi ... quindi come incorporare questi campi in api per filtrare risultati – Bhupendra

6

Come per l'API V3 di YouTube, c'è un campo embeddable nella parte stato.

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

Grazie, questo era esattamente quello che stavo cercando! Purtroppo l'API non ci dice subito dove sono cose del genere, mai pensato che sarebbe stato in stato. –

4

In YouTube API V3, per restituire solo i video che sono embeddable, aggiungere videoEmbeddable=true parametro. È necessario utilizzare anche type=video affinché funzioni.

Problemi correlati