Ziggeo 2.15 → 2.21
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.
- checksums.yaml +5 -5
- data/README.md +652 -572
- data/lib/Ziggeo.rb +31 -46
- data/lib/classes/ZiggeoConfig.rb +5 -1
- data/lib/classes/ZiggeoConnect.rb +50 -20
- data/lib/classes/ZiggeoEffectProfileProcess.rb +17 -1
- data/lib/classes/ZiggeoStreams.rb +25 -3
- data/lib/classes/ZiggeoVideos.rb +7 -1
- metadata +5 -20
data/lib/Ziggeo.rb
CHANGED
|
@@ -19,7 +19,7 @@ require_relative "classes/ZiggeoAnalytics"
|
|
|
19
19
|
|
|
20
20
|
class Ziggeo
|
|
21
21
|
|
|
22
|
-
attr_accessor :token, :private_key, :encryption_key, :config, :connect, :api_connect
|
|
22
|
+
attr_accessor :token, :private_key, :encryption_key, :config, :connect, :api_connect, :cdn_connect
|
|
23
23
|
|
|
24
24
|
def initialize(token = nil, private_key = nil, encryption_key = nil)
|
|
25
25
|
@token = token
|
|
@@ -42,6 +42,14 @@ class Ziggeo
|
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
@api_connect = ZiggeoConnect.new(self, api_url)
|
|
45
|
+
cdn_url = @config.cdn_url
|
|
46
|
+
cdn_regions = @config.cdn_regions
|
|
47
|
+
cdn_regions.each do |key, value|
|
|
48
|
+
if (@token.start_with?(key))
|
|
49
|
+
cdn_url = value
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
@cdn_connect = ZiggeoConnect.new(self, cdn_url)
|
|
45
53
|
@auth = nil
|
|
46
54
|
@videos = nil
|
|
47
55
|
@streams = nil
|
|
@@ -64,70 +72,47 @@ class Ziggeo
|
|
|
64
72
|
end
|
|
65
73
|
|
|
66
74
|
def auth()
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
end
|
|
70
|
-
return @auth end
|
|
75
|
+
return @auth || ZiggeoAuth.new(self)
|
|
76
|
+
end
|
|
71
77
|
|
|
72
78
|
def videos()
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
end
|
|
76
|
-
return @videos end
|
|
79
|
+
return @videos || ZiggeoVideos.new(self)
|
|
80
|
+
end
|
|
77
81
|
|
|
78
82
|
def streams()
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
end
|
|
82
|
-
return @streams end
|
|
83
|
+
return @streams || ZiggeoStreams.new(self)
|
|
84
|
+
end
|
|
83
85
|
|
|
84
86
|
def authtokens()
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
end
|
|
88
|
-
return @authtokens end
|
|
87
|
+
return @authtokens || ZiggeoAuthtokens.new(self)
|
|
88
|
+
end
|
|
89
89
|
|
|
90
90
|
def application()
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
end
|
|
94
|
-
return @application end
|
|
91
|
+
return @application || ZiggeoApplication.new(self)
|
|
92
|
+
end
|
|
95
93
|
|
|
96
94
|
def effectProfiles()
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
end
|
|
100
|
-
return @effectProfiles end
|
|
95
|
+
return @effectProfiles || ZiggeoEffectProfiles.new(self)
|
|
96
|
+
end
|
|
101
97
|
|
|
102
98
|
def effectProfileProcess()
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
end
|
|
106
|
-
return @effectProfileProcess end
|
|
99
|
+
return @effectProfileProcess || ZiggeoEffectProfileProcess.new(self)
|
|
100
|
+
end
|
|
107
101
|
|
|
108
102
|
def metaProfiles()
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
end
|
|
112
|
-
return @metaProfiles end
|
|
103
|
+
return @metaProfiles || ZiggeoMetaProfiles.new(self)
|
|
104
|
+
end
|
|
113
105
|
|
|
114
106
|
def metaProfileProcess()
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
end
|
|
118
|
-
return @metaProfileProcess end
|
|
107
|
+
return @metaProfileProcess || ZiggeoMetaProfileProcess.new(self)
|
|
108
|
+
end
|
|
119
109
|
|
|
120
110
|
def webhooks()
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
end
|
|
124
|
-
return @webhooks end
|
|
111
|
+
return @webhooks || ZiggeoWebhooks.new(self)
|
|
112
|
+
end
|
|
125
113
|
|
|
126
114
|
def analytics()
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
end
|
|
130
|
-
return @analytics end
|
|
131
|
-
|
|
115
|
+
return @analytics || ZiggeoAnalytics.new(self)
|
|
116
|
+
end
|
|
132
117
|
|
|
133
118
|
end
|
data/lib/classes/ZiggeoConfig.rb
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
|
|
2
2
|
class ZiggeoConfig
|
|
3
|
-
attr_accessor :server_api_url, :api_url, :
|
|
3
|
+
attr_accessor :request_timeout, :request_timeout_per_mb, :server_api_url, :api_url, :cdn_url, :regions, :api_regions, :cdn_regions, :resilience_factor, :resilience_on_fail
|
|
4
4
|
|
|
5
5
|
def initialize()
|
|
6
6
|
@request_timeout = 30 # seconds
|
|
7
7
|
@request_timeout_per_mb = 20 # seconds per MB of uploaded file
|
|
8
8
|
@server_api_url = "https://srvapi.ziggeo.com"
|
|
9
9
|
@api_url = "https://api-us-east-1.ziggeo.com"
|
|
10
|
+
@cdn_url = "https://video-cdn.ziggeo.com"
|
|
10
11
|
@regions = {"r1" => "https://srvapi-eu-west-1.ziggeo.com", }
|
|
11
12
|
@api_regions = {"r1" => "https://api-eu-west-1.ziggeo.com", }
|
|
13
|
+
@cdn_regions = {"r1" => "https://video-cdn-eu-west-1.ziggeo.com", }
|
|
14
|
+
@resilience_factor = 5
|
|
15
|
+
@resilience_on_fail = {"error" => "Too many failed attempts"}
|
|
12
16
|
end
|
|
13
17
|
end
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require 'net/http'
|
|
2
2
|
require 'json'
|
|
3
3
|
require 'httparty'
|
|
4
|
-
require 'httmultiparty'
|
|
5
4
|
|
|
6
5
|
class ZiggeoConnect
|
|
7
6
|
def initialize(application, baseuri)
|
|
@@ -9,7 +8,7 @@ class ZiggeoConnect
|
|
|
9
8
|
@baseuri = baseuri
|
|
10
9
|
end
|
|
11
10
|
|
|
12
|
-
def
|
|
11
|
+
def singleRequest(method, path, data = nil, file = nil)
|
|
13
12
|
url = URI.parse(@baseuri + path)
|
|
14
13
|
auth = { username: @application.token, password: @application.private_key }
|
|
15
14
|
timeout_in_seconds = @application.config.request_timeout.to_i
|
|
@@ -17,33 +16,37 @@ class ZiggeoConnect
|
|
|
17
16
|
method.downcase!
|
|
18
17
|
allowed_methods = %w(get post delete)
|
|
19
18
|
return unless allowed_methods.include?(method)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
rescue Net::ReadTimeout => error
|
|
31
|
-
self.timeout_error_message timeout_in_seconds, error
|
|
32
|
-
end
|
|
19
|
+
unless (file.nil?)
|
|
20
|
+
data = data || {}
|
|
21
|
+
data["file"] = File.new(file)
|
|
22
|
+
timeout_in_seconds = ( ( File.size(file).to_f / 2**20 ).ceil * @application.config.request_timeout_per_mb.to_i ).to_i;
|
|
23
|
+
end
|
|
24
|
+
if (method == "get")
|
|
25
|
+
begin
|
|
26
|
+
HTTParty.send(method, url.to_s, query: data, basic_auth: auth, timeout: timeout_in_seconds)
|
|
27
|
+
rescue Net::ReadTimeout => error
|
|
28
|
+
self.timeout_error_message timeout_in_seconds, error
|
|
33
29
|
end
|
|
34
30
|
else
|
|
35
|
-
data = data.nil? ? {} : data;
|
|
36
|
-
data["file"] = File.new(file)
|
|
37
|
-
timeout_in_seconds = ( ( File.size(file).to_f / 2**20 ).round(0) * @application.config.request_timeout_per_mb.to_i ).to_i;
|
|
38
|
-
|
|
39
31
|
begin
|
|
40
|
-
|
|
32
|
+
HTTParty.send(method, url.to_s, body: data, basic_auth: auth, timeout: timeout_in_seconds)
|
|
41
33
|
rescue Net::ReadTimeout => error
|
|
42
34
|
self.timeout_error_message timeout_in_seconds, error
|
|
43
35
|
end
|
|
44
36
|
end
|
|
45
37
|
end
|
|
46
38
|
|
|
39
|
+
def request(method, path, data = nil, file = nil)
|
|
40
|
+
res = nil
|
|
41
|
+
@application.config.resilience_factor.times do
|
|
42
|
+
res = self.singleRequest(method, path, data, file)
|
|
43
|
+
if res.response.code.to_i >= 200 && res.response.code.to_i < 500
|
|
44
|
+
return res.body
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
return @application.config.resilience_on_fail.to_json
|
|
48
|
+
end
|
|
49
|
+
|
|
47
50
|
def requestJSON(method, path, data = nil, file = nil)
|
|
48
51
|
return JSON.parse(self.request(method, path, data, file))
|
|
49
52
|
end
|
|
@@ -72,6 +75,33 @@ class ZiggeoConnect
|
|
|
72
75
|
return self.requestJSON("DELETE", path, data, file)
|
|
73
76
|
end
|
|
74
77
|
|
|
78
|
+
def uploadFile(url, file, data)
|
|
79
|
+
res = nil
|
|
80
|
+
data["file"] = File.new(file)
|
|
81
|
+
timeout_in_seconds = ( ( File.size(file).to_f / 2**20 ).ceil * @application.config.request_timeout_per_mb.to_i ).to_i;
|
|
82
|
+
begin
|
|
83
|
+
@application.config.resilience_factor.times do
|
|
84
|
+
res = HTTParty.send("post", url.to_s, body: data, timeout: timeout_in_seconds)
|
|
85
|
+
if res.response.code.to_i >= 200 && res.response.code.to_i < 300
|
|
86
|
+
return
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
raise Exception.new res.response
|
|
90
|
+
rescue Net::ReadTimeout => error
|
|
91
|
+
self.timeout_error_message timeout_in_seconds, error
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def postUploadJSON(path, scope, data = nil, file = nil, type_key = nil)
|
|
96
|
+
data = data || {}
|
|
97
|
+
if type_key && (file.is_a? String)
|
|
98
|
+
data[type_key] = File.extname(file)
|
|
99
|
+
end
|
|
100
|
+
result = self.postJSON(path, data)
|
|
101
|
+
self.uploadFile(result["url_data"]["url"], file, result["url_data"]["fields"])
|
|
102
|
+
return result[scope]
|
|
103
|
+
end
|
|
104
|
+
|
|
75
105
|
protected
|
|
76
106
|
|
|
77
107
|
def timeout_error_message( timeout_in_seconds, error )
|
|
@@ -21,7 +21,23 @@ class ZiggeoEffectProfileProcess
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def create_watermark_process(effect_token_or_key, data = nil, file = nil)
|
|
24
|
-
|
|
24
|
+
unless file.nil?
|
|
25
|
+
result = @application.connect.postUploadJSON('/v1/effects/' + effect_token_or_key + '/process/watermark-upload-url', 'effect_process', data, file)
|
|
26
|
+
result = @application.connect.postJSON('/v1/effects/' + effect_token_or_key + '/process/' + result["token"] + '/confirm-watermark');
|
|
27
|
+
return result
|
|
28
|
+
else
|
|
29
|
+
return @application.connect.postJSON('/v1/effects/' + effect_token_or_key + '/process/watermark', data, file)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def edit_watermark_process(effect_token_or_key, token_or_key, data = nil, file = nil)
|
|
34
|
+
unless file.nil?
|
|
35
|
+
result = @application.connect.postUploadJSON('/v1/effects/' + effect_token_or_key + '/process/' + token_or_key + '/watermark-upload-url', 'effect_process', data, file)
|
|
36
|
+
result = @application.connect.postJSON('/v1/effects/' + effect_token_or_key + '/process/' + token_or_key + '/confirm-watermark');
|
|
37
|
+
return result
|
|
38
|
+
else
|
|
39
|
+
return @application.connect.postJSON('/v1/effects/' + effect_token_or_key + '/process/watermark/' + token_or_key + '', data, file)
|
|
40
|
+
end
|
|
25
41
|
end
|
|
26
42
|
|
|
27
43
|
end
|
|
@@ -29,15 +29,37 @@ class ZiggeoStreams
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def create(video_token_or_key, data = nil, file = nil)
|
|
32
|
-
|
|
32
|
+
unless file.nil?
|
|
33
|
+
result = @application.connect.postUploadJSON('/v1/videos/' + video_token_or_key + '/streams-upload-url', 'stream', data, file, 'video_type')
|
|
34
|
+
result = @application.connect.postJSON('/v1/videos/' + video_token_or_key + '/streams/' + result["token"] + '/confirm-video');
|
|
35
|
+
return result
|
|
36
|
+
else
|
|
37
|
+
return @application.connect.postJSON('/v1/videos/' + video_token_or_key + '/streams', data, file)
|
|
38
|
+
end
|
|
33
39
|
end
|
|
34
40
|
|
|
35
41
|
def attach_image(video_token_or_key, token_or_key, data = nil, file = nil)
|
|
36
|
-
|
|
42
|
+
unless file.nil?
|
|
43
|
+
result = @application.connect.postUploadJSON('/v1/videos/' + video_token_or_key + '/streams/' + token_or_key + '/image-upload-url', 'stream', data, file)
|
|
44
|
+
result = @application.connect.postJSON('/v1/videos/' + video_token_or_key + '/streams/' + token_or_key + '/confirm-image');
|
|
45
|
+
return result
|
|
46
|
+
else
|
|
47
|
+
return @application.connect.postJSON('/v1/videos/' + video_token_or_key + '/streams/' + token_or_key + '/image', data, file)
|
|
48
|
+
end
|
|
37
49
|
end
|
|
38
50
|
|
|
39
51
|
def attach_video(video_token_or_key, token_or_key, data = nil, file = nil)
|
|
40
|
-
|
|
52
|
+
unless file.nil?
|
|
53
|
+
result = @application.connect.postUploadJSON('/v1/videos/' + video_token_or_key + '/streams/' + token_or_key + '/video-upload-url', 'stream', data, file, 'video_type')
|
|
54
|
+
result = @application.connect.postJSON('/v1/videos/' + video_token_or_key + '/streams/' + token_or_key + '/confirm-video');
|
|
55
|
+
return result
|
|
56
|
+
else
|
|
57
|
+
return @application.connect.postJSON('/v1/videos/' + video_token_or_key + '/streams/' + token_or_key + '/video', data, file)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def attach_subtitle(video_token_or_key, token_or_key, data = nil)
|
|
62
|
+
return @application.connect.postJSON('/v1/videos/' + video_token_or_key + '/streams/' + token_or_key + '/subtitle', data)
|
|
41
63
|
end
|
|
42
64
|
|
|
43
65
|
def bind(video_token_or_key, token_or_key)
|
data/lib/classes/ZiggeoVideos.rb
CHANGED
|
@@ -61,7 +61,13 @@ class ZiggeoVideos
|
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
def create(data = nil, file = nil)
|
|
64
|
-
|
|
64
|
+
unless file.nil?
|
|
65
|
+
result = @application.connect.postUploadJSON('/v1/videos-upload-url', 'video', data, file, 'video_type')
|
|
66
|
+
result["default_stream"] = @application.connect.postJSON('/v1/videos/' + result["token"] + '/streams/' + result["default_stream"]["token"] + '/confirm-video');
|
|
67
|
+
return result
|
|
68
|
+
else
|
|
69
|
+
return @application.connect.postJSON('/v1/videos/', data, file)
|
|
70
|
+
end
|
|
65
71
|
end
|
|
66
72
|
|
|
67
73
|
def analytics(token_or_key, data = nil)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: Ziggeo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '2.
|
|
4
|
+
version: '2.21'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ziggeo, Inc
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-10-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: httparty
|
|
@@ -16,28 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.
|
|
19
|
+
version: '0.16'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: httmultiparty
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - ">="
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0'
|
|
34
|
-
type: :runtime
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - ">="
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '0'
|
|
26
|
+
version: '0.16'
|
|
41
27
|
description: The Ziggeo Ruby and Rails Server SDK.
|
|
42
28
|
email:
|
|
43
29
|
- support@ziggeo.com
|
|
@@ -79,8 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
79
65
|
- !ruby/object:Gem::Version
|
|
80
66
|
version: '0'
|
|
81
67
|
requirements: []
|
|
82
|
-
|
|
83
|
-
rubygems_version: 2.5.2.3
|
|
68
|
+
rubygems_version: 3.0.3
|
|
84
69
|
signing_key:
|
|
85
70
|
specification_version: 4
|
|
86
71
|
summary: The Ziggeo ServerSDK gem.
|