Class: BOTR::VideoThumbnail

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

Overview

The BOTR::VideoThumbnail class contains calls for managing the preview image of a video.

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

Returns a new instance of VideoThumbnail.



47
48
49
50
51
52
53
# File 'lib/botr/videos/video_thumbnail.rb', line 47

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.



9
10
11
# File 'lib/botr/videos/video_thumbnail.rb', line 9

def last_status
  @last_status
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



44
45
46
# File 'lib/botr/videos/video_thumbnail.rb', line 44

def error
  @error
end

#keyObject (readonly)

Returns the value of attribute key.



44
45
46
# File 'lib/botr/videos/video_thumbnail.rb', line 44

def key
  @key
end

#last_statusObject (readonly)

Returns the value of attribute last_status.



44
45
46
# File 'lib/botr/videos/video_thumbnail.rb', line 44

def last_status
  @last_status
end

Returns the value of attribute link.



44
45
46
# File 'lib/botr/videos/video_thumbnail.rb', line 44

def link
  @link
end

#statusObject (readonly)

Returns the value of attribute status.



44
45
46
# File 'lib/botr/videos/video_thumbnail.rb', line 44

def status
  @status
end

#strip_errorObject (readonly)

Returns the value of attribute strip_error.



44
45
46
# File 'lib/botr/videos/video_thumbnail.rb', line 44

def strip_error
  @strip_error
end

#strip_statusObject (readonly)

Returns the value of attribute strip_status.



44
45
46
# File 'lib/botr/videos/video_thumbnail.rb', line 44

def strip_status
  @strip_status
end

Class Method Details

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

Returns a new object with the thumbnail status of the video referenced by the video key.

Parameters:

  • video_key (String)

    key of the video for which to show thumbnails creation status

Returns:

  • (BOTR::VideoThumbnail)

    a new object with the thumbnail status of the video referenced by the video key



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

def show(video_key)
	json = get_request({:method => 'show',
					    :video_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

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

Update a video’s thumbnail by either setting a frame from the video or uploading an image.

optional upload link

Parameters:

  • options (Hash)

    video parameters

Options Hash (**options):

  • position (Float)

    video frame position in seconds from which thumbnail should be generated; seconds can be given as a whole number (e.g: 7) or with the fractions (e.g.: 7.42)

  • tags (String)

    tags for the video; multiple tags should be comma-separated

  • thumbnail_index (Integer)

    index of the image in the thumbnail strip to use as a video thumbnail; thumbnail index starts from 1

  • md5 (String)

    thumbnail file MD5 message digest

  • size (Integer)

    thumbnail file size

Returns:



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/botr/videos/video_thumbnail.rb', line 73

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

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

	return self
end

#upload(data_path, **options) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/botr/videos/video_thumbnail.rb', line 86

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