multi_video_streaming 1.0.1.beta → 1.0.1.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/multi_video_streaming/drivers/bunny.rb +6 -2
- data/lib/multi_video_streaming/drivers/s3.rb +1 -6
- data/lib/multi_video_streaming/drivers/vimeo.rb +6 -1
- data/lib/multi_video_streaming/errors/invalid_s3_method_name.rb +11 -0
- data/lib/multi_video_streaming/errors.rb +1 -0
- data/lib/multi_video_streaming/helpers/get_default_error_message.rb +4 -0
- data/lib/multi_video_streaming/helpers/title_from_url.rb +1 -1
- data/lib/multi_video_streaming/helpers.rb +3 -3
- data/lib/multi_video_streaming/utils/s3/generate_presign_url.rb +15 -0
- data/lib/multi_video_streaming/utils.rb +3 -0
- data/lib/multi_video_streaming/version.rb +1 -1
- data/lib/multi_video_streaming.rb +17 -29
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30e29e1f3ab221846a0bc705d35bd594381e3e14a2ed5ff714d0eceffc19174a
|
4
|
+
data.tar.gz: 78063df1773595912c56b1177928fa9e54f7c5c62b68a71e81bede7029db9794
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8f04023161c0848bab3b5d28bfb91da84bc31d3b05f72b2a6eb3e6fec3dc6defbd5cb2fe5fd49facdd8add55e8ebb970475ce96af6bddd8b0c4a6687ef77aaa
|
7
|
+
data.tar.gz: 7e0049d7d583813730215e0edf89cb680f134638fb29faa066904fa33d6e72a3386c630ff1c77b9f06a242be9b4e098c5715c3a6f47b328ba2e177819d9da27c
|
@@ -99,10 +99,10 @@ module MultiVideoStreaming
|
|
99
99
|
end
|
100
100
|
|
101
101
|
response["directPlay"] = "https://video.bunnycdn.com/play/#{library_id}/#{video_id}"
|
102
|
-
response["availableResolutions"] = response["availableResolutions"]
|
102
|
+
response["availableResolutions"] = response["availableResolutions"]&.split(",")
|
103
103
|
|
104
104
|
files = []
|
105
|
-
response["availableResolutions"]
|
105
|
+
response["availableResolutions"]&.map do |available_resolution|
|
106
106
|
files <<
|
107
107
|
{
|
108
108
|
file: "https://#{pull_zone}.b-cdn.net/#{response["guid"]}/play_#{available_resolution}.mp4",
|
@@ -116,6 +116,10 @@ module MultiVideoStreaming
|
|
116
116
|
|
117
117
|
response["status"] = STATUS_EQUIVALENT[response["status"].to_s]
|
118
118
|
|
119
|
+
if response["status"] != "available"
|
120
|
+
raise MultiVideoStreaming::Helpers::GetDefaultErrorMessage.not_available
|
121
|
+
end
|
122
|
+
|
119
123
|
return self.response_instance.add_response(
|
120
124
|
platform_name: "bunny",
|
121
125
|
status: "success",
|
@@ -29,7 +29,7 @@ module MultiVideoStreaming
|
|
29
29
|
response = Aws::S3::Resource.new().bucket(bucket).object(video_id)
|
30
30
|
video_url = response.public_url
|
31
31
|
|
32
|
-
url_signed = generate_presign_url(bucket: bucket, key: video_id)
|
32
|
+
url_signed = MultiVideoStreaming::Utils::S3.generate_presign_url(method: :get, bucket: bucket, key: video_id)
|
33
33
|
data = {
|
34
34
|
"key": response.key,
|
35
35
|
"title": response.key,
|
@@ -140,11 +140,6 @@ module MultiVideoStreaming
|
|
140
140
|
Aws.config.update(credentials: credentials, region: region, force_path_style: true)
|
141
141
|
end
|
142
142
|
end
|
143
|
-
|
144
|
-
def generate_presign_url(bucket:, key:)
|
145
|
-
signer = Aws::S3::Presigner.new
|
146
|
-
signer.presigned_url(:get_object, bucket: bucket, key: key, expires_in: 900)
|
147
|
-
end
|
148
143
|
end
|
149
144
|
end
|
150
145
|
end
|
@@ -105,7 +105,7 @@ module MultiVideoStreaming
|
|
105
105
|
|
106
106
|
available_resolutions = []
|
107
107
|
files = []
|
108
|
-
response["files"]
|
108
|
+
response["files"]&.each do |file|
|
109
109
|
if file["rendition"] != "adaptive"
|
110
110
|
available_resolutions << file["rendition"]
|
111
111
|
files << { file: file["link"], label: file["rendition"] }
|
@@ -116,6 +116,11 @@ module MultiVideoStreaming
|
|
116
116
|
response["files"] = files
|
117
117
|
response["available_resolutions"] = available_resolutions
|
118
118
|
response["status"] = STATUS_EQUIVALENT[response["status"]]
|
119
|
+
|
120
|
+
if response["status"] != "available"
|
121
|
+
raise MultiVideoStreaming::Helpers::GetDefaultErrorMessage.not_available
|
122
|
+
end
|
123
|
+
|
119
124
|
return self.response_instance.add_response(
|
120
125
|
platform_name: "vimeo",
|
121
126
|
status: "success",
|
@@ -3,5 +3,6 @@
|
|
3
3
|
require "multi_video_streaming/errors/duplicated_platform_name"
|
4
4
|
require "multi_video_streaming/errors/invalid_platform_name"
|
5
5
|
require "multi_video_streaming/errors/invalid_platforms_param"
|
6
|
+
require "multi_video_streaming/errors/invalid_s3_method_name"
|
6
7
|
require "multi_video_streaming/errors/missing_param"
|
7
8
|
require "multi_video_streaming/errors/s3_is_not_valid_to_upload"
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "multi_video_streaming/helpers/title_from_url
|
4
|
-
require "multi_video_streaming/helpers/sort_files_array_by_label
|
5
|
-
require "multi_video_streaming/helpers/get_default_error_message
|
3
|
+
require "multi_video_streaming/helpers/title_from_url"
|
4
|
+
require "multi_video_streaming/helpers/sort_files_array_by_label"
|
5
|
+
require "multi_video_streaming/helpers/get_default_error_message"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MultiVideoStreaming
|
4
|
+
module Utils
|
5
|
+
module S3
|
6
|
+
def self.generate_presign_url(method:, bucket:, key:)
|
7
|
+
methods = { :get => :get_object, :put => :put_object, :delete => :delete_object }
|
8
|
+
method_to_generate_presign_url = methods[method]
|
9
|
+
raise MultiVideoStreaming::Errors::InvalidS3MethodName.new(method) if method_to_generate_presign_url.nil?
|
10
|
+
signer = Aws::S3::Presigner.new
|
11
|
+
signer.presigned_url(method_to_generate_presign_url, bucket: bucket, key: key, expires_in: 900)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'thread'
|
4
|
-
require 'thwait'
|
5
3
|
require "uri"
|
6
4
|
require "net/http"
|
7
5
|
require "openssl"
|
@@ -16,13 +14,12 @@ require "multi_video_streaming/factories"
|
|
16
14
|
require "multi_video_streaming/errors"
|
17
15
|
require "multi_video_streaming/response"
|
18
16
|
require "multi_video_streaming/helpers"
|
17
|
+
require "multi_video_streaming/utils"
|
19
18
|
require "multi_video_streaming/version"
|
20
19
|
require "multi_video_streaming/validators"
|
21
20
|
|
22
21
|
module MultiVideoStreaming
|
23
22
|
def self.upload(url, *platforms)
|
24
|
-
threads = []
|
25
|
-
|
26
23
|
MultiVideoStreaming::Validators::PlatformsArrayValidator.validate(platforms_array: platforms)
|
27
24
|
MultiVideoStreaming::Validators::PlatformsHashValidator.validate(platforms_hash: platforms, method: :create, number_of_platforms: platforms.length)
|
28
25
|
|
@@ -31,19 +28,16 @@ module MultiVideoStreaming
|
|
31
28
|
https_service_instance = MultiVideoStreaming::Services::Https.new
|
32
29
|
|
33
30
|
platforms.each do |platform|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
platform_instance.upload_video(url: url)
|
43
|
-
}
|
31
|
+
platform_instance = MultiVideoStreaming::Factories::Drive.get_platform_instance(
|
32
|
+
platform_name: platform[:platform_name],
|
33
|
+
dependency_params: platform[:dependency_params],
|
34
|
+
response_instance: response_instance,
|
35
|
+
required_fields_validator_instance: required_fields_validator_instance,
|
36
|
+
https_service_instance: https_service_instance
|
37
|
+
)
|
38
|
+
platform_instance.upload_video(url: url)
|
44
39
|
end
|
45
40
|
|
46
|
-
ThreadsWait.all_waits(*threads)
|
47
41
|
response_instance.get_all_response
|
48
42
|
end
|
49
43
|
|
@@ -76,8 +70,6 @@ module MultiVideoStreaming
|
|
76
70
|
end
|
77
71
|
|
78
72
|
def self.delete(*platforms)
|
79
|
-
threads = []
|
80
|
-
|
81
73
|
MultiVideoStreaming::Validators::PlatformsArrayValidator.validate(platforms_array: platforms)
|
82
74
|
MultiVideoStreaming::Validators::PlatformsHashValidator.validate(platforms_hash: platforms, method: :get, number_of_platforms: platforms.length)
|
83
75
|
|
@@ -86,19 +78,15 @@ module MultiVideoStreaming
|
|
86
78
|
https_service_instance = MultiVideoStreaming::Services::Https.new
|
87
79
|
|
88
80
|
platforms.each do |platform|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
platform_instance.delete_video
|
98
|
-
}
|
81
|
+
platform_instance = MultiVideoStreaming::Factories::Drive.get_platform_instance(
|
82
|
+
platform_name: platform[:platform_name],
|
83
|
+
dependency_params: platform[:dependency_params],
|
84
|
+
response_instance: response_instance,
|
85
|
+
required_fields_validator_instance: required_fields_validator_instance,
|
86
|
+
https_service_instance: https_service_instance
|
87
|
+
)
|
88
|
+
platform_instance.delete_video
|
99
89
|
end
|
100
|
-
|
101
|
-
ThreadsWait.all_waits(*threads)
|
102
90
|
response_instance.get_all_response
|
103
91
|
end
|
104
92
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi_video_streaming
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.1.
|
4
|
+
version: 1.0.1.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henrique Schmeller
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-10-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- lib/multi_video_streaming/errors/duplicated_platform_name.rb
|
84
84
|
- lib/multi_video_streaming/errors/invalid_platform_name.rb
|
85
85
|
- lib/multi_video_streaming/errors/invalid_platforms_param.rb
|
86
|
+
- lib/multi_video_streaming/errors/invalid_s3_method_name.rb
|
86
87
|
- lib/multi_video_streaming/errors/missing_param.rb
|
87
88
|
- lib/multi_video_streaming/errors/s3_is_not_valid_to_upload.rb
|
88
89
|
- lib/multi_video_streaming/factories.rb
|
@@ -99,6 +100,8 @@ files:
|
|
99
100
|
- lib/multi_video_streaming/response.rb
|
100
101
|
- lib/multi_video_streaming/services.rb
|
101
102
|
- lib/multi_video_streaming/services/https.rb
|
103
|
+
- lib/multi_video_streaming/utils.rb
|
104
|
+
- lib/multi_video_streaming/utils/s3/generate_presign_url.rb
|
102
105
|
- lib/multi_video_streaming/validators.rb
|
103
106
|
- lib/multi_video_streaming/validators/platform_name_validator.rb
|
104
107
|
- lib/multi_video_streaming/validators/platforms_array_validator.rb
|