Class: EncodingDotCom::Queue
- Inherits:
-
Object
- Object
- EncodingDotCom::Queue
- Defined in:
- lib/encoding_dot_com/queue.rb
Overview
A remote facade to the encoding.com queue.
The queue is stateless and can be reused for multiple requests.
Constant Summary collapse
- ENDPOINT =
Where encoding.com expects messages to be posted to.
"http://manage.encoding.com/"
Instance Method Summary collapse
-
#add(source, formats = {}) ⇒ Object
Add a video/image to the encoding.com queue to be encoded in various formats.
-
#add_and_process(source, formats = {}) ⇒ Object
Add a video/image to the encoding.com queue to be encoded in various formats.
-
#cancel(media_id) ⇒ Object
Cancels a media item in the encoding.com queue.
-
#full_status(media_id) ⇒ Object
Returns the full status of an entry in the encoding.com queue, including details about the status of individual formats.
-
#info(media_id) ⇒ Object
Returns a MediaInfo object with some attributes of the video identified by media_id.
-
#initialize(user_id, user_key, http = HttpAdapters::CurbAdapter.new) ⇒ Queue
constructor
Creates a new facacde given an encoding.com user id & key, and an HTTP library implementation.
-
#list ⇒ Object
Returns a list of media in the encoding.com queue.
-
#process(media_id) ⇒ Object
Process an item already in the encoding.com queue.
-
#status(media_id) ⇒ Object
Returns the status string of a particular media item in the encoding.com queue.
-
#update(media_id, formats = {}) ⇒ Object
Replaces all the formats in an item on the encoding.com queue with the formats provided.
Constructor Details
#initialize(user_id, user_key, http = HttpAdapters::CurbAdapter.new) ⇒ Queue
Creates a new facacde given an encoding.com user id & key, and an HTTP library implementation.
user_id
-
your encoding.com user id
user_key
-
your encoding.com secret key
http
-
should respond to post, and return an object responding to
#code
and#to_s
18 19 20 |
# File 'lib/encoding_dot_com/queue.rb', line 18 def initialize(user_id, user_key, http=HttpAdapters::CurbAdapter.new) @user_id, @user_key, @http = user_id, user_key, http end |
Instance Method Details
#add(source, formats = {}) ⇒ Object
Add a video/image to the encoding.com queue to be encoded in various formats.
source
-
the source url
formats
-
a hash of destination urls => format objects
36 37 38 |
# File 'lib/encoding_dot_com/queue.rb', line 36 def add(source, formats={}) add_request("AddMediaBenchmark", source, formats) end |
#add_and_process(source, formats = {}) ⇒ Object
Add a video/image to the encoding.com queue to be encoded in various formats. Item will be processed after being added.
source
-
the source url
formats
-
a hash of destination urls => format objects
27 28 29 |
# File 'lib/encoding_dot_com/queue.rb', line 27 def add_and_process(source, formats={}) add_request("AddMedia", source, formats) end |
#cancel(media_id) ⇒ Object
Cancels a media item in the encoding.com queue
62 63 64 |
# File 'lib/encoding_dot_com/queue.rb', line 62 def cancel(media_id) make_request("CancelMedia") {|q| q.mediaid media_id } end |
#full_status(media_id) ⇒ Object
Returns the full status of an entry in the encoding.com queue, including details about the status of individual formats
50 51 52 53 54 |
# File 'lib/encoding_dot_com/queue.rb', line 50 def full_status(media_id) #:nodoc: response = make_request("GetStatus") do |q| q.mediaid media_id end end |
#info(media_id) ⇒ Object
Returns a MediaInfo object with some attributes of the video identified by media_id.
86 87 88 89 |
# File 'lib/encoding_dot_com/queue.rb', line 86 def info(media_id) response = make_request("GetMediaInfo") {|q| q.mediaid media_id } MediaInfo.new(response) end |
#list ⇒ Object
Returns a list of media in the encoding.com queue
57 58 59 |
# File 'lib/encoding_dot_com/queue.rb', line 57 def list make_request("GetMediaList").xpath("/response/media").map {|node| MediaListItem.new(node) } end |
#process(media_id) ⇒ Object
Process an item already in the encoding.com queue
67 68 69 |
# File 'lib/encoding_dot_com/queue.rb', line 67 def process(media_id) make_request("ProcessMedia") {|q| q.mediaid media_id } end |
#status(media_id) ⇒ Object
Returns the status string of a particular media item in the encoding.com queue. The status will be for the job as a whole, rather than individual ouput formats
43 44 45 46 |
# File 'lib/encoding_dot_com/queue.rb', line 43 def status(media_id) response = make_request("GetStatus") {|q| q.mediaid media_id } response.xpath("/response/status").text end |
#update(media_id, formats = {}) ⇒ Object
Replaces all the formats in an item on the encoding.com queue with the formats provided. This also kicks off the encoding process - there is no need to call process after this.
media_id
-
id of the item in the encoding.com queue
formats
-
a hash of destination urls => Format objects
77 78 79 80 81 82 |
# File 'lib/encoding_dot_com/queue.rb', line 77 def update(media_id, formats={}) make_request("UpdateMedia") do |q| q.mediaid media_id formats.each {|url, format| format.build_xml(q, url) } end end |