vidload 0.5.3 → 0.6.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 +4 -4
- data/lib/vidload/custom/api.rb +114 -0
- data/lib/vidload/custom/cli.rb +33 -0
- data/lib/vidload/custom.rb +8 -0
- data/lib/vidload/mp2t/cli.rb +33 -0
- data/lib/vidload/mp2t.rb +1 -0
- data/lib/vidload/mp4/cli.rb +32 -0
- data/lib/vidload/mp4.rb +1 -0
- data/lib/vidload/version.rb +1 -1
- data/lib/vidload.rb +1 -1
- metadata +23 -4
- data/lib/vidload/cli.rb +0 -52
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bfb4321ae5920e81d81c3309dd6311afc2146df5c91143f1d59ade27a5d53267
|
|
4
|
+
data.tar.gz: ecbd3f8b0003e336d633240715b87f5f9253b2e4cf452da4da0e9b4827a18bf3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '038dd29d23532baae65bdcf587a36599bd12fc74d991c46f9f524c2a8d1615ae1b941e934c4a618e47454d4fff3c1c0748068656f319d798b46633fb2abe4c3f'
|
|
7
|
+
data.tar.gz: 56ae75f98274d050c9ac0e1e16d6649e5587a2ae38fdd3e9163cdc12f73c290979ce877cab80f8316bd76402ef0376a260bfa45e7f5e52d8931bef553d38adde
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'playwright'
|
|
4
|
+
require 'tty-spinner'
|
|
5
|
+
require 'open3'
|
|
6
|
+
require 'io/console'
|
|
7
|
+
|
|
8
|
+
module Vidload
|
|
9
|
+
module Custom
|
|
10
|
+
module Api
|
|
11
|
+
class DownloaderBuilder
|
|
12
|
+
REQUIRED_ARGS = %i[playwright_cli_path].freeze
|
|
13
|
+
|
|
14
|
+
def initialize
|
|
15
|
+
@kwargs = {}
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def with_kwargs(**kwargs)
|
|
19
|
+
@kwargs = kwargs
|
|
20
|
+
self
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def with_service_url(service_url)
|
|
24
|
+
@kwargs[:service_url] = service_url
|
|
25
|
+
self
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def with_video_url(video_url)
|
|
29
|
+
@kwargs[:video_url] = video_url
|
|
30
|
+
self
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def with_title(title)
|
|
34
|
+
@kwargs[:title] = title
|
|
35
|
+
self
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def with_author_name(author_name)
|
|
39
|
+
@kwargs[:author_name] = author_name
|
|
40
|
+
self
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def with_playwright_cli_path(playwright_cli_path)
|
|
44
|
+
@kwargs[:playwright_cli_path] = playwright_cli_path
|
|
45
|
+
self
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def is_headless?(headless)
|
|
49
|
+
@kwargs[:headless] = headless
|
|
50
|
+
self
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def build
|
|
54
|
+
REQUIRED_ARGS.each do |required_arg|
|
|
55
|
+
raise ArgumentError, "#{required_arg} must be provided" unless @kwargs[required_arg]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
Downloader.new(**@kwargs)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
class Downloader
|
|
63
|
+
def initialize(**kwargs)
|
|
64
|
+
@kwargs = kwargs
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def self.builder
|
|
68
|
+
DownloaderBuilder.new
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def self.from_hash(hash)
|
|
72
|
+
builder.with_kwargs(**hash).build
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# main func to be called in your own scripts defined under web/
|
|
76
|
+
def download_video(video_starter_callbacks: [])
|
|
77
|
+
Playwright.create(playwright_cli_executable_path: @kwargs[:playwright_cli_path]) do |playwright|
|
|
78
|
+
browser = playwright.chromium.launch(headless: @kwargs['headless'])
|
|
79
|
+
page = browser.new_page
|
|
80
|
+
|
|
81
|
+
manage_video_download(page, *video_starter_callbacks)
|
|
82
|
+
|
|
83
|
+
browser.close
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def display_calling_args
|
|
88
|
+
puts 'Called with:'
|
|
89
|
+
@kwargs.each do |key, value|
|
|
90
|
+
puts "\t#{key}=#{value}"
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def self.display_with_spinner(loading_msg = 'Loading...')
|
|
95
|
+
spinner = TTY::Spinner.new("[:spinner] #{loading_msg}")
|
|
96
|
+
spinner.auto_spin
|
|
97
|
+
yield
|
|
98
|
+
spinner.success('(done)')
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
private
|
|
102
|
+
|
|
103
|
+
def manage_video_download(page, *video_starter_callbacks)
|
|
104
|
+
video_starter_callbacks.each do |callback|
|
|
105
|
+
res = callback.call(page, @kwargs)
|
|
106
|
+
@kwargs[:title] = res[:title] if !@kwargs[:title] && res[:title]
|
|
107
|
+
@kwargs[:author_name] = res[:author_name] if !@kwargs[:author_name] && res[:author_name]
|
|
108
|
+
@kwargs[:cover_img_url] = res[:cover_img_url] if !@kwargs[:cover_img_url] && res[:cover_img_url]
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'thor'
|
|
4
|
+
|
|
5
|
+
module Vidload
|
|
6
|
+
module Custom
|
|
7
|
+
class Cli < Thor
|
|
8
|
+
desc 'custom VIDEO_URLS...', 'download one ore more mp4 videos'
|
|
9
|
+
method_option :title, type: :string, required: false
|
|
10
|
+
method_option :author_name, type: :string, required: false
|
|
11
|
+
method_option :playwright_cli_path, type: :string, required: true
|
|
12
|
+
method_option :headless, type: :boolean, default: true
|
|
13
|
+
method_option :service_url, type: :string, required: true
|
|
14
|
+
def custom(*video_urls)
|
|
15
|
+
video_urls.each do |video_url|
|
|
16
|
+
params = {
|
|
17
|
+
video_url: video_url,
|
|
18
|
+
**options
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
process_custom(params)
|
|
22
|
+
sleep 1
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def process_custom(params)
|
|
29
|
+
raise NotImplementedError
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'thor'
|
|
4
|
+
|
|
5
|
+
module Vidload
|
|
6
|
+
module Mp2t
|
|
7
|
+
class Cli < Thor
|
|
8
|
+
desc 'mp2t VIDEO_URLS...', 'download one ore more mp2t containerized videos'
|
|
9
|
+
method_option :video_name, type: :string, required: false
|
|
10
|
+
method_option :author_name, type: :string, required: false
|
|
11
|
+
method_option :output_dir, type: :string, required: false
|
|
12
|
+
method_option :headless, type: :boolean, default: true
|
|
13
|
+
method_option :author_dir, type: :boolean, default: false
|
|
14
|
+
method_option :hls_url, type: :string, required: true
|
|
15
|
+
method_option :master_playlist_name, type: :string, required: true
|
|
16
|
+
method_option :playwright_cli_path, type: :string, required: true
|
|
17
|
+
method_option :video_referer, type: :string, required: true
|
|
18
|
+
method_option :ts_seg_pattern, type: :string, required: true
|
|
19
|
+
method_option :hls_index_pattern, type: :string, required: true
|
|
20
|
+
def mp2t(*video_urls)
|
|
21
|
+
video_urls.each do |video_url|
|
|
22
|
+
params = {
|
|
23
|
+
video_url: video_url,
|
|
24
|
+
**options
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
process_mp2t(params)
|
|
28
|
+
sleep 1
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
data/lib/vidload/mp2t.rb
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'thor'
|
|
4
|
+
|
|
5
|
+
module Vidload
|
|
6
|
+
module Mp4
|
|
7
|
+
class Cli < Thor
|
|
8
|
+
desc 'mp4 VIDEO_URLS...', 'download one ore more mp4 videos'
|
|
9
|
+
method_option :video_name, type: :string, required: false
|
|
10
|
+
method_option :video_hub_url, type: :string, required: true
|
|
11
|
+
method_option :playwright_cli_path, type: :string, required: true
|
|
12
|
+
method_option :headless, type: :boolean, default: true
|
|
13
|
+
def mp4(*video_urls)
|
|
14
|
+
video_urls.each do |video_url|
|
|
15
|
+
params = {
|
|
16
|
+
video_url: video_url,
|
|
17
|
+
**options
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
process_mp4(params)
|
|
21
|
+
sleep 1
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def process_mp4(params)
|
|
28
|
+
raise NotImplementedError
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
data/lib/vidload/mp4.rb
CHANGED
data/lib/vidload/version.rb
CHANGED
data/lib/vidload.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vidload
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Patacode <pata.codegineer@gmail.com>
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-03-
|
|
11
|
+
date: 2026-03-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: lucky_case
|
|
@@ -80,6 +80,20 @@ dependencies:
|
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0.9'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: gem-release
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '2.2'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '2.2'
|
|
83
97
|
- !ruby/object:Gem::Dependency
|
|
84
98
|
name: rake
|
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -115,15 +129,20 @@ extensions: []
|
|
|
115
129
|
extra_rdoc_files: []
|
|
116
130
|
files:
|
|
117
131
|
- lib/vidload.rb
|
|
118
|
-
- lib/vidload/
|
|
132
|
+
- lib/vidload/custom.rb
|
|
133
|
+
- lib/vidload/custom/api.rb
|
|
134
|
+
- lib/vidload/custom/cli.rb
|
|
119
135
|
- lib/vidload/mp2t.rb
|
|
120
136
|
- lib/vidload/mp2t/api.rb
|
|
137
|
+
- lib/vidload/mp2t/cli.rb
|
|
121
138
|
- lib/vidload/mp2t/remuxer.sh
|
|
122
139
|
- lib/vidload/mp4.rb
|
|
123
140
|
- lib/vidload/mp4/api.rb
|
|
141
|
+
- lib/vidload/mp4/cli.rb
|
|
124
142
|
- lib/vidload/version.rb
|
|
125
143
|
homepage:
|
|
126
|
-
licenses:
|
|
144
|
+
licenses:
|
|
145
|
+
- MIT
|
|
127
146
|
metadata: {}
|
|
128
147
|
post_install_message:
|
|
129
148
|
rdoc_options: []
|
data/lib/vidload/cli.rb
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'thor'
|
|
4
|
-
|
|
5
|
-
module Vidload
|
|
6
|
-
class Cli < Thor
|
|
7
|
-
desc 'mp2t VIDEO_URL', 'download a mp2t containerized video'
|
|
8
|
-
method_option :video_name, type: :string, required: false
|
|
9
|
-
method_option :author_name, type: :string, required: false
|
|
10
|
-
method_option :output_dir, type: :string, required: false
|
|
11
|
-
method_option :headless, type: :boolean, default: true
|
|
12
|
-
method_option :author_dir, type: :boolean, default: false
|
|
13
|
-
method_option :hls_url, type: :string, required: true
|
|
14
|
-
method_option :master_playlist_name, type: :string, required: true
|
|
15
|
-
method_option :playwright_cli_path, type: :string, required: true
|
|
16
|
-
method_option :video_referer, type: :string, required: true
|
|
17
|
-
method_option :ts_seg_pattern, type: :string, required: true
|
|
18
|
-
method_option :hls_index_pattern, type: :string, required: true
|
|
19
|
-
def mp2t(video_url)
|
|
20
|
-
params = {
|
|
21
|
-
video_url: video_url,
|
|
22
|
-
**options
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
process_mp2t(params)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
desc 'mp4 VIDEO_URL', 'download a mp4 video'
|
|
29
|
-
method_option :video_name, type: :string, required: false
|
|
30
|
-
method_option :video_hub_url, type: :string, required: true
|
|
31
|
-
method_option :playwright_cli_path, type: :string, required: true
|
|
32
|
-
method_option :headless, type: :boolean, default: true
|
|
33
|
-
def mp4(video_url)
|
|
34
|
-
params = {
|
|
35
|
-
video_url: video_url,
|
|
36
|
-
**options
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
process_mp4(params)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
private
|
|
43
|
-
|
|
44
|
-
def process_mp2t(params)
|
|
45
|
-
raise NotImplementedError
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def process_mp4(params)
|
|
49
|
-
raise NotImplementedError
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|