Check if video is available

I am working on the YouTube v3 data API.

I want to know how I can check if a YouTube video has been disconnected or deleted.

for example: https://www.youtube.com/watch?v=dHt_6Z2OaZI

https://www.googleapis.com/youtube/v3/videos?id=dHt_6Z2OaZI &part=snippet,contentDetails,player,statistics,status &key=[mykey] 

I do not understand from the API.

 { "kind": "youtube#videoListResponse", "etag": "\"iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/Y7032cCbQSAurzEiVMjdFYzamtg\"", "pageInfo": { "totalResults": 1, "resultsPerPage": 1 }, "items": [ { "kind": "youtube#video", "etag": "\"iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/2FORRsUGqbS1nvQK3AR1PfmiN7I\"", "id": "dHt_6Z2OaZI", "snippet": {}, "contentDetails": { "duration": "PT1H31M1S", "dimension": "2d", "definition": "sd", "caption": "false", "licensedContent": false }, "status": { "uploadStatus": "processed", "privacyStatus": "public", "license": "youtube", "embeddable": true, "publicStatsViewable": true }, "statistics": { "viewCount": "301", "likeCount": "0", "dislikeCount": "0", "favoriteCount": "0", "commentCount": "0" }, "player": { "embedHtml": "<iframe width=\"640\" height=\"360\" src=\"//www.youtube.com/embed/dHt_6Z2OaZI\" frameborder=\"0\" allowfullscreen></iframe>" } } ] } 

I tried this

 https://www.googleapis.com/youtube/v3/videos ?part=id &key=[mykey] &id=dHt_6Z2OaZI 

But it does NOT work, it still gives a result.

+5
source share
1 answer

In the results published by you, there is a status field. I think the subfield that is most closely related to what you need is uploadStatus . When I make an API call for this video, I get:

 "status": { "uploadStatus": "rejected", "rejectionReason": "uploaderAccountSuspended", "privacyStatus": "public", "license": "youtube", "embeddable": true, "publicStatsViewable": true } 

From the documentation , here are the possible values โ€‹โ€‹for uploadStatus :

  • deleted
  • failed
  • processed
  • rejected
  • uploaded

After the video has been successfully uploaded and processed, it should be available to users (provided that it is also open). Therefore, you should simply check if the status is โ€œrejectedโ€ or โ€œdeletedโ€.

+1
source

All Articles