如果用户视频已从youtube中删除,如何在我的网站上将精选视频更改为最新上传的视频?

$url    =   "https://www.googleapis.com/youtube/v3/videos?id=".$row['video_id']."&part=contentDetails&key=[here is my Developer key]";

    if(file_get_contents($url))
    {
     return true;
    }
     else
     {
     false;
     }

When I check against a video id it show result like this if the video exists:

{
 "kind": "youtube#videoListResponse",
 "etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/pw80UEKFm5y728vQU5kjhUJTHGg\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 1
 },
 "items": [
  {
   "kind": "youtube#video",
   "etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/fBBgINoeGCSLK9f4shEUiy1MfeY\"",
   "id": "tyV0npY-0g8",
   "contentDetails": {
    "duration": "PT17M36S",
    "dimension": "2d",
    "definition": "hd",
    "caption": "false",
    "licensedContent": true
   }
  }
 ]
}

If the video does not exist against the id it shows total result 0 like this:

enter code here
{
 "kind": "youtube#videoListResponse",
 "etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/Rk41fm-2TD0VG1yv0-bkUvcBi9s\"",
 "pageInfo": {
  "totalResults": 0,
  "resultsPerPage": 0
 },
 "items": []
}

I'm storing the videoid in a database. Now if the video does not exist on youtube it generates a notification to the user: "your feature video is removed kindly update your video to newest upload video......."

Here is the screen shot also:

https://gyazo.com/d6e0afa338feef73b76a27a030eb060b

Kindly help me out.

Your screenshot shows a video that does exist but is not allowed to be embedded outside of YouTube. To check for that:

Add 'status' to your part paremeter:

$url    =   "https://www.googleapis.com/youtube/v3/videos?id=".$row['video_id']."&part=contentDetails,status&key=[here is my Developer key]";

then you can check the 'embeddable' field in the results:

"status": {
"uploadStatus": "processed",
"privacyStatus": "public",
"license": "youtube",
"embeddable": true,
"publicStatsViewable": true

}