multi_video_streaming 1.0.0 → 1.0.1.beta

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8eb82448880f2f8cf028c589410cd6d5c61cc7f2f54143ce55595d57367f9321
4
- data.tar.gz: 9dddf0c708085972d920eb9918535a654244b4ea299d39d2e9c8b3ed3dc1d036
3
+ metadata.gz: 0f823ff71e880e3e7efce69dcbdb48456176327e2f0731b9d40d2870d23f0b71
4
+ data.tar.gz: 9807632350465257894274a8818f498d5593b19757ab59db1f063c8fa26ccc6a
5
5
  SHA512:
6
- metadata.gz: 22683688bad4a4e3f83c88d2949f1d180df47276b314d2a60b5f1ba308ecacb0c689cb4387392da8c971a45cbab65dcebe55de12a7c926d9f8f2c8df7e9253d2
7
- data.tar.gz: d74439ec0be81eaa16da7f1038d0af02f19b096b2977760bde5f75869ec0526b987f15d8241830010c4686a798741ce3a96c7b0f676f806a765e4c4b82871034
6
+ metadata.gz: 8e4cd7670fd8b64ccc9f7b1ccb49ae6180cfb966f625b9942075b58dc9e2999b8c7dfbb9d48dc21b32ba1e2256af194e793feeaf29616b6875f48fcad4465412
7
+ data.tar.gz: 104882165a54cd6bc82b918b67b566cc5965cd492fc7f851a1de471283443cf00836d71c99d2f39f379c792020513681694af2f343407270e3d3aea8119fb70b
@@ -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"]&.split(",")
102
+ response["availableResolutions"] = response["availableResolutions"].split(",")
103
103
 
104
104
  files = []
105
- response["availableResolutions"]&.map do |available_resolution|
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,10 +116,6 @@ 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
-
123
119
  return self.response_instance.add_response(
124
120
  platform_name: "bunny",
125
121
  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 = MultiVideoStreaming::Utils::S3.generate_presign_url(method: :get, bucket: bucket, key: video_id)
32
+ url_signed = generate_presign_url(bucket: bucket, key: video_id)
33
33
  data = {
34
34
  "key": response.key,
35
35
  "title": response.key,
@@ -140,6 +140,11 @@ 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
143
148
  end
144
149
  end
145
150
  end
@@ -105,7 +105,7 @@ module MultiVideoStreaming
105
105
 
106
106
  available_resolutions = []
107
107
  files = []
108
- response["files"]&.each do |file|
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,11 +116,6 @@ 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
-
124
119
  return self.response_instance.add_response(
125
120
  platform_name: "vimeo",
126
121
  status: "success",
@@ -3,6 +3,5 @@
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"
7
6
  require "multi_video_streaming/errors/missing_param"
8
7
  require "multi_video_streaming/errors/s3_is_not_valid_to_upload"
@@ -21,10 +21,6 @@ module MultiVideoStreaming
21
21
  def self.not_found(video_id:)
22
22
  "The video with id: #{video_id} does not exist."
23
23
  end
24
-
25
- def self.not_available
26
- "The video was successfully found, but it is currently not available."
27
- end
28
24
  end
29
25
  end
30
26
  end
@@ -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.rb"
4
+ require "multi_video_streaming/helpers/sort_files_array_by_label.rb"
5
+ require "multi_video_streaming/helpers/get_default_error_message.rb"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MultiVideoStreaming
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1.beta"
5
5
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'thread'
4
+ require 'thwait'
3
5
  require "uri"
4
6
  require "net/http"
5
7
  require "openssl"
@@ -14,12 +16,13 @@ require "multi_video_streaming/factories"
14
16
  require "multi_video_streaming/errors"
15
17
  require "multi_video_streaming/response"
16
18
  require "multi_video_streaming/helpers"
17
- require "multi_video_streaming/utils"
18
19
  require "multi_video_streaming/version"
19
20
  require "multi_video_streaming/validators"
20
21
 
21
22
  module MultiVideoStreaming
22
23
  def self.upload(url, *platforms)
24
+ threads = []
25
+
23
26
  MultiVideoStreaming::Validators::PlatformsArrayValidator.validate(platforms_array: platforms)
24
27
  MultiVideoStreaming::Validators::PlatformsHashValidator.validate(platforms_hash: platforms, method: :create, number_of_platforms: platforms.length)
25
28
 
@@ -28,16 +31,19 @@ module MultiVideoStreaming
28
31
  https_service_instance = MultiVideoStreaming::Services::Https.new
29
32
 
30
33
  platforms.each do |platform|
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)
34
+ threads << Thread.new {
35
+ platform_instance = MultiVideoStreaming::Factories::Drive.get_platform_instance(
36
+ platform_name: platform[:platform_name],
37
+ dependency_params: platform[:dependency_params],
38
+ response_instance: response_instance,
39
+ required_fields_validator_instance: required_fields_validator_instance,
40
+ https_service_instance: https_service_instance
41
+ )
42
+ platform_instance.upload_video(url: url)
43
+ }
39
44
  end
40
45
 
46
+ ThreadsWait.all_waits(*threads)
41
47
  response_instance.get_all_response
42
48
  end
43
49
 
@@ -70,6 +76,8 @@ module MultiVideoStreaming
70
76
  end
71
77
 
72
78
  def self.delete(*platforms)
79
+ threads = []
80
+
73
81
  MultiVideoStreaming::Validators::PlatformsArrayValidator.validate(platforms_array: platforms)
74
82
  MultiVideoStreaming::Validators::PlatformsHashValidator.validate(platforms_hash: platforms, method: :get, number_of_platforms: platforms.length)
75
83
 
@@ -78,15 +86,19 @@ module MultiVideoStreaming
78
86
  https_service_instance = MultiVideoStreaming::Services::Https.new
79
87
 
80
88
  platforms.each do |platform|
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
89
+ threads << Thread.new {
90
+ platform_instance = MultiVideoStreaming::Factories::Drive.get_platform_instance(
91
+ platform_name: platform[:platform_name],
92
+ dependency_params: platform[:dependency_params],
93
+ response_instance: response_instance,
94
+ required_fields_validator_instance: required_fields_validator_instance,
95
+ https_service_instance: https_service_instance
96
+ )
97
+ platform_instance.delete_video
98
+ }
89
99
  end
100
+
101
+ ThreadsWait.all_waits(*threads)
90
102
  response_instance.get_all_response
91
103
  end
92
104
  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.0
4
+ version: 1.0.1.beta
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-10-21 00:00:00.000000000 Z
13
+ date: 2022-09-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -83,7 +83,6 @@ 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
87
86
  - lib/multi_video_streaming/errors/missing_param.rb
88
87
  - lib/multi_video_streaming/errors/s3_is_not_valid_to_upload.rb
89
88
  - lib/multi_video_streaming/factories.rb
@@ -100,8 +99,6 @@ files:
100
99
  - lib/multi_video_streaming/response.rb
101
100
  - lib/multi_video_streaming/services.rb
102
101
  - 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
105
102
  - lib/multi_video_streaming/validators.rb
106
103
  - lib/multi_video_streaming/validators/platform_name_validator.rb
107
104
  - lib/multi_video_streaming/validators/platforms_array_validator.rb
@@ -123,9 +120,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
120
  version: '0'
124
121
  required_rubygems_version: !ruby/object:Gem::Requirement
125
122
  requirements:
126
- - - ">="
123
+ - - ">"
127
124
  - !ruby/object:Gem::Version
128
- version: '0'
125
+ version: 1.3.1
129
126
  requirements: []
130
127
  rubygems_version: 3.0.3
131
128
  signing_key:
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module MultiVideoStreaming
4
- module Errors
5
- class InvalidS3MethodName < StandardError
6
- def initialize(method)
7
- super("Method name #{method} is invalid")
8
- end
9
- end
10
- end
11
- end
@@ -1,15 +0,0 @@
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,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "multi_video_streaming/utils/s3/generate_presign_url"