How to update YouTube videos using API v3

I am trying to use "Try It!" on this page: https://developers.google.com/youtube/v3/docs/videos/update

But I get an invalid request error. Where should I set the ID of the video I want to update? And what is the request format for updating the title or description of the video?

+4
source share
1 answer

The request format is designed to send a JSON "video resource" package that looks something like this:

{ "id": "GS9h8M3ep-M", "kind": "youtube#video", "etag": "\"MhkxP1IuK4vYJ-nhM3d9E49-2oU/HUmayeWdVX19XyvhE5c2RnbZjgA\"", "snippet": { "publishedAt": "2012-11-10T09:36:49.000Z", "channelId": "UC070UP0rK7rShCW1x4B4bgg", "title": "Finding Ourselves: The Humanities as a Discipline", "description": "Lecture delivered by Geoffrey Harpham, of the National Humanities Center, at the inaugural event of the Brigham Young University Humanities Center.", "thumbnails": { "default": { "url": "https://i.ytimg.com/vi/GS9h8M3ep-M/default.jpg" }, "medium": { "url": "https://i.ytimg.com/vi/GS9h8M3ep-M/mqdefault.jpg" }, "high": { "url": "https://i.ytimg.com/vi/GS9h8M3ep-M/hqdefault.jpg" } }, "categoryId": "27", "tags": [ "humanities", "Harpham", "BYU" ] } } 

When performing the update, you need to send only the values ​​"id" and "kind", and in this case, a partial "fragment". However, keep in mind that for recorded attributes - snippet.title, snippet.description, snippet.tags, snippet.categoryId and status.privacyStatus - dropping them will return to default ("public" for privacyStatus, empty for another 4). If you must omit categoryId, then this leads to bad queries, because it would be as if you set it to no category, and Youtube does not allow the video to not have a category (this, then, making categoryId a necessary defacto element ) You also need to re-enable the tags, description and privacy status (if you do not want it to be available by default), so they will not be cleared. Thus, to change the title, you must include the fragment, its title and its category identifier, for example:

 { "id": "GS9h8M3ep-M", "kind": "youtube#video", "snippet": { "title": "I'm being changed.", "categoryId": "27", "tags": [ "humanities", "Harpham", "BYU" ], "description": " can be changed, too, but if I'm not to be I still have to be included as I was before. I will be emptied out if omitted." } } 
+7
source

Source: https://habr.com/ru/post/1447172/


All Articles