使用 YouTube v3 API 更新标题和说明? [英] Update title and description using YouTube v3 API?
问题描述
我使用 YouTube Data API v3 成功地将视频上传到了 YouTube.没有使用第三方库.现在我想更新上传视频的标题和描述,但这似乎是不可能的!
I successfully uploaded a video to YouTube using YouTube Data API v3. No third party libraries were used. Now I want to update the title and description of an uploaded video, but this seems impossible!
这应该是显而易见的,但 YouTube 拒绝接受这个简单的查询:
This should be a no-brainer, but YouTube refuses to accept this simple query:
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":"我的标题","description":"我的描述","categoryId":"22"}}' "https://www.googleapis.com/youtube/v3/videos?part=片段"
即使我很确定视频确实存在 YouTube 服务器也会这样响应:
Even though I'm dead sure that the video does exist YouTube server responds with this:
{
"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 u003ccodeu003eidu003c/codeu003e 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 u003ccodeu003eidu003c/codeu003e field in the request body to e
nsure that it is correct."
}
}
谁能告诉我低级命令(不能使用第三方库)来成功更新上传视频的标题和描述?最好使用 curl.
Can somebody please show me the low-level commands (cannot use third party library) to successfully update the title and description of an uploaded video? Preferably using curl.
我可以使用 delete API 删除文件.因此,ID确实是正确的.
I am able to delete the file using the delete API. Hence, the ID is indeed correct.
推荐答案
不知道为什么,但是如果我包含来自实际上传的整个 json
响应,它就可以工作.也就是说,要更新描述,我会执行以下操作:
Not sure why, but if I include the entire json
response from the actual upload, it works. That is, to update the description I do the following:
- 上传视频.
- 等待回复.
- 解析 json 响应并替换描述文本.
- 使用新的 json 更新视频.
因此,使用精简的 json 进行更新似乎不起作用.
Hence, updating using a stripped down json does not seem to work.
这篇关于使用 YouTube v3 API 更新标题和说明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!