eivid 1.1.3 → 1.1.4

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: 44d8733cec02c2d822a758903661c03b348ec6797a8cdcb817ffa4790094aeb1
4
- data.tar.gz: b1c1b3ac06bb695ce76b72db220e18b74db69960f4ce0131d4f00289e3fc5e34
3
+ metadata.gz: 84e784e3dbec889dae0b8fd97deade4b7dfb158845015783c1f3bc4bf7ff1f5f
4
+ data.tar.gz: d804c9c9c80d164bcfcf07046d880f3359e7e1c6f030d038039c43e711689941
5
5
  SHA512:
6
- metadata.gz: a83022e2807549aeaee50017ece932101a8d973a9a4e878b702afb762b5939a45f72479f30f6300cb38e89223f69bb2fc51a7619bc3662f7ea98c3ef6504b980
7
- data.tar.gz: 141aa446b58902cb6c4106b3489abeaad47ac68d492651b112fa9e3463fc38082201d174b38b6161ec8e0807b8b09e51be0c5f71eb9fbfe1aefa7920c4d0f3cb
6
+ metadata.gz: ade10d5df13c9d5bd79ce6c1c0e12a8ac470feca13d0cc7c0611a51d632dd01fb344afe54a4163a0a781238b8c9f63f3ceb6726a71aa17c93160eb4ef76bda75
7
+ data.tar.gz: e6df28555d25e1d259546285924e5fd237383bebfb9ce98b7856c3b2618428ca31245a07b67cc5f37396aa1aefb89cf6c863e232e820aba97bb3104774339586
@@ -2,19 +2,56 @@ module Eivid::Concerns::RequestService::UploadVideo
2
2
  extend ActiveSupport::Concern
3
3
 
4
4
  def upload_video(video_path:)
5
- @file = File.open(video_path)
6
- @request = HTTParty.post Eivid::RequestService::VIDEOS_URL, **upload_params
7
- @response = JSON.parse(@request).deep_symbolize_keys
8
- @upload_link = @response.dig(:upload, :upload_link)
9
-
5
+ @file = File.open(video_path)
6
+ retrieve_upload_link
10
7
  tus_upload_to_vimeo
11
8
  @response
12
9
  end
13
10
 
14
11
  private
15
12
 
13
+ def retrieve_upload_link
14
+ efforts = 0
15
+ max_efforts = 180
16
+ sleep_time = 1
17
+
18
+ while @upload_link.blank? && efforts < max_efforts do
19
+
20
+ puts "Trying to retrieve upload link from Vimeo... try #{efforts}/#{max_efforts} with #{sleep_time} seconds sleep in between..."
21
+
22
+ @request = HTTParty.post Eivid::RequestService::VIDEOS_URL, **upload_params
23
+ @response = JSON.parse(@request).deep_symbolize_keys
24
+ @upload_link = @response.dig(:upload, :upload_link)
25
+
26
+ if @upload_link.blank?
27
+ sleep sleep_time
28
+ efforts += 1
29
+
30
+ else
31
+ puts "successfully retrieved the Vimeo upload link!"
32
+ end
33
+ end
34
+ end
35
+
16
36
  def tus_upload_to_vimeo
17
- HTTParty.patch @upload_link, body: @file.read, headers: tus_headers
37
+ efforts = 0
38
+ max_efforts = 10
39
+ sleep_time = 30
40
+ successful = false
41
+
42
+ while !successful && efforts < max_efforts
43
+
44
+ puts "Trying to upload the video to Vimeo... try #{efforts}/#{max_efforts} with #{sleep_time} seconds sleep in between..."
45
+ response = HTTParty.patch @upload_link, body: @file.read, headers: tus_headers
46
+
47
+ if response.code >= 500
48
+ sleep sleep_time
49
+ efforts += 1
50
+ else
51
+ successful = true
52
+ puts "successfully uploaded the video to Vimeo!"
53
+ end
54
+ end
18
55
  end
19
56
 
20
57
  def upload_params
@@ -28,4 +65,4 @@ module Eivid::Concerns::RequestService::UploadVideo
28
65
  { body: body.to_json, headers: default_headers }
29
66
  end
30
67
 
31
- end
68
+ end
data/lib/eivid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eivid
2
- VERSION = '1.1.3'
2
+ VERSION = '1.1.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eivid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jurriaan Schrofer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-01 00:00:00.000000000 Z
11
+ date: 2022-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
145
  requirements: []
146
- rubygems_version: 3.0.9
146
+ rubygems_version: 3.2.22
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: Eivid because we can.