Search code examples
youtube

How do I know If a Video Becomes Unavailable in YouTube Data API v3?


When I request a snippet, statistics, status, on video Id: darZbXulSDI I am receiving that its status is public.

  "status": {
    "uploadStatus": "processed",
    "privacyStatus": "public",
    "license": "youtube",
    "embeddable": true,
    "publicStatsViewable": true,
    "madeForKids": false
  },
  "statistics": {
    "viewCount": "4",
    "likeCount": "1538",
    "favoriteCount": "0",
    "commentCount": "0"
  }

but on YouTube page, It shows unavailable. I also can't explain how the likes count exceeds the view count :)

What is the best way to check if a video becomes unavailable? And did the creator unlist this video, made it private, or deleted it?


Solution

  • I don't know how creators, if they are able to, make their videos unavailable.

    Note that Subscribe to Push Notifications sends a notification when a video of the tracked channel becomes private or unlisted or is deleted, for each of this case you will receive for instance:

    <?xml version=\'1.0\' encoding=\'UTF-8\'?>
    <feed xmlns:at="http://purl.org/atompub/tombstones/1.0" xmlns="http://www.w3.org/2005/Atom"><at:deleted-entry ref="yt:video:1RHxvM8mQS4" when="2022-10-24T13:39:07.99031+00:00">
      <link href="https://www.youtube.com/watch?v=1RHxvM8mQS4"/>
      <at:by>
       <name>Test</name>
       <uri>https://www.youtube.com/channel/UCv_LqFI-0vMVYgNR3TeB3zQ</uri>
      </at:by>
     </at:deleted-entry></feed>
    

    For an unlisted video (such as 8c-AHRlzyJs) you can retrieve this information from status/privacyStatus using YouTube Data API v3 Videos: list endpoint with part=snippet.

    Graphically you would get:

    private video UI rendering

    For such a private video, Videos: list won't return you any item for the given YouTube video id (if you aren't using OAuth 2 by being logged as the creator of the given video).

    For a deleted video you would graphically get:

    deleted video UI rendering

    For the video darZbXulSDI you sent, graphically you get:

    provided video UI rendering

    To distinguish both of them as they are both unavailable, you can use my open-source YouTube operational API. Indeed by requesting https://yt.lemnoslife.com/videos?part=status&id=VIDEO_ID, you would get whether or not the video was deleted by his uploader by reading item["status"]["removedByTheUploader"].

    Note that as we don't know how the video went unavailable and as people are able to like the video without watching it, this may explains how the likes count exceeds the view count.