使用YouTube v3 API更新标题和说明?

时间:2014-07-22 21:14:43

标签: curl youtube-api

我使用YouTube Data API v3成功将视频上传到YouTube。没有使用第三方库。现在我想更新上传视频的标题和说明,但这似乎不可能!

这应该是一个明智的选择,但YouTube拒绝接受这个简单的查询:

curl --insecure -v -i -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer ACCESS_TOKEN_FROM_GOOGLE_HERE" -d '{"id":"YOUTUBE_VIDEO_ID_HERE","snippet":{"title":"My title","description":"My description","categoryId":"22"}}' "https://www.googleapis.com/youtube/v3/videos?part=snippet"

即使我确定该视频确实存在,但YouTube服务器仍会响应:

{
 "error": {
  "errors": [
   {
    "domain": "youtube.video",
    "reason": "videoNotFound",
    "message": "The video that you are trying to update cannot be found. Check t
he value of the \u003ccode\u003eid\u003c/code\u003e field in the request body to
 ensure that it is correct.",
    "locationType": "other",
    "location": "body.id"
   }
  ],
  "code": 404,
  "message": "The video that you are trying to update cannot be found. Check the
 value of the \u003ccode\u003eid\u003c/code\u003e field in the request body to e
nsure that it is correct."
 }
}

有人可以告诉我低级命令(不能使用第三方库)来成功更新上传视频的标题和说明吗?最好使用 curl

UPDATE:

我可以使用delete API删除该文件。因此,ID确实是正确的。

2 个答案:

答案 0 :(得分:3)

看起来你可能错过了“善意”的价值。

curl --insecure -v -i -X PUT -H "Content-Type: application/json" -H "Authorization:  Bearer ACCESS_TOKEN_FROM_GOOGLE_HERE" -d '{"id":"YOUTUBE_VIDEO_ID_HERE","kind":"youtube#video","snippet":{"title":"My title","description":"My description","categoryId":"22"}}' "https://www.googleapis.com/youtube/v3/videos?part=snippet"

答案 1 :(得分:0)

不确定原因,但如果我包含实际上传的整个json响应,则可行。也就是说,要更新说明,请执行以下操作:

  1. 上传视频。
  2. 等待回复。
  3. 解析json响应并替换描述文本。
  4. 使用新的json更新视频。
  5. 因此,使用剥离的json进行更新似乎不起作用。

相关问题