vidload 0.3.2 → 0.3.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a24a8d21e0c6a4d1c29211c2fc730a34d7f27e1629cec415e3014820a7b13a2e
4
- data.tar.gz: 64b502cf0d8b0ddb8f3c7e17246df47c8a04e415b91d67c167a941f8bcf98cc8
3
+ metadata.gz: 7181701b014459237b2d54b48fa246a4218c002e8caf2bce4f36f7d2d4882d26
4
+ data.tar.gz: f16e3bd0e7dfcb008a7c1cab1a14345c44e6e7b1ab0d202660cba1d19161adb0
5
5
  SHA512:
6
- metadata.gz: 04e6bef3507ec3580f0ed69ddf427d9b6d9405ea7e46ddf35149e6babde4ee2f680670145bba4179282938dbc199e62bdd5124b3e2a06de5824025525c5d9a22
7
- data.tar.gz: 36613f4b862a7adeccf1b5581049e40e9f7e0f3cc3e9602d3e0c919e6f39178784989f636f285949facbc731b5d333d0ecef56eea13f2f5cc807b1d6efd19a12
6
+ metadata.gz: 67470011b4518c594f4ea3c899a48ab0d5aa7104d64584a533df42ffa531d32d996e9962444fe1f09c637fd613cbf1762c8acee8494b16df4c1131b44789ff57
7
+ data.tar.gz: fe9f12aeed6f937fc58225874dd037c50d2421f0cc2256f78be48d2efc57ee9f294133c8252a2e7ab510e4d33960d6940ed94c1c50dc40b096464d8dd6e331a9
@@ -9,8 +9,9 @@ require 'io/console'
9
9
  module Vidload
10
10
  module Mp2t
11
11
  module Api
12
- DEMUXER_PATH = "#{__dir__}/remuxer.sh"
12
+ DEMUXER_PATH = "#{__dir__}/remuxer.sh".freeze
13
13
  VIDEO_DOWNLOADED_EVENT_QUEUE = Queue.new
14
+ VIDEO_START_DOWNLOAD_EVENT_QUEUE = Queue.new
14
15
  VIDEO_INDEX_EVENT_QUEUE = Queue.new
15
16
  ANSI_BOLD_WHITE = "\033[1;97m"
16
17
  ANSI_LIGHT_GREY = "\033[37m"
@@ -108,13 +109,19 @@ module Vidload
108
109
  # main func to be called in your own scripts defined under web/
109
110
  def download_video(video_starter_callbacks: [])
110
111
  Playwright.create(playwright_cli_executable_path: @kwargs[:playwright_cli_path]) do |playwright|
111
- browser = playwright.chromium.launch
112
+ browser = playwright.chromium.launch(headless: false)
112
113
  page = browser.new_page
113
114
 
114
115
  manage_video_download(page, *video_starter_callbacks)
115
- wait_until_video_downloaded
116
116
 
117
- browser.close
117
+ if wait_until_video_start_downloading(timeout: 10).nil?
118
+ puts 'Not possible to download video. Restarting new session'
119
+ browser.close
120
+ download_video(video_starter_callbacks: video_starter_callbacks)
121
+ else
122
+ wait_until_video_downloaded
123
+ browser.close
124
+ end
118
125
  end
119
126
  end
120
127
 
@@ -156,7 +163,12 @@ module Vidload
156
163
  VIDEO_DOWNLOADED_EVENT_QUEUE.pop
157
164
  end
158
165
 
166
+ def wait_until_video_start_downloading(timeout:)
167
+ VIDEO_START_DOWNLOAD_EVENT_QUEUE.pop(timeout: timeout)
168
+ end
169
+
159
170
  def trigger_video_download(video_url, seg_qty)
171
+ VIDEO_START_DOWNLOAD_EVENT_QUEUE << true
160
172
  puts 'Video starts. Starting download...'
161
173
  run_cmd(DEMUXER_PATH, video_url, "#{@kwargs[:output_dir]}#{@kwargs[:video_name]}",
162
174
  @kwargs[:video_referer]) do |line|
@@ -209,11 +221,7 @@ module Vidload
209
221
 
210
222
  _rows, cols = IO.console.winsize
211
223
  @lines.each do |line|
212
- if line.length > cols
213
- puts "#{line.slice(0, cols - 3)}..."
214
- else
215
- puts line
216
- end
224
+ line.length > cols ? (puts "#{line.slice(0, cols - 3)}...") : (puts line)
217
225
  end
218
226
  end
219
227
 
@@ -107,9 +107,8 @@ module Vidload
107
107
  end
108
108
 
109
109
  def listen_to_video_starts(_page, response)
110
- unless response.url.start_with?(@kwargs[:video_hub_url]) && response.headers['content-type']&.include?('video/mp4')
111
- return
112
- end
110
+ content_type = response.headers['content-type']
111
+ return unless response.url.start_with?(@kwargs[:video_hub_url]) && content_type&.include?('video/mp4')
113
112
 
114
113
  body = response.text
115
114
  File.open("video-#{@kwargs[:video_name]}.mp4", 'wb') do |f|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vidload
4
- VERSION = '0.3.2'
4
+ VERSION = '0.3.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vidload
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patacode <pata.codegineer@gmail.com>
@@ -119,7 +119,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - ">="
121
121
  - !ruby/object:Gem::Version
122
- version: '0'
122
+ version: '3.3'
123
123
  required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  requirements:
125
125
  - - ">="