使用youtube API,如何上传红宝石的私人视频?

时间:2019-06-04 04:58:48

标签: ruby youtube-api

我可以使用Ruby API将视频上传到YouTube。问题是我已要求可见性=>私有,并且视频以公共形式上传。其他字段(标题,说明)设置正确。我想念什么?

    body = {
      :snippet => {
       :title => 'file upload',
       :category_id => 29,
       :description => 'description of first file upload'
      },
      :status => {
        :privacyStatus => "private"
      },
   }
    puts "body: ", body 
    r = youtube.insert_video('snippet,status', body, upload_source: fname, content_type:'video/mp4') do |result, err|
      puts "result: ", result
      puts "err: ", err
    end

使用google-api-client(0.30.0)

1 个答案:

答案 0 :(得分:1)

google-api-client宝石需要下划线,然后在内部translates privacy_status to privacyStatus中使用。

也就是说,只需将代码更改为:

body = {
  :snippet => {
    :title => 'file upload',
    :category_id => 29,
    :description => 'description of first file upload'
  },
  :status => {
    :privacy_status =>'private'
  }
}

顺便说一句,您可能要考虑使用不太冗长的“新”哈希语法:

body = {
  snippet: {
   title: 'file upload',
   category_id: 29,
   description: 'description of first file upload'
  },
  status: {
    privacy_status: 'private'
  }
}