Method: Yt::Models::Account#upload_video

Defined in:
lib/yt/models/account.rb

#upload_video(path_or_url, params = {}) ⇒ Yt::Models::Video

Uploads a video to the account’s channel.

Parameters:

  • path_or_url (String)

    the video to upload. Can either be the path of a local file or the URL of a remote file.

  • params (Hash) (defaults to: {})

    the metadata to add to the uploaded video.

Options Hash (params):

  • :title (String)

    The video’s title.

  • :description (String)

    The video’s description.

  • :tags (Array<String>)

    The video’s tags.

  • :privacy_status (String)

    The video’s privacy status.

  • :self_declared_made_for_kids (Boolean)

    The video’s made for kids self-declaration.

Returns:



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/yt/models/account.rb', line 76

def upload_video(path_or_url, params = {})
  file = URI.open(path_or_url)
  session = resumable_sessions.insert file.size, upload_body(params)

  session.update(body: file) do |data|
    Yt::Video.new(
      id: data['id'],
      snippet: data['snippet'],
      status: data['status'],
      auth: self
    )
  end
end