Class: BOTR::VideoConversion

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

Overview

The BOTR::VideoConversion class calls are used to create, search for and delete individual video files (conversions) inside a video object.

A conversion is always created by applying a transcoding template to a video. A template contains information for the dimensions, bitrate and watermark of the resulting conversion.

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 = {}) ⇒ VideoConversion

Returns a new instance of VideoConversion.



90
91
92
93
94
95
96
# File 'lib/botr/videos/video_conversion.rb', line 90

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.



13
14
15
# File 'lib/botr/videos/video_conversion.rb', line 13

def last_status
  @last_status
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.



87
88
89
# File 'lib/botr/videos/video_conversion.rb', line 87

def duration
  @duration
end

#errorObject (readonly)

Returns the value of attribute error.



87
88
89
# File 'lib/botr/videos/video_conversion.rb', line 87

def error
  @error
end

#filesizeObject (readonly)

Returns the value of attribute filesize.



87
88
89
# File 'lib/botr/videos/video_conversion.rb', line 87

def filesize
  @filesize
end

#heightObject (readonly)

Returns the value of attribute height.



87
88
89
# File 'lib/botr/videos/video_conversion.rb', line 87

def height
  @height
end

#keyObject (readonly)

Returns the value of attribute key.



87
88
89
# File 'lib/botr/videos/video_conversion.rb', line 87

def key
  @key
end

#last_statusObject (readonly)

Returns the value of attribute last_status.



87
88
89
# File 'lib/botr/videos/video_conversion.rb', line 87

def last_status
  @last_status
end

Returns the value of attribute link.



87
88
89
# File 'lib/botr/videos/video_conversion.rb', line 87

def link
  @link
end

#mediatypeObject (readonly)

Returns the value of attribute mediatype.



87
88
89
# File 'lib/botr/videos/video_conversion.rb', line 87

def mediatype
  @mediatype
end

#statusObject (readonly)

Returns the value of attribute status.



87
88
89
# File 'lib/botr/videos/video_conversion.rb', line 87

def status
  @status
end

#templateObject (readonly)

Returns the value of attribute template.



87
88
89
# File 'lib/botr/videos/video_conversion.rb', line 87

def template
  @template
end

#widthObject (readonly)

Returns the value of attribute width.



87
88
89
# File 'lib/botr/videos/video_conversion.rb', line 87

def width
  @width
end

Class Method Details

.list(key, **options) ⇒ Array

List conversions for a given video.

conversions

Parameters:

  • video_key (String)

    key of the video for which to list

  • options (Hash)

    result parameters

Options Hash (**options):

  • result_limit (Integer)

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

  • result_offset (Integer)

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

Returns:

  • (Array)

    a list of video conversion objects for the given video key



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/botr/videos/video_conversion.rb', line 53

def list(key, **options)
	json = get_request(options.merge(:method => 'list',
									 :video_key => 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(conversion_key) ⇒ BOTR::VideoConversion Also known as: find

Returns a new object with the properties of the conversion referenced by the conversion_key.

Parameters:

  • conversion_key (String)

    key of the conversion for which to show information

Returns:

  • (BOTR::VideoConversion)

    a new object with the properties of the conversion referenced by the conversion_key



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/botr/videos/video_conversion.rb', line 22

def show(conversion_key)
	json = get_request({:method => 'show',
					    :conversion_key => conversion_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, template_key) ⇒ BOTR::VideoConversion

Create a new conversion of a video.

Parameters:

  • video_key (String)

    key of the video for which conversion should be created

  • template_key (String)

    key of the conversion template that should be used for this conversion.

Returns:

  • (BOTR::VideoConversion)

    this object with the properties of the conversion referenced by the template_key



107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/botr/videos/video_conversion.rb', line 107

def create(video_key, template_key)
	json = get_request({:method => 'create',
						:video_key => video_key,
						:template_key => template_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::VideoConversion

Delete a video conversion from the CDN.

Returns:



125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/botr/videos/video_conversion.rb', line 125

def delete
	json = delete_request({:conversion_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