Class: Yt::Collections::ResumableSessions

Inherits:
Base
  • Object
show all
Defined in:
lib/yt/collections/resumable_sessions.rb

Overview

Provides methods to upload videos with the resumable upload protocol.

Resources with resumable sessions are: accounts.

Instance Method Summary collapse

Methods inherited from Base

#initialize, of, #where

Methods included from Actions::List

#first!

Constructor Details

This class inherits a constructor from Yt::Collections::Base

Instance Method Details

#insert(content_length, options = {}) ⇒ Object

Starts a resumable session by sending to YouTube the metadata of the video to upload. If the request succeeds, YouTube returns a unique URL to upload the video file (and eventually resume the upload).

Parameters:

  • content_length (Integer)

    the size (bytes) of the video to upload.

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

    the metadata to add to the uploaded video.

Options Hash (options):

  • :title (String)

    The video’s title.

  • :description (String)

    The video’s description.

  • :title (Array<String>)

    The video’s tags.

  • :privacy_status (String)

    The video’s privacy status.



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/yt/collections/resumable_sessions.rb', line 22

def insert(content_length, options = {})
  @headers = headers_for content_length
  body = {}

  snippet = options.slice :title, :description, :tags
  body[:snippet] = snippet if snippet.any?

  status = options[:privacy_status]
  body[:status] = {privacyStatus: status} if status

  do_insert body: body, headers: @headers
end