Class: Vidload::Mp2t::Api::DownloaderBuilder
- Inherits:
-
Object
- Object
- Vidload::Mp2t::Api::DownloaderBuilder
- Defined in:
- lib/vidload/mp2t/api.rb
Constant Summary collapse
- REQUIRED_ARGS =
%i[video_url hls_url master_playlist_name playwright_cli_path video_referer ts_seg_pattern hls_index_pattern].freeze
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize ⇒ DownloaderBuilder
constructor
A new instance of DownloaderBuilder.
- #with_author_name(author_name) ⇒ Object
- #with_hls_index_pattern(hls_index_pattern) ⇒ Object
- #with_hls_url(hls_url) ⇒ Object
- #with_kwargs(**kwargs) ⇒ Object
- #with_master_playlist_name(master_playlist_name) ⇒ Object
- #with_output_dir(output_dir) ⇒ Object
- #with_playwright_cli_path(playwright_cli_path) ⇒ Object
- #with_ts_seg_pattern(ts_seg_pattern) ⇒ Object
- #with_video_name(video_name) ⇒ Object
- #with_video_referer(video_referer) ⇒ Object
- #with_video_url(video_url) ⇒ Object
Constructor Details
#initialize ⇒ DownloaderBuilder
Returns a new instance of DownloaderBuilder.
23 24 25 |
# File 'lib/vidload/mp2t/api.rb', line 23 def initialize @kwargs = {} end |
Instance Method Details
#build ⇒ Object
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/vidload/mp2t/api.rb', line 82 def build REQUIRED_ARGS.each do |required_arg| raise ArgumentError, "#{required_arg} must be provided" unless @kwargs[required_arg] end @kwargs[:output_dir] = './' unless @kwargs[:output_dir] @kwargs[:video_name] = "#{@kwargs[:author_name]}_#{@kwargs[:video_name]}" if @kwargs[:author_name] Downloader.new(**@kwargs) end |
#with_author_name(author_name) ⇒ Object
42 43 44 45 |
# File 'lib/vidload/mp2t/api.rb', line 42 def () @kwargs[:author_name] = self end |
#with_hls_index_pattern(hls_index_pattern) ⇒ Object
72 73 74 75 |
# File 'lib/vidload/mp2t/api.rb', line 72 def with_hls_index_pattern(hls_index_pattern) @kwargs[:hls_index_pattern] = hls_index_pattern self end |
#with_hls_url(hls_url) ⇒ Object
47 48 49 50 |
# File 'lib/vidload/mp2t/api.rb', line 47 def with_hls_url(hls_url) @kwargs[:hls_url] = hls_url self end |
#with_kwargs(**kwargs) ⇒ Object
27 28 29 30 |
# File 'lib/vidload/mp2t/api.rb', line 27 def with_kwargs(**kwargs) @kwargs = kwargs self end |
#with_master_playlist_name(master_playlist_name) ⇒ Object
52 53 54 55 |
# File 'lib/vidload/mp2t/api.rb', line 52 def with_master_playlist_name(master_playlist_name) @kwargs[:master_playlist_name] = master_playlist_name self end |
#with_output_dir(output_dir) ⇒ Object
77 78 79 80 |
# File 'lib/vidload/mp2t/api.rb', line 77 def with_output_dir(output_dir) @kwargs[:output_dir] = output_dir self end |
#with_playwright_cli_path(playwright_cli_path) ⇒ Object
57 58 59 60 |
# File 'lib/vidload/mp2t/api.rb', line 57 def with_playwright_cli_path(playwright_cli_path) @kwargs[:playwright_cli_path] = playwright_cli_path self end |
#with_ts_seg_pattern(ts_seg_pattern) ⇒ Object
67 68 69 70 |
# File 'lib/vidload/mp2t/api.rb', line 67 def with_ts_seg_pattern(ts_seg_pattern) @kwargs[:ts_seg_pattern] = ts_seg_pattern self end |
#with_video_name(video_name) ⇒ Object
37 38 39 40 |
# File 'lib/vidload/mp2t/api.rb', line 37 def with_video_name(video_name) @kwargs[:video_name] = video_name self end |
#with_video_referer(video_referer) ⇒ Object
62 63 64 65 |
# File 'lib/vidload/mp2t/api.rb', line 62 def with_video_referer(video_referer) @kwargs[:video_referer] = video_referer self end |
#with_video_url(video_url) ⇒ Object
32 33 34 35 |
# File 'lib/vidload/mp2t/api.rb', line 32 def with_video_url(video_url) @kwargs[:video_url] = video_url self end |