6

「Try It!」を使おうとしています。このページ: https://developers.google.com/youtube/v3/docs/videos/update

しかし、Bad request エラーが発生します。更新したい動画のIDはどこに設定すればよいですか?また、動画のタイトルまたは説明を更新するためのリクエスト形式は何ですか?

4

1 に答える 1

11

リクエストの形式は、次のような「ビデオ リソース」JSON パケットを送信することです。

{
"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"
    ]
  }
}

更新を行うときは、"id" と "kind" の値を、この場合は部分的な "snippet" と共に送信するだけで済みます。ただし、書き込み可能な属性 (snippet.title、snippet.description、snippet.tags、snippet.categoryId、および status.privacyStatus) については、それらを省略するとデフォルト (privacyStatus の場合は「public」、空白の場合) に戻ることに注意してください。他の 4)。categoryId を省略すると、不適切なリクエストが発生します。これは、カテゴリを設定しないように設定した場合と同じであり、YouTube では動画にカテゴリがないことを許可していないためです (これは、次に、categoryId を事実上の必須要素にします)。また、タグ、説明、およびプライバシー ステータスを再度含める必要があります (デフォルトで公開する場合を除きます)。これらが消去されないようにします。したがって、タイトルを変更するには、

{
 "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."
  }
 }
于 2012-11-20T21:00:21.940 に答える