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/format attribute hashes
38 39 40 |
# File 'lib/encoding_dot_com/queue.rb', line 38 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/format attribute hashes
28 29 30 |
# File 'lib/encoding_dot_com/queue.rb', line 28 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
64 65 66 |
# File 'lib/encoding_dot_com/queue.rb', line 64 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
52 53 54 55 56 |
# File 'lib/encoding_dot_com/queue.rb', line 52 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.
88 89 90 91 |
# File 'lib/encoding_dot_com/queue.rb', line 88 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
59 60 61 |
# File 'lib/encoding_dot_com/queue.rb', line 59 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
69 70 71 |
# File 'lib/encoding_dot_com/queue.rb', line 69 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
45 46 47 48 |
# File 'lib/encoding_dot_com/queue.rb', line 45 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
79 80 81 82 83 84 |
# File 'lib/encoding_dot_com/queue.rb', line 79 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 |