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 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀