dsgrs26202 2015-09-05 11:37
浏览 324
已采纳

如果用户视频已从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.

  • 写回答

1条回答 默认 最新

  • donglangtun1850 2015-09-06 11:31
    关注

    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
    

    }

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制