Class: BOTR::VideoCaption

Inherits:
Object
  • Object
show all
Defined in:
lib/botr/videos/video_caption.rb

Overview

The BOTR::VideoCaption class contains calls for manipulating videos captions.

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Authentication

#signature

Methods included from API

#api_call_class, #api_format, #api_key, #api_nonce, #api_protocol, #api_secret_key, #api_server, #api_timestamp, #api_url, #api_version, #progress_url, #upload_address, #upload_key, #upload_protocol, #upload_token, #upload_url

Methods included from HTTP

#client, #delete_request, #get_request, #post_request, #put_request

Constructor Details

#initialize(params = {}) ⇒ VideoCaption

Returns a new instance of VideoCaption.


92
93
94
95
96
97
98
# File 'lib/botr/videos/video_caption.rb', line 92

def initialize(params = {})
	params.each do |key, val|
		param = "@#{key.to_s}"
		next unless methods.include? key.to_sym
		instance_variable_set(param, val)
	end		
end

Class Attribute Details

.last_statusObject (readonly)

Returns the value of attribute last_status


8
9
10
# File 'lib/botr/videos/video_caption.rb', line 8

def last_status
  @last_status
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error


89
90
91
# File 'lib/botr/videos/video_caption.rb', line 89

def error
  @error
end

#formatObject (readonly)

Returns the value of attribute format


89
90
91
# File 'lib/botr/videos/video_caption.rb', line 89

def format
  @format
end

#keyObject (readonly)

Returns the value of attribute key


89
90
91
# File 'lib/botr/videos/video_caption.rb', line 89

def key
  @key
end

#labelObject (readonly)

Returns the value of attribute label


89
90
91
# File 'lib/botr/videos/video_caption.rb', line 89

def label
  @label
end

#last_statusObject (readonly)

Returns the value of attribute last_status


89
90
91
# File 'lib/botr/videos/video_caption.rb', line 89

def last_status
  @last_status
end

Returns the value of attribute link


89
90
91
# File 'lib/botr/videos/video_caption.rb', line 89

def link
  @link
end

#md5Object (readonly)

Returns the value of attribute md5


89
90
91
# File 'lib/botr/videos/video_caption.rb', line 89

def md5
  @md5
end

#positionObject (readonly)

Returns the value of attribute position


89
90
91
# File 'lib/botr/videos/video_caption.rb', line 89

def position
  @position
end

#statusObject (readonly)

Returns the value of attribute status


89
90
91
# File 'lib/botr/videos/video_caption.rb', line 89

def status
  @status
end

Class Method Details

.list(video_key, **options) ⇒ Array

Return a list of videos captions.

Parameters:

  • options (Hash)

    search parameters

Options Hash (**options):

  • video_key (String)

    key of the video which captions to list

  • search (String)

    case-insensitive search in the caption key and label fields

  • statuses_filter (String)

    list only captions with the specified statuses: "processing", "ready", "updating", "failed", "deleted"

  • order_by (String)

    specifies parameters by which returned result should be ordered; ":asc" and ":desc" can be appended accordingly

  • result_limit (Integer)

    specifies maximum number of captions to return; default is 50 and maximum result limit is 1000

  • result_offset (Integer)

    specifies how many captions should be skipped at the beginning of the result set; default is 0

Returns:

  • (Array)

    a list of video caption objects matching the search criteria


55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/botr/videos/video_caption.rb', line 55

def list(video_key, **options)
	json = get_request(options.merge(:method => 'list',
									 :video_key => video_key))
	res = JSON.parse(json.body)
	
	if json.status == 200
		results = process_list_response(res)
	else
		raise "HTTP Error #{json.status}: #{json.body}"
	end

	return results
end

.show(video_key) ⇒ BOTR::VideoCaption Also known as: find

Returns a new object with the properties of the caption referenced by the caption_key.

Parameters:

  • caption_key (String)

    key of the caption which information to show

Returns:

  • (BOTR::VideoCaption)

    a new object with the properties of the caption referenced by the caption_key


17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/botr/videos/video_caption.rb', line 17

def show(video_key)
	json = get_request({:method => 'show',
					    :caption_key => video_key})
	res = JSON.parse(json.body)

	if json.status == 200
		params = process_show_response(res)
	else
		raise "HTTP Error #{json.status}: #{json.body}"
	end

	return new(params)
end

Instance Method Details

#create(video_key, **options) ⇒ BOTR::VideoCaption

Create a new video caption.

caption; default is to insert at the end of the list

Parameters:

  • video_key (String)

    key of the video for which caption should be created

  • options (Hash)

    caption parameters

Options Hash (**options):

  • label (String)

    caption label

  • position (Integer)

    indicates where to insert the new

  • md5 (String)

    caption file MD5 message digest

  • size (Integer)

    caption file size

Returns:

  • (BOTR::VideoCaption)

    this video caption object with the parameters specified in the options hash and an upload link


114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/botr/videos/video_caption.rb', line 114

def create(video_key, **options)
	json = get_request(options.merge(:method => 'create',
									 :video_key => video_key))
	res = JSON.parse(json.body)

	if json.status == 200
		process_create_response(res)
	else
		raise "HTTP Error #{json.status}: #{json.body}"
	end

	return self
end

#deleteBOTR::VideoCaption

Delete a video caption.

Returns:


167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/botr/videos/video_caption.rb', line 167

def delete
	json = delete_request({:caption_key => @key})
	res = JSON.parse(json.body)

	if json.status == 200
		process_delete_response(res)
	else
		raise "HTTP Error #{json.status}: #{json.body}"
	end

	return self
end

#update(**options) ⇒ BOTR::VideoCaption

Update video caption.

caption; default is to insert at the end of the list

Parameters:

  • options (Hash)

    caption parameters

Options Hash (**options):

  • label (String)

    caption label

  • position (Integer)

    indicates where to insert the new

Returns:

  • (BOTR::VideoCaption)

    this video caption object with the parameters specified in the options hash and an optional upload link


151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/botr/videos/video_caption.rb', line 151

def update(**options)
	json = put_request(options.merge(:caption_key => @key))
	res = JSON.parse(json.body)

	if json.status == 200
		process_update_response(res, options)
	else
		raise "HTTP Error #{json.status}: #{json.body}"
	end

	return self
end

#upload(data_path, **options) ⇒ Object


128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/botr/videos/video_caption.rb', line 128

def upload(data_path, **options)
	json = post_request(options, data_path)
	res = JSON.parse(json.body)

	if json.status == 200
		process_upload_response(res)
	else
		raise "HTTP Error #{json.status}: #{json.body}"
	end

	return self
end