vidload 0.3.3 → 0.4.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 +4 -4
- data/lib/vidload/cli.rb +2 -0
- data/lib/vidload/mp2t/api.rb +13 -6
- data/lib/vidload/mp4/api.rb +10 -5
- data/lib/vidload/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e6a6c2e597c0e649db09f64a00bc131646351ee75e5ced8b03802802e3144e7f
|
|
4
|
+
data.tar.gz: 825c9e372c6387480eb8bf29aeba03c97c68206ae068ff2d3bf9471cb96ab41b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 54182e718b7c6fc260a80d35be61465ee56d5b03d692fcdca24f4e428513387bf1768f083c4a2f4bd4c33b5abd11b947a4df2ab9577252211f9665a293a97db5
|
|
7
|
+
data.tar.gz: e0cd61e5ea71c05553519b9b81612c0ed9ccf6d7f79a022a536671745cdd9f2279b12a93d20e04ca53961f144d52dbc8891abb3bc82dc154d95691802012c538
|
data/lib/vidload/cli.rb
CHANGED
|
@@ -8,6 +8,7 @@ module Vidload
|
|
|
8
8
|
method_option :video_name, type: :string, required: false
|
|
9
9
|
method_option :author_name, type: :string, required: false
|
|
10
10
|
method_option :output_dir, type: :string, required: false
|
|
11
|
+
method_option :non_headless, type: :boolean, default: false
|
|
11
12
|
method_option :hls_url, type: :string, required: true
|
|
12
13
|
method_option :master_playlist_name, type: :string, required: true
|
|
13
14
|
method_option :playwright_cli_path, type: :string, required: true
|
|
@@ -27,6 +28,7 @@ module Vidload
|
|
|
27
28
|
method_option :video_name, type: :string, required: false
|
|
28
29
|
method_option :video_hub_url, type: :string, required: true
|
|
29
30
|
method_option :playwright_cli_path, type: :string, required: true
|
|
31
|
+
method_option :non_headless, type: :boolean, default: false
|
|
30
32
|
def mp4(video_url)
|
|
31
33
|
params = {
|
|
32
34
|
video_url: video_url,
|
data/lib/vidload/mp2t/api.rb
CHANGED
|
@@ -5,6 +5,7 @@ require 'tty-spinner'
|
|
|
5
5
|
require 'open3'
|
|
6
6
|
require 'm3u8'
|
|
7
7
|
require 'io/console'
|
|
8
|
+
require 'fileutils'
|
|
8
9
|
|
|
9
10
|
module Vidload
|
|
10
11
|
module Mp2t
|
|
@@ -45,6 +46,16 @@ module Vidload
|
|
|
45
46
|
self
|
|
46
47
|
end
|
|
47
48
|
|
|
49
|
+
def with_output_dir(output_dir)
|
|
50
|
+
@kwargs[:output_dir] = output_dir
|
|
51
|
+
self
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def non_headless?(non_headless)
|
|
55
|
+
@kwargs[:non_headless] = non_headless
|
|
56
|
+
self
|
|
57
|
+
end
|
|
58
|
+
|
|
48
59
|
def with_hls_url(hls_url)
|
|
49
60
|
@kwargs[:hls_url] = hls_url
|
|
50
61
|
self
|
|
@@ -75,11 +86,6 @@ module Vidload
|
|
|
75
86
|
self
|
|
76
87
|
end
|
|
77
88
|
|
|
78
|
-
def with_output_dir(output_dir)
|
|
79
|
-
@kwargs[:output_dir] = output_dir
|
|
80
|
-
self
|
|
81
|
-
end
|
|
82
|
-
|
|
83
89
|
def build
|
|
84
90
|
REQUIRED_ARGS.each do |required_arg|
|
|
85
91
|
raise ArgumentError, "#{required_arg} must be provided" unless @kwargs[required_arg]
|
|
@@ -109,7 +115,7 @@ module Vidload
|
|
|
109
115
|
# main func to be called in your own scripts defined under web/
|
|
110
116
|
def download_video(video_starter_callbacks: [])
|
|
111
117
|
Playwright.create(playwright_cli_executable_path: @kwargs[:playwright_cli_path]) do |playwright|
|
|
112
|
-
browser = playwright.chromium.launch(headless:
|
|
118
|
+
browser = playwright.chromium.launch(headless: !@kwargs[:non_headless])
|
|
113
119
|
page = browser.new_page
|
|
114
120
|
|
|
115
121
|
manage_video_download(page, *video_starter_callbacks)
|
|
@@ -170,6 +176,7 @@ module Vidload
|
|
|
170
176
|
def trigger_video_download(video_url, seg_qty)
|
|
171
177
|
VIDEO_START_DOWNLOAD_EVENT_QUEUE << true
|
|
172
178
|
puts 'Video starts. Starting download...'
|
|
179
|
+
FileUtils.mkdir_p(@kwargs[:output_dir], mode: 0o755)
|
|
173
180
|
run_cmd(DEMUXER_PATH, video_url, "#{@kwargs[:output_dir]}#{@kwargs[:video_name]}",
|
|
174
181
|
@kwargs[:video_referer]) do |line|
|
|
175
182
|
if (line.include?('hls @') || line.include?('https @')) && line.match?(/#{@kwargs[:ts_seg_pattern]}/i)
|
data/lib/vidload/mp4/api.rb
CHANGED
|
@@ -22,13 +22,13 @@ module Vidload
|
|
|
22
22
|
self
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
def
|
|
26
|
-
@kwargs[:
|
|
25
|
+
def with_video_url(video_url)
|
|
26
|
+
@kwargs[:video_url] = video_url
|
|
27
27
|
self
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
def
|
|
31
|
-
@kwargs[:
|
|
30
|
+
def with_video_name(video_name)
|
|
31
|
+
@kwargs[:video_name] = video_name
|
|
32
32
|
self
|
|
33
33
|
end
|
|
34
34
|
|
|
@@ -42,6 +42,11 @@ module Vidload
|
|
|
42
42
|
self
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
def non_headless?(non_headless)
|
|
46
|
+
@kwargs[:non_headless] = non_headless
|
|
47
|
+
self
|
|
48
|
+
end
|
|
49
|
+
|
|
45
50
|
def build
|
|
46
51
|
REQUIRED_ARGS.each do |required_arg|
|
|
47
52
|
raise ArgumentError, "#{required_arg} must be provided" unless @kwargs[required_arg]
|
|
@@ -69,7 +74,7 @@ module Vidload
|
|
|
69
74
|
# main func to be called in your own scripts defined under web/
|
|
70
75
|
def download_video
|
|
71
76
|
Playwright.create(playwright_cli_executable_path: @kwargs[:playwright_cli_path]) do |playwright|
|
|
72
|
-
browser = playwright.chromium.launch
|
|
77
|
+
browser = playwright.chromium.launch(headless: !@kwargs[:non_headless])
|
|
73
78
|
page = browser.new_page
|
|
74
79
|
|
|
75
80
|
manage_video_download(page)
|
data/lib/vidload/version.rb
CHANGED