sproutvideo-rb 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +28 -3
- data/example/token_upload.rb +37 -0
- data/lib/sproutvideo.rb +1 -0
- data/lib/sproutvideo/account.rb +13 -0
- data/lib/sproutvideo/version.rb +1 -1
- data/lib/sproutvideo/video.rb +10 -6
- data/spec/sproutvideo/account_spec.rb +31 -0
- data/spec/sproutvideo/video_spec.rb +25 -3
- data/sproutvideo-rb.gemspec +8 -4
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a52cda667a7cfda9579e2246db404d9e0c25dde
|
4
|
+
data.tar.gz: a4050d148fe1f9d8e0abb96f545c7cb25ded780a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf34a568277635123d47ac0a55dc5c1af6fc653485e1aa5c6cc132f83ec6a80ed4eca34d4c9de38c94a7513620b8dde2a042d33b4224be4df76b0a92a9569268
|
7
|
+
data.tar.gz: b99a8a911241add84fc75beb291c3381e1f75aaf51319ee9ab0d2da0b6b0d4ac102899c529a774e760db819b2f6283b0981a77ddcc5e1ee633bc9440e94be4c4
|
data/README.markdown
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#SproutVideo
|
1
|
+
# SproutVideo
|
2
2
|
Use this gem to interact with the [SproutVideo API](http://sproutvideo.com/docs/api.html)
|
3
3
|
|
4
4
|
# Getting Started
|
@@ -103,7 +103,15 @@ Sproutvideo::Video.create('/path/to/video.mp4',
|
|
103
103
|
```ruby
|
104
104
|
Sproutvideo::Video.update('abc123', :title => 'Updated Title')
|
105
105
|
```
|
106
|
-
|
106
|
+
|
107
|
+
##replace
|
108
|
+
The first parameter is the id of the video you wish to replace. The second parameter is the local path to the video file.
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
Sproutvideo::Video.replace('abc123', '/path/to/video.mp4')
|
112
|
+
```
|
113
|
+
|
114
|
+
# Tags
|
107
115
|
To add a tag to a video, make sure to include all of the tags currently associated with the video. For instance if the video already has tags with the ids "abc" and "123" and you want to add a tag with the id "def" do pass "abc", "123" and "def" to the update method.
|
108
116
|
|
109
117
|
```ruby
|
@@ -408,6 +416,23 @@ You can also grab engagement sessions for a video for a specific email address l
|
|
408
416
|
Sproutvideo::Analytics.engagement_sessions('abc123', :vemail => 'test@example.com')
|
409
417
|
```
|
410
418
|
|
419
|
+
# Account
|
420
|
+
The following methods are available: `details`, `update`.
|
421
|
+
|
422
|
+
## details
|
423
|
+
To get information about your account:
|
424
|
+
|
425
|
+
```ruby
|
426
|
+
Sproutvideo::Account.details
|
427
|
+
```
|
428
|
+
|
429
|
+
## update
|
430
|
+
To update account settings:
|
431
|
+
|
432
|
+
```ruby
|
433
|
+
Sproutvideo::Account.update({download_sd: true})
|
434
|
+
```
|
435
|
+
|
411
436
|
# Contributing to sproutvideo-rb
|
412
437
|
|
413
438
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
@@ -420,5 +445,5 @@ Sproutvideo::Analytics.engagement_sessions('abc123', :vemail => 'test@example.co
|
|
420
445
|
|
421
446
|
# Copyright
|
422
447
|
|
423
|
-
Copyright (c)
|
448
|
+
Copyright (c) 2016 SproutVideo. See LICENSE.txt for
|
424
449
|
further details.
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'sproutvideo'
|
3
|
+
|
4
|
+
Sproutvideo.api_key = 'enter_your_api_key_here'
|
5
|
+
|
6
|
+
get '/' do
|
7
|
+
@token = Sproutvideo::UploadToken.create(:return_url => 'http://localhost:4567/upload_complete').body
|
8
|
+
template = <<-eos
|
9
|
+
<!doctype html>
|
10
|
+
<html>
|
11
|
+
<head>
|
12
|
+
<title>Upload Test</title>
|
13
|
+
</head>
|
14
|
+
<body>
|
15
|
+
<form action='https://api.sproutvideo.com/v1/videos' method='post' enctype='multipart/form-data'>
|
16
|
+
<fieldset>
|
17
|
+
<legend>Upload:</legend>
|
18
|
+
Title: <input name='title'><br/>
|
19
|
+
Description: <textarea name='description'></textarea><br/>
|
20
|
+
File: <input name='source_video' type='file'>
|
21
|
+
<input type='hidden' name='token' value='<%= token %>'><br/>
|
22
|
+
<input type='submit' value='Upload'>
|
23
|
+
</fieldset>
|
24
|
+
</form>
|
25
|
+
</body>
|
26
|
+
</html>
|
27
|
+
eos
|
28
|
+
erb template, locals: {token: @token[:token]}
|
29
|
+
end
|
30
|
+
|
31
|
+
get '/upload_complete' do
|
32
|
+
if params[:successful] == 'true'
|
33
|
+
"Upload Successful! Created video: #{params[:video_id]}"
|
34
|
+
else
|
35
|
+
"Upload Failed! Error: #{params[:error_message]}"
|
36
|
+
end
|
37
|
+
end
|
data/lib/sproutvideo.rb
CHANGED
data/lib/sproutvideo/version.rb
CHANGED
data/lib/sproutvideo/video.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
module Sproutvideo
|
2
2
|
class Video < Resource
|
3
|
-
|
3
|
+
|
4
4
|
def self.create(file_path='', options={})
|
5
5
|
upload("/videos", file_path, options)
|
6
6
|
end
|
7
7
|
|
8
|
+
def self.replace(video_id, file_path='')
|
9
|
+
upload("/videos/#{video_id}/replace", file_path)
|
10
|
+
end
|
11
|
+
|
8
12
|
def self.list(options={})
|
9
13
|
params = {
|
10
14
|
:page => options.delete(:page) || 1,
|
@@ -30,13 +34,13 @@ module Sproutvideo
|
|
30
34
|
delete("/videos/#{video_id}", options)
|
31
35
|
end
|
32
36
|
|
33
|
-
def self.signed_embed_code(video_id, security_token, params={}, expires=nil, protocol='http')
|
37
|
+
def self.signed_embed_code(video_id, security_token, params={}, expires=nil, protocol='http')
|
34
38
|
host = 'videos.sproutvideo.com'
|
35
39
|
path = "/embed/#{video_id}/#{security_token}"
|
36
40
|
string_to_sign = "GET\n"
|
37
41
|
string_to_sign << "#{host}\n"
|
38
42
|
string_to_sign << "#{path}\n"
|
39
|
-
|
43
|
+
|
40
44
|
expires = Time.now.to_i + 300 unless expires
|
41
45
|
|
42
46
|
params = params.merge('expires' => expires)
|
@@ -53,10 +57,10 @@ module Sproutvideo
|
|
53
57
|
|
54
58
|
digest = OpenSSL::Digest::Digest.new('sha1')
|
55
59
|
b64_hmac = [OpenSSL::HMAC.digest(digest, Sproutvideo.api_key, string_to_sign)].pack("m").strip
|
56
|
-
signature = CGI.escape(b64_hmac)
|
57
|
-
|
60
|
+
signature = CGI.escape(b64_hmac)
|
61
|
+
|
58
62
|
"#{protocol}://#{host}#{path}?signature=#{signature}#{actual_url_params}"
|
59
63
|
end
|
60
64
|
|
61
65
|
end
|
62
|
-
end
|
66
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
|
2
|
+
describe Sproutvideo::Tag do
|
3
|
+
before(:each) do
|
4
|
+
@api_key = 'abc123'
|
5
|
+
Sproutvideo.api_key = @api_key
|
6
|
+
Sproutvideo.base_url = 'https://api.sproutvideo.com/v1'
|
7
|
+
@msg = mock(:to_s => "{}", :code => 200)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#details" do
|
11
|
+
it "should get the correct url and return a response" do
|
12
|
+
RestClient.should_receive(:get).with(
|
13
|
+
"#{Sproutvideo.base_url}/account",
|
14
|
+
{'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
|
15
|
+
Sproutvideo::Account.details.class.should == Sproutvideo::Response
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#update" do
|
20
|
+
it "should PUT the correct url and return a response" do
|
21
|
+
data = {:download_sd => true}
|
22
|
+
|
23
|
+
RestClient.should_receive(:put).with(
|
24
|
+
"#{Sproutvideo.base_url}/account",
|
25
|
+
MultiJson.encode(data),
|
26
|
+
{'SproutVideo-Api-Key' => @api_key}).and_return(@msg)
|
27
|
+
Sproutvideo::Account.update(data).class.should == Sproutvideo::Response
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -30,13 +30,35 @@ describe Sproutvideo::Video do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
describe "#replace" do
|
34
|
+
it "should POST to the correct url and return a response" do
|
35
|
+
#create temp file
|
36
|
+
File.open("upload_test", "w+") do |f|
|
37
|
+
f.syswrite("upload!")
|
38
|
+
end
|
39
|
+
|
40
|
+
file = File.open('upload_test')
|
41
|
+
|
42
|
+
File.stub!(:open).with('upload_test').and_yield(file)
|
43
|
+
|
44
|
+
RestClient.should_receive(:post).with(
|
45
|
+
"#{Sproutvideo.base_url}/videos/asdf/replace",
|
46
|
+
{:source_video => file},
|
47
|
+
{'SproutVideo-Api-Key' => @api_key, :timeout => 18000}).and_return(@msg)
|
48
|
+
|
49
|
+
Sproutvideo::Video.replace('asdf','upload_test').class.should == Sproutvideo::Response
|
50
|
+
|
51
|
+
FileUtils.rm('upload_test')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
33
55
|
describe "#list" do
|
34
56
|
before(:each) do
|
35
57
|
@url = "#{Sproutvideo.base_url}/videos"
|
36
58
|
end
|
37
59
|
|
38
60
|
it "should GET the correct url and return a response" do
|
39
|
-
|
61
|
+
|
40
62
|
RestClient.should_receive(:get).with(
|
41
63
|
@url,
|
42
64
|
{'SproutVideo-Api-Key' => @api_key, :params => {:page => 1, :per_page => 25}}).and_return(@msg)
|
@@ -149,7 +171,7 @@ describe Sproutvideo::Video do
|
|
149
171
|
string_to_sign = "GET\nvideos.sproutvideo.com\n/embed/1/abc123\n&expires=#{@expires_time}"
|
150
172
|
@signature = CGI::escape([OpenSSL::HMAC.digest(@digest, @api_key, string_to_sign)].pack("m").strip)
|
151
173
|
end
|
152
|
-
|
174
|
+
|
153
175
|
it "should sign the embed code" do
|
154
176
|
Sproutvideo::Video.signed_embed_code(@video_id, @security_token).should == "http://videos.sproutvideo.com/embed/1/abc123?signature=#{@signature}&expires=#{@expires_time}"
|
155
177
|
end
|
@@ -172,4 +194,4 @@ describe Sproutvideo::Video do
|
|
172
194
|
end
|
173
195
|
end
|
174
196
|
|
175
|
-
end
|
197
|
+
end
|
data/sproutvideo-rb.gemspec
CHANGED
@@ -2,14 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: sproutvideo-rb 1.6.0 ruby lib
|
5
6
|
|
6
7
|
Gem::Specification.new do |s|
|
7
8
|
s.name = "sproutvideo-rb"
|
8
|
-
s.version = "1.
|
9
|
+
s.version = "1.6.0"
|
9
10
|
|
10
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
11
13
|
s.authors = ["SproutVideo"]
|
12
|
-
s.date = "
|
14
|
+
s.date = "2016-10-20"
|
13
15
|
s.description = "SproutVideo API Client"
|
14
16
|
s.email = "support@sproutvideo.com"
|
15
17
|
s.extra_rdoc_files = [
|
@@ -22,8 +24,10 @@ Gem::Specification.new do |s|
|
|
22
24
|
"LICENSE.txt",
|
23
25
|
"README.markdown",
|
24
26
|
"Rakefile",
|
27
|
+
"example/token_upload.rb",
|
25
28
|
"lib/sproutvideo.rb",
|
26
29
|
"lib/sproutvideo/access_grant.rb",
|
30
|
+
"lib/sproutvideo/account.rb",
|
27
31
|
"lib/sproutvideo/analytics.rb",
|
28
32
|
"lib/sproutvideo/login.rb",
|
29
33
|
"lib/sproutvideo/playlist.rb",
|
@@ -36,6 +40,7 @@ Gem::Specification.new do |s|
|
|
36
40
|
"lib/sproutvideo/video.rb",
|
37
41
|
"spec/spec_helper.rb",
|
38
42
|
"spec/sproutvideo/access_grant_spec.rb",
|
43
|
+
"spec/sproutvideo/account_spec.rb",
|
39
44
|
"spec/sproutvideo/analytics_spec.rb",
|
40
45
|
"spec/sproutvideo/login_spec.rb",
|
41
46
|
"spec/sproutvideo/playlist_spec.rb",
|
@@ -50,8 +55,7 @@ Gem::Specification.new do |s|
|
|
50
55
|
]
|
51
56
|
s.homepage = "http://github.com/SproutVideo/sproutvideo-rb"
|
52
57
|
s.licenses = ["MIT"]
|
53
|
-
s.
|
54
|
-
s.rubygems_version = "2.0.7"
|
58
|
+
s.rubygems_version = "2.4.2"
|
55
59
|
s.summary = "SproutVideo API Client"
|
56
60
|
|
57
61
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sproutvideo-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SproutVideo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -107,8 +107,10 @@ files:
|
|
107
107
|
- LICENSE.txt
|
108
108
|
- README.markdown
|
109
109
|
- Rakefile
|
110
|
+
- example/token_upload.rb
|
110
111
|
- lib/sproutvideo.rb
|
111
112
|
- lib/sproutvideo/access_grant.rb
|
113
|
+
- lib/sproutvideo/account.rb
|
112
114
|
- lib/sproutvideo/analytics.rb
|
113
115
|
- lib/sproutvideo/login.rb
|
114
116
|
- lib/sproutvideo/playlist.rb
|
@@ -121,6 +123,7 @@ files:
|
|
121
123
|
- lib/sproutvideo/video.rb
|
122
124
|
- spec/spec_helper.rb
|
123
125
|
- spec/sproutvideo/access_grant_spec.rb
|
126
|
+
- spec/sproutvideo/account_spec.rb
|
124
127
|
- spec/sproutvideo/analytics_spec.rb
|
125
128
|
- spec/sproutvideo/login_spec.rb
|
126
129
|
- spec/sproutvideo/playlist_spec.rb
|
@@ -152,8 +155,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
155
|
version: '0'
|
153
156
|
requirements: []
|
154
157
|
rubyforge_project:
|
155
|
-
rubygems_version: 2.
|
158
|
+
rubygems_version: 2.4.2
|
156
159
|
signing_key:
|
157
160
|
specification_version: 4
|
158
161
|
summary: SproutVideo API Client
|
159
162
|
test_files: []
|
163
|
+
has_rdoc:
|