Class: NSIVideoGranulate::Client
- Inherits:
-
Object
- Object
- NSIVideoGranulate::Client
- Defined in:
- lib/nsivideogranulate/client.rb,
lib/nsivideogranulate/configuration.rb
Defined Under Namespace
Classes: Configuration
Class Method Summary collapse
-
.configure { ... } ⇒ Object
Pre-configure the NSIVideoGranulate module with default params for the NSIVideoGranulate::Client.
Instance Method Summary collapse
- #audio_key_for(video_key) ⇒ Object
- #converted_video_key_for(video_key) ⇒ Object
-
#done(key) ⇒ Hash
Verify if a video is already granulated.
-
#grains_keys_for(video_key) ⇒ Hash
Return the keys of the grains of a video.
-
#granulate(options = {}) ⇒ Hash
Send a video be granulated by a nsi.videogranulate node.
-
#initialize(params = {}) ⇒ Client
constructor
Initialize a client to a VideoGranulate node.
- #thumbnails_keys_for(video_key) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Client
if you had used the ‘configure’ method, you can use it without parameters and those you provided before will be used (see Client#configure)
Initialize a client to a VideoGranulate node
23 24 25 26 27 28 29 |
# File 'lib/nsivideogranulate/client.rb', line 23 def initialize(params = {}) params = Configuration.settings.merge(params) @user = params[:user] @password = params[:password] @host = params[:host] @port = params[:port] end |
Class Method Details
.configure { ... } ⇒ Object
Pre-configure the NSIVideoGranulate module with default params for the NSIVideoGranulate::Client
160 161 162 |
# File 'lib/nsivideogranulate/client.rb', line 160 def self.configure(&block) Configuration.instance_eval(&block) end |
Instance Method Details
#audio_key_for(video_key) ⇒ Object
139 140 141 142 |
# File 'lib/nsivideogranulate/client.rb', line 139 def audio_key_for(video_key) request = prepare_request :GET, {:video_key => video_key, :grains => true}.to_json execute_request(request).select { |key| 'audio' == key } end |
#converted_video_key_for(video_key) ⇒ Object
144 145 146 147 |
# File 'lib/nsivideogranulate/client.rb', line 144 def converted_video_key_for(video_key) request = prepare_request :GET, {:video_key => video_key, :grains => true}.to_json execute_request(request).select { |key| 'converted_video' == key } end |
#done(key) ⇒ Hash
Verify if a video is already granulated
109 110 111 112 |
# File 'lib/nsivideogranulate/client.rb', line 109 def done(key) request = prepare_request :GET, {:key => key}.to_json execute_request(request) end |
#grains_keys_for(video_key) ⇒ Hash
Return the keys of the grains of a video
129 130 131 132 |
# File 'lib/nsivideogranulate/client.rb', line 129 def grains_keys_for(video_key) request = prepare_request :GET, {:video_key => video_key, :grains => true}.to_json execute_request(request).select { |key| ['images', 'videos'].include? key } end |
#granulate(options = {}) ⇒ Hash
the filename is very importante, the videogranulate node will use the proper coding/encoding option for the video type
if provided both video_link and file options, file will be ignored and the client will download the video instead
Send a video be granulated by a nsi.videogranulate node
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/nsivideogranulate/client.rb', line 77 def granulate( = {}) @request_data = Hash.new if [:video_link] insert_download_data elsif [:sam_uid] && [:filename] file_data = {:video_uid => [:sam_uid], :filename => [:filename]} @request_data.merge! file_data elsif [:file] && [:filename] file_data = {:video => [:file], :filename => [:filename]} @request_data.merge! file_data else raise NSIVideoGranulate::Errors::Client::MissingParametersError end insert_callback_data request = prepare_request :POST, @request_data.to_json execute_request(request) end |
#thumbnails_keys_for(video_key) ⇒ Object
134 135 136 137 |
# File 'lib/nsivideogranulate/client.rb', line 134 def thumbnails_keys_for(video_key) request = prepare_request :GET, {:video_key => video_key, :grains => true}.to_json execute_request(request).select { |key| 'thumbnails' == key } end |