limelight_video 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/limelight_video.rb
CHANGED
@@ -14,15 +14,17 @@ class Limelight
|
|
14
14
|
@secret = options.fetch(:secret, ENV['LIMELIGHT_SECRET'])
|
15
15
|
|
16
16
|
@host = 'http://api.videoplatform.limelight.com'
|
17
|
-
@base_url = "/rest/organizations/#{@organization}
|
17
|
+
@base_url = "/rest/organizations/#{@organization}"
|
18
|
+
@base_media_url = "#{@base_url}/media"
|
19
|
+
@base_channels_url = "#{@base_url}/channels"
|
18
20
|
@client = Faraday.new(@host) do |builder|
|
19
|
-
builder.request :
|
21
|
+
builder.request :url_encoded
|
20
22
|
builder.adapter :net_http
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
24
26
|
def media_info(media_id)
|
25
|
-
response = @client.get("#{@
|
27
|
+
response = @client.get("#{@base_media_url}/#{media_id}/properties.json")
|
26
28
|
JSON.parse response.body
|
27
29
|
end
|
28
30
|
|
@@ -64,20 +66,28 @@ class Limelight
|
|
64
66
|
end
|
65
67
|
|
66
68
|
def upload_path
|
67
|
-
generate_encoded_path('post', @
|
69
|
+
generate_encoded_path('post', @base_media_url)
|
70
|
+
end
|
71
|
+
|
72
|
+
def create_channel(name)
|
73
|
+
# http://api.videoplatform.limelight.com/rest/organizations/<org id>/channels.{XML,JSON}
|
74
|
+
path = generate_encoded_path('post', @base_channels_url)
|
75
|
+
response = @client.post(path, title: name)
|
76
|
+
|
77
|
+
JSON.parse response.body
|
68
78
|
end
|
69
79
|
|
70
80
|
def create_metadata(names)
|
71
81
|
# http://api.videoplatform.limelight.com/rest/organizations/<org id>/media/properties/custom/<property name>
|
72
82
|
Array(names).each do |name|
|
73
|
-
path = generate_encoded_path('put', "#{@
|
83
|
+
path = generate_encoded_path('put', "#{@base_media_url}/properties/custom/#{name}")
|
74
84
|
@client.put(path)
|
75
85
|
end
|
76
86
|
end
|
77
87
|
|
78
88
|
def list_metadata
|
79
89
|
# http://api.videoplatform.limelight.com/rest/organizations/<orgid>/media/properties/custom.{XML,JSON}
|
80
|
-
response = @client.get("#{@
|
90
|
+
response = @client.get("#{@base_media_url}/properties/custom.json")
|
81
91
|
metadata = JSON.parse response.body
|
82
92
|
metadata["custom_property_types"].map { |meta| meta["type_name"] }
|
83
93
|
end
|
@@ -85,14 +95,14 @@ class Limelight
|
|
85
95
|
def remove_metadata(names)
|
86
96
|
# http://api.videoplatform.limelight.com/rest/organizations/<org id>/media/properties/custom/<property name>
|
87
97
|
Array(names).each do |name|
|
88
|
-
path = generate_encoded_path('delete', "#{@
|
98
|
+
path = generate_encoded_path('delete', "#{@base_media_url}/properties/custom/#{name}")
|
89
99
|
@client.delete(path)
|
90
100
|
end
|
91
101
|
end
|
92
102
|
|
93
103
|
private
|
94
104
|
|
95
|
-
def generate_encoded_path(method = 'get', path = @
|
105
|
+
def generate_encoded_path(method = 'get', path = @base_media_url)
|
96
106
|
authorized_action
|
97
107
|
|
98
108
|
params = { access_key: @access_key, expires: Time.now.to_i + 300 }
|
@@ -108,7 +118,7 @@ class Limelight
|
|
108
118
|
raise KeyError.new("access_key") if !@access_key
|
109
119
|
end
|
110
120
|
|
111
|
-
def payload(params, method = 'get', path = @
|
121
|
+
def payload(params, method = 'get', path = @base_media_url)
|
112
122
|
[
|
113
123
|
method.downcase, URI.parse(@host).host, path,
|
114
124
|
params.sort.map{ |arr| arr.join('=') }.join('&')
|
data/limelight_video.gemspec
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://api.videoplatform.limelight.com/rest/organizations/889457f434f14057bdcc9a1f39bd9614/channels?access_key=5CIILY3Sw1P%2FqF2VHikRPXMEPdA%3D&expires=1340974510&signature=w71jfoX%2BSfFflZxbsGdpTkK8z9KHDpbPnetmKMWsBj4%3D
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: title=test
|
9
|
+
headers:
|
10
|
+
content-type:
|
11
|
+
- application/x-www-form-urlencoded
|
12
|
+
accept:
|
13
|
+
- "*/*"
|
14
|
+
user-agent:
|
15
|
+
- Ruby
|
16
|
+
connection:
|
17
|
+
- close
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 201
|
21
|
+
message: Created
|
22
|
+
headers:
|
23
|
+
server:
|
24
|
+
- nginx/0.8.54
|
25
|
+
date:
|
26
|
+
- Fri, 29 Jun 2012 12:50:12 GMT
|
27
|
+
content-type:
|
28
|
+
- application/json; charset=utf-8
|
29
|
+
connection:
|
30
|
+
- close
|
31
|
+
cache-control:
|
32
|
+
- no-cache
|
33
|
+
status:
|
34
|
+
- 201 Created
|
35
|
+
x-runtime:
|
36
|
+
- 1650ms
|
37
|
+
content-length:
|
38
|
+
- "393"
|
39
|
+
via:
|
40
|
+
- 1.0 vps-099.iad.llnw.net
|
41
|
+
body:
|
42
|
+
encoding: US-ASCII
|
43
|
+
string: "{\"publish_date\": null, \"email_enabled\": false, \"thumbnail_url\": \"\", \"description\": null, \"embed_enabled\": false, \"title\": \"test\", \"channel_id\": \"49f3caaa940f4ddeb32d0149e9ccb15e\", \"search_inside_enabled\": false, \"rss_enabled\": false, \"create_date\": 1340974212, \"state\": \"NotPublished\", \"itunes_rss_enabled\": false, \"autoplay_enabled\": false, \"update_date\": 1340974212, \"custom_property\": null}"
|
44
|
+
http_version: "1.1"
|
45
|
+
recorded_at: Fri, 29 Jun 2012 12:50:12 GMT
|
46
|
+
recorded_with: VCR 2.1.1
|
@@ -43,4 +43,11 @@ describe Limelight do
|
|
43
43
|
assert media_info["custom_property"], "This media should have a custom property"
|
44
44
|
end
|
45
45
|
end
|
46
|
+
|
47
|
+
it 'should create a channel' do
|
48
|
+
with_a_cassette('create a channel') do
|
49
|
+
channel = @limelight.create_channel('test')
|
50
|
+
assert channel["channel_id"]
|
51
|
+
end
|
52
|
+
end
|
46
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: limelight_video
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- Rakefile
|
105
105
|
- lib/limelight_video.rb
|
106
106
|
- limelight_video.gemspec
|
107
|
+
- test/fixtures/cassettes/create_a_channel.yml
|
107
108
|
- test/fixtures/cassettes/create_and_list_metadata.yml
|
108
109
|
- test/fixtures/cassettes/limelight_upload_io.yml
|
109
110
|
- test/fixtures/cassettes/limelight_upload_media.yml
|
@@ -138,6 +139,7 @@ signing_key:
|
|
138
139
|
specification_version: 3
|
139
140
|
summary: Limelight video client
|
140
141
|
test_files:
|
142
|
+
- test/fixtures/cassettes/create_a_channel.yml
|
141
143
|
- test/fixtures/cassettes/create_and_list_metadata.yml
|
142
144
|
- test/fixtures/cassettes/limelight_upload_io.yml
|
143
145
|
- test/fixtures/cassettes/limelight_upload_media.yml
|