How do I check if a youtube video is blocked/restricted/deleted

12,491

Use the v3 API. https://developers.google.com/youtube/v3/docs/videos/list

Your question is in 2 parts.

  1. To check if video(s) have been removed from YouTube, send a videos:list request with the video ID(s). For a single ID you can just check if totalResults is 0. If checking multiple video IDs at once, cycle through the items response to see which video IDs still exist on YouTube.

Example:

GET https://www.googleapis.com/youtube/v3/videos?part=id&id=abcdefghijklm&key={YOUR_API_KEY}

{
 "kind": "youtube#videoListResponse",
 "etag": "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/qFRkUhSdCF83BrjXm7uub8slGsk\"",
 "pageInfo": {
  "totalResults": 0,
  "resultsPerPage": 0
 },
 "items": [
 ]
}
  1. To check for access restrictions, send a videos:list request for contentDetails.

Example:

GET https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id=IcmTyiVkhGk&key={YOUR_API_KEY}

Under items[] you'll check for

 "regionRestriction": {
 "blocked": [
  "QA",
  "AW",
  "IN",
  etc.
  ]
  }
Share:
12,491

Related videos on Youtube

theprogrammer311
Author by

theprogrammer311

Updated on September 15, 2022

Comments

  • theprogrammer311
    theprogrammer311 over 1 year

    I have a website that stores users playlists, but sometimes the videos that were once usable get removed due to copyright violations, or get deleted. I would like my website to automatically detect when this happens, so it can delete the video, or replace it. I'v done a lot of research trying to figure this out but nothing is working. for example, the api data request for the youtube video ID IcmTyiVkhGk (which is unavailable due to copyright) doesn't have a yt:state variable (which would indicate it is restricted), under access control, it does not say restricted or anything similar. How do you check for this type of data?

    http://gdata.youtube.com/feeds/api/videos/IcmTyiVkhGk?v=2&prettyprint=true

    basically using this to get the data, but no relevant data is there I don't think.

    this site is able to detect what regions the site is available in: http://polsy.org.uk/stuff/ytrestrict.cgi?ytid=IcmTyiVkhGk Does anyone know how this works?

  • theprogrammer311
    theprogrammer311 almost 9 years
    exactly what I ended up doing. Thanks.
  • Benny Ae
    Benny Ae over 8 years
    It looks working, because you put a fake ID in there. if you try a real disabled one, it won't work.
  • Morten Nilsen
    Morten Nilsen almost 8 years
    you need to ask for the status part, it will contain uploadStatus: rejected for removed videos, with a reason in rejectionStatus
  • Marten Koetsier
    Marten Koetsier about 5 years
    This does not work. Besides the fact that YT could change that text, the user may have settings such that another language is used.