zencoder 2.1.14 → 2.1.15
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +22 -14
- data/lib/zencoder.rb +9 -0
- data/lib/zencoder/version.rb +1 -1
- data/lib/zencoder/zencoder.rb +6 -2
- metadata +17 -4
data/README.markdown
CHANGED
@@ -16,13 +16,15 @@ Tested on the following versions of Ruby:
|
|
16
16
|
|
17
17
|
## Getting Started
|
18
18
|
|
19
|
-
The first thing you'll need to interact with the Zencoder API is your API key. You can use your API key in one of
|
19
|
+
The first thing you'll need to interact with the Zencoder API is your API key. You can use your API key in one of three ways. The first and easiest is to set it and forget it on the Zencoder module like so:
|
20
20
|
|
21
21
|
Zencoder.api_key = 'abcd1234'
|
22
22
|
|
23
|
-
Alternatively you can
|
23
|
+
Alternatively, you can use an environment variable:
|
24
24
|
|
25
|
-
|
25
|
+
ENV['ZENCODER_API_KEY'] = 'abcd1234'
|
26
|
+
|
27
|
+
You can also pass your API key in every request, but who wants to do that?
|
26
28
|
|
27
29
|
## Responses
|
28
30
|
|
@@ -51,18 +53,9 @@ Or you can specify them as a string, which we'll just pass along as the request
|
|
51
53
|
|
52
54
|
There's more you can do on jobs than anything else in the API. The following methods are available: `list`, `create`, `details`, `progress`, `resubmit`, `cancel`, `delete`.
|
53
55
|
|
54
|
-
### list
|
55
|
-
|
56
|
-
By default the jobs listing is paginated with 50 jobs per page and sorted by ID in descending order. You can pass two parameters to control the paging: `page` and `per_page`.
|
57
|
-
|
58
|
-
Zencoder::Job.list
|
59
|
-
Zencoder::Job.list(:per_page => 10)
|
60
|
-
Zencoder::Job.list(:per_page => 10, :page => 2)
|
61
|
-
Zencoder::Job.list(:per_page => 10, :page => 2, :api_key => 'abcd1234')
|
62
|
-
|
63
56
|
### create
|
64
57
|
|
65
|
-
The hash you pass to the `create` method should be encodable to the [JSON you would pass to the Job creation API call on Zencoder](http://zencoder.com/docs/api/#encoding-job).
|
58
|
+
The hash you pass to the `create` method should be encodable to the [JSON you would pass to the Job creation API call on Zencoder](http://zencoder.com/docs/api/#encoding-job). We'll auto-populate your API key if you've set it already.
|
66
59
|
|
67
60
|
Zencoder::Job.create({:input => 's3://bucket/key.mp4'})
|
68
61
|
Zencoder::Job.create({:input => 's3://bucket/key.mp4',
|
@@ -70,6 +63,21 @@ The hash you pass to the `create` method should be encodable to the [JSON you wo
|
|
70
63
|
:url => 's3://bucket/key_output.webm'}]})
|
71
64
|
Zencoder::Job.create({:input => 's3://bucket/key.mp4', :api_key => 'abcd1234'})
|
72
65
|
|
66
|
+
This returns a Zencoder::Response object. The body includes a Job ID, and one or more Output IDs (one for every output file created).
|
67
|
+
|
68
|
+
response = Zencoder::Job.create({:input => 's3://bucket/key.mp4'})
|
69
|
+
response.code # => 201
|
70
|
+
response.body['id'] # => 12345
|
71
|
+
|
72
|
+
### list
|
73
|
+
|
74
|
+
By default the jobs listing is paginated with 50 jobs per page and sorted by ID in descending order. You can pass two parameters to control the paging: `page` and `per_page`.
|
75
|
+
|
76
|
+
Zencoder::Job.list
|
77
|
+
Zencoder::Job.list(:per_page => 10)
|
78
|
+
Zencoder::Job.list(:per_page => 10, :page => 2)
|
79
|
+
Zencoder::Job.list(:per_page => 10, :page => 2, :api_key => 'abcd1234')
|
80
|
+
|
73
81
|
### details
|
74
82
|
|
75
83
|
The number passed to `details` is the ID of a Zencoder job.
|
@@ -102,7 +110,7 @@ The number passed to `delete` is the ID of a Zencoder job.
|
|
102
110
|
|
103
111
|
### progress
|
104
112
|
|
105
|
-
|
113
|
+
*Important:* the number passed to `progress` is the output file ID, not the Job ID.
|
106
114
|
|
107
115
|
Zencoder::Output.progress(1)
|
108
116
|
Zencoder::Output.progress(1, :api_key => 'abcd1234')
|
data/lib/zencoder.rb
CHANGED
@@ -6,6 +6,15 @@ require 'timeout'
|
|
6
6
|
# Gems
|
7
7
|
require 'active_support' # JSON and XML parsing/encoding
|
8
8
|
|
9
|
+
# ActiveSupport 3.0
|
10
|
+
begin
|
11
|
+
require 'active_support/core_ext/class'
|
12
|
+
require 'active_support/core_ext/hash'
|
13
|
+
require 'active_support/json'
|
14
|
+
require 'active_support/xml'
|
15
|
+
rescue LoadError
|
16
|
+
end
|
17
|
+
|
9
18
|
# Zencoder
|
10
19
|
require 'zencoder/extensions'
|
11
20
|
require 'zencoder/zencoder'
|
data/lib/zencoder/version.rb
CHANGED
data/lib/zencoder/zencoder.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
class Zencoder
|
2
2
|
|
3
3
|
cattr_accessor :base_url
|
4
|
-
|
4
|
+
cattr_writer :api_key
|
5
5
|
|
6
|
-
self.
|
6
|
+
def self.api_key
|
7
|
+
@@api_key || ENV['ZENCODER_API_KEY']
|
8
|
+
end
|
7
9
|
|
10
|
+
self.base_url = 'https://app.zencoder.com/api'
|
11
|
+
|
8
12
|
def self.encode(content, format=nil)
|
9
13
|
if content.is_a?(String)
|
10
14
|
content
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zencoder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 21
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 2
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 2.1.
|
9
|
+
- 15
|
10
|
+
version: 2.1.15
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Nathan Sutton
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-09-10 00:00:00 -07:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: activesupport
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
version: "0"
|
@@ -33,9 +36,11 @@ dependencies:
|
|
33
36
|
name: shoulda
|
34
37
|
prerelease: false
|
35
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
36
40
|
requirements:
|
37
41
|
- - ">="
|
38
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
39
44
|
segments:
|
40
45
|
- 0
|
41
46
|
version: "0"
|
@@ -45,9 +50,11 @@ dependencies:
|
|
45
50
|
name: mocha
|
46
51
|
prerelease: false
|
47
52
|
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
48
54
|
requirements:
|
49
55
|
- - ">="
|
50
56
|
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
51
58
|
segments:
|
52
59
|
- 0
|
53
60
|
version: "0"
|
@@ -57,9 +64,11 @@ dependencies:
|
|
57
64
|
name: webmock
|
58
65
|
prerelease: false
|
59
66
|
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
60
68
|
requirements:
|
61
69
|
- - ">="
|
62
70
|
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
63
72
|
segments:
|
64
73
|
- 0
|
65
74
|
version: "0"
|
@@ -100,23 +109,27 @@ rdoc_options: []
|
|
100
109
|
require_paths:
|
101
110
|
- lib
|
102
111
|
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
103
113
|
requirements:
|
104
114
|
- - ">="
|
105
115
|
- !ruby/object:Gem::Version
|
116
|
+
hash: 3
|
106
117
|
segments:
|
107
118
|
- 0
|
108
119
|
version: "0"
|
109
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
110
122
|
requirements:
|
111
123
|
- - ">="
|
112
124
|
- !ruby/object:Gem::Version
|
125
|
+
hash: 3
|
113
126
|
segments:
|
114
127
|
- 0
|
115
128
|
version: "0"
|
116
129
|
requirements: []
|
117
130
|
|
118
131
|
rubyforge_project: zencoder
|
119
|
-
rubygems_version: 1.3.
|
132
|
+
rubygems_version: 1.3.7
|
120
133
|
signing_key:
|
121
134
|
specification_version: 3
|
122
135
|
summary: Zencoder <http://zencoder.com> integration library.
|