vidload 0.4.0 → 0.5.1

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: 886c9c18b30408aa459ab4e8e96d76e372fbe72f4438aa57c9cdd2b43b6360ee
4
+ data.tar.gz: e86001695c92d38311bf54bf0cc80d81d2bea7a69472bdca60a5f479816b1cc2
5
5
  SHA512:
6
- metadata.gz: 54182e718b7c6fc260a80d35be61465ee56d5b03d692fcdca24f4e428513387bf1768f083c4a2f4bd4c33b5abd11b947a4df2ab9577252211f9665a293a97db5
7
- data.tar.gz: e0cd61e5ea71c05553519b9b81612c0ed9ccf6d7f79a022a536671745cdd9f2279b12a93d20e04ca53961f144d52dbc8891abb3bc82dc154d95691802012c538
6
+ metadata.gz: 1cb6f48253b09248683b2116206004a1178e8bf6784416c368dca01f6530034491c51f9ca8b1237fd40e1e7a63ef55da31db61939f405283cde63ce65a5725c3
7
+ data.tar.gz: '048a4b987dde44897ccfe5c6941074df9a43514b26afd43398d66ccf481ec497f14ceb03222b0c36d9d7426c9fd57a80a2aef09c8c5ba927da7e1ecb059bad86'
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
@@ -6,6 +6,7 @@ require 'open3'
6
6
  require 'm3u8'
7
7
  require 'io/console'
8
8
  require 'fileutils'
9
+ require 'lucky_case'
9
10
 
10
11
  module Vidload
11
12
  module Mp2t
@@ -56,6 +57,11 @@ module Vidload
56
57
  self
57
58
  end
58
59
 
60
+ def author_dir?(author_dir)
61
+ @kwargs[:author_dir] = author_dir
62
+ self
63
+ end
64
+
59
65
  def with_hls_url(hls_url)
60
66
  @kwargs[:hls_url] = hls_url
61
67
  self
@@ -91,7 +97,6 @@ module Vidload
91
97
  raise ArgumentError, "#{required_arg} must be provided" unless @kwargs[required_arg]
92
98
  end
93
99
 
94
- @kwargs[:output_dir] = './' unless @kwargs[:output_dir]
95
100
  @kwargs[:video_name] = "#{@kwargs[:author_name]}_#{@kwargs[:video_name]}" if @kwargs[:author_name]
96
101
 
97
102
  Downloader.new(**@kwargs)
@@ -157,11 +162,14 @@ module Vidload
157
162
  navigate_to_url(@kwargs[:video_url], page)
158
163
  video_starter_callbacks.each do |callback|
159
164
  res = callback.call(page)
160
- @kwargs[:video_name] = res[:video_name] if !@kwargs[:video_name] && res[:video_name]
165
+ @kwargs[:video_name] = !@kwargs[:video_name] && res[:video_name] ? res[:video_name] : 'unknown_name'
161
166
  if !@kwargs[:author_name] && res[:author_name]
162
167
  @kwargs[:author_name] = res[:author_name]
163
168
  @kwargs[:video_name] = "#{@kwargs[:author_name]}_#{@kwargs[:video_name]}"
164
169
  end
170
+
171
+ @kwargs[:video_name] = LuckyCase.dash_case(@kwargs[:video_name].gsub(/[^[:alnum:] ]/, ''))
172
+ @kwargs[:author_name] = LuckyCase.dash_case(@kwargs[:author_name].gsub(/[^[:alnum:] ]/, ''))
165
173
  end
166
174
  end
167
175
 
@@ -176,8 +184,19 @@ module Vidload
176
184
  def trigger_video_download(video_url, seg_qty)
177
185
  VIDEO_START_DOWNLOAD_EVENT_QUEUE << true
178
186
  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]}",
187
+ video_parent_dirs = if @kwargs[:author_dir]
188
+ if @kwargs[:output_dir]
189
+ "#{@kwargs[:output_dir]}/#{@kwargs[:author_name]}"
190
+ else
191
+ @kwargs[:author_name]
192
+ end
193
+ else
194
+ @kwargs[:output_dir]
195
+ end
196
+
197
+ puts video_parent_dirs
198
+ FileUtils.mkdir_p(video_parent_dirs, mode: 0o755)
199
+ run_cmd(DEMUXER_PATH, video_url, "#{video_parent_dirs}/#{@kwargs[:video_name]}",
181
200
  @kwargs[:video_referer]) do |line|
182
201
  if (line.include?('hls @') || line.include?('https @')) && line.match?(/#{@kwargs[:ts_seg_pattern]}/i)
183
202
  seg_nb = line.match(/#{@kwargs[:ts_seg_pattern]}/i)[:seg_nb]
@@ -186,7 +205,7 @@ module Vidload
186
205
  end
187
206
  end
188
207
  print "\r\e[2K"
189
- puts "✔ Video downloaded successfully! Available in #{@kwargs[:output_dir]}#{@kwargs[:video_name]}.mp4"
208
+ puts "✔ Video downloaded successfully! Available in #{video_parent_dirs}/#{@kwargs[:video_name]}.mp4"
190
209
  VIDEO_DOWNLOADED_EVENT_QUEUE << true
191
210
  end
192
211
 
@@ -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.1'
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patacode <pata.codegineer@gmail.com>
@@ -10,6 +10,20 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2026-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lucky_case
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.1'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: m3u8
15
29
  requirement: !ruby/object:Gem::Requirement