8

Does anyone know how to check if a Youtube video is embeddable using the Youtube API? I've tried using this URL:

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

but the response I get, pasted below, doesn't seem to have a field for 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
ben
  • 29,229
  • 42
  • 124
  • 179

5 Answers5

17

As of the YouTube V3 API, there is an embeddable field in the status part.

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
}
maknz
  • 3,746
  • 3
  • 24
  • 21
  • Thanks, this was exactly what I was looking for! Sadly the API doesn't tell us straight away where stuff like this is, never thought it would be under status. – Carlos F Dec 18 '15 at 13:30
9

Looking at the YouTube API reference, it appears you have a couple choices:

Specify the "FORMAT" parameter when searching for a clip:

The format parameter specifies that videos must be available in a particular video format. Your request can specify any of the following formats:

5 - HTTP URL to the embeddable player (SWF) for this video. This format is not available for a video that is not embeddable. Developers commonly add &format=5 to their queries to restrict results to videos that can be embedded on their sites.

Or reference the yt:accessControl element:

The <yt:accessControl> tag indicates whether users are allowed to rate a video, add comments about a video, rate comments about the video, add a video response to the video, or embed the video on third-party websites. Another setting indicates whether YouTube can show the video on YouTube properties other than the YouTube.com website.

Syntax would look something like <yt:accessControl action='embed' permission='allowed'/>

So in your example it looks like the line yt:format: "5" tells you the clip can be embedded.

Community
  • 1
  • 1
BradC
  • 39,306
  • 13
  • 73
  • 89
7

In YouTube V3 API, to return only videos that are embeddable, add videoEmbeddable=true parameter. You must also use type=video for this to work.

Yuval A.
  • 5,849
  • 11
  • 51
  • 63
  • I tried, but didn't filter it. I used this: https://youtube.googleapis.com/youtube/v3/search?q=YOURQUERY&videoEmbeddable=false&type=video&key=YOURAPIKEY – Wim den Herder May 14 '22 at 08:32
2

If you can use the new object-free way of showing a video you'll see that almost every video not viewable with the object tag now work flawlessy.

Syntax is:

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

You can't trust yt:accessControl at this time.

JF Gagnon
  • 220
  • 3
  • 8
  • Hey, I am using the same to fetch youtube videos API that i am hitting is: http://gdata.youtube.com/feeds/api/charts/movies/trending?v=2&paid-content=false&hl=en&alt=json&format=5 Can you please suggest some way so that i can send some parameters in this api that can filter the results on basis of yt:accsessControl embed and syndicate fields... so how to embed this fields in api to filter results – Bhupendra Oct 07 '12 at 17:21
1

The XML should include <yt:noembed/> if the video isn't embeddable. Example.

Ashley Williams
  • 6,770
  • 4
  • 35
  • 42
  • This doesn't always seem to be the case. For example, http://gdata.youtube.com/feeds/api/videos/-KYUPJIzCyM does not have this tag but in a chromeless player I can't get it to embed. Maybe that's just me, though? – Ian Hunter Mar 25 '12 at 02:09