vidload 0.4.0 → 0.5.0

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: e6a6c2e597c0e649db09f64a00bc131646351ee75e5ced8b03802802e3144e7f
4
- data.tar.gz: 825c9e372c6387480eb8bf29aeba03c97c68206ae068ff2d3bf9471cb96ab41b
3
+ metadata.gz: d991f1940c3b16c4d30982c802a24b21aa1e467fc0e5f3544bacce4b711d8e8a
4
+ data.tar.gz: 303da39859fa070f77c47da10b0d8070e4e8bd0edb525141d7e113d021ea81da
5
5
  SHA512:
6
- metadata.gz: 54182e718b7c6fc260a80d35be61465ee56d5b03d692fcdca24f4e428513387bf1768f083c4a2f4bd4c33b5abd11b947a4df2ab9577252211f9665a293a97db5
7
- data.tar.gz: e0cd61e5ea71c05553519b9b81612c0ed9ccf6d7f79a022a536671745cdd9f2279b12a93d20e04ca53961f144d52dbc8891abb3bc82dc154d95691802012c538
6
+ metadata.gz: 1654b94190934e9d8d771564e33d601c2e823d01a93cc649574f7124617e1bca33c01a0dde97f285268d8e59be42637c7f43d9da41832c446da81d83f5d16bc8
7
+ data.tar.gz: 04fb1174a63b6675e290be8c05448b6db8e0bfc402bbc5e8a42b5840379a4c78c245f3b204f5b8420b3de34cd69b4e37157c1db5382b712c318762c581689246
data/lib/vidload/cli.rb CHANGED
@@ -9,6 +9,7 @@ module Vidload
9
9
  method_option :author_name, type: :string, required: false
10
10
  method_option :output_dir, type: :string, required: false
11
11
  method_option :non_headless, type: :boolean, default: false
12
+ method_option :author_dir, type: :boolean, default: false
12
13
  method_option :hls_url, type: :string, required: true
13
14
  method_option :master_playlist_name, type: :string, required: true
14
15
  method_option :playwright_cli_path, type: :string, required: true
@@ -56,6 +56,11 @@ module Vidload
56
56
  self
57
57
  end
58
58
 
59
+ def author_dir?(author_dir)
60
+ @kwargs[:author_dir] = author_dir
61
+ self
62
+ end
63
+
59
64
  def with_hls_url(hls_url)
60
65
  @kwargs[:hls_url] = hls_url
61
66
  self
@@ -91,7 +96,6 @@ module Vidload
91
96
  raise ArgumentError, "#{required_arg} must be provided" unless @kwargs[required_arg]
92
97
  end
93
98
 
94
- @kwargs[:output_dir] = './' unless @kwargs[:output_dir]
95
99
  @kwargs[:video_name] = "#{@kwargs[:author_name]}_#{@kwargs[:video_name]}" if @kwargs[:author_name]
96
100
 
97
101
  Downloader.new(**@kwargs)
@@ -176,8 +180,19 @@ module Vidload
176
180
  def trigger_video_download(video_url, seg_qty)
177
181
  VIDEO_START_DOWNLOAD_EVENT_QUEUE << true
178
182
  puts 'Video starts. Starting download...'
179
- FileUtils.mkdir_p(@kwargs[:output_dir], mode: 0o755)
180
- run_cmd(DEMUXER_PATH, video_url, "#{@kwargs[:output_dir]}#{@kwargs[:video_name]}",
183
+ video_parent_dirs = if @kwargs[:author_dir]
184
+ if @kwargs[:output_dir]
185
+ "#{@kwargs[:output_dir]}/#{@kwargs[:author_name]}"
186
+ else
187
+ @kwargs[:author_name]
188
+ end
189
+ else
190
+ @kwargs[:output_dir]
191
+ end
192
+
193
+ puts video_parent_dirs
194
+ FileUtils.mkdir_p(video_parent_dirs, mode: 0o755)
195
+ run_cmd(DEMUXER_PATH, video_url, "#{video_parent_dirs}/#{@kwargs[:video_name]}",
181
196
  @kwargs[:video_referer]) do |line|
182
197
  if (line.include?('hls @') || line.include?('https @')) && line.match?(/#{@kwargs[:ts_seg_pattern]}/i)
183
198
  seg_nb = line.match(/#{@kwargs[:ts_seg_pattern]}/i)[:seg_nb]
@@ -186,7 +201,7 @@ module Vidload
186
201
  end
187
202
  end
188
203
  print "\r\e[2K"
189
- puts "✔ Video downloaded successfully! Available in #{@kwargs[:output_dir]}#{@kwargs[:video_name]}.mp4"
204
+ puts "✔ Video downloaded successfully! Available in #{video_parent_dirs}/#{@kwargs[:video_name]}.mp4"
190
205
  VIDEO_DOWNLOADED_EVENT_QUEUE << true
191
206
  end
192
207
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vidload
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
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.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patacode <pata.codegineer@gmail.com>