Class: Vidload::Mp2t::Api::DownloaderBuilder

Inherits:
Object
  • Object
show all
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

Constructor Details

#initializeDownloaderBuilder

Returns a new instance of DownloaderBuilder.



26
27
28
# File 'lib/vidload/mp2t/api.rb', line 26

def initialize
  @kwargs = {}
end

Instance Method Details

#author_dir?(author_dir) ⇒ Boolean

Returns:

  • (Boolean)


60
61
62
63
# File 'lib/vidload/mp2t/api.rb', line 60

def author_dir?(author_dir)
  @kwargs[:author_dir] = author_dir
  self
end

#buildObject



95
96
97
98
99
100
101
102
103
# File 'lib/vidload/mp2t/api.rb', line 95

def build
  REQUIRED_ARGS.each do |required_arg|
    raise ArgumentError, "#{required_arg} must be provided" unless @kwargs[required_arg]
  end

  @kwargs[:video_name] = "#{@kwargs[:author_name]}_#{@kwargs[:video_name]}" if @kwargs[:author_name]

  Downloader.new(**@kwargs)
end

#is_headless?(headless) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
58
# File 'lib/vidload/mp2t/api.rb', line 55

def is_headless?(headless)
  @kwargs[:headless] = headless
  self
end

#with_author_name(author_name) ⇒ Object



45
46
47
48
# File 'lib/vidload/mp2t/api.rb', line 45

def with_author_name(author_name)
  @kwargs[:author_name] = author_name
  self
end

#with_hls_index_pattern(hls_index_pattern) ⇒ Object



90
91
92
93
# File 'lib/vidload/mp2t/api.rb', line 90

def with_hls_index_pattern(hls_index_pattern)
  @kwargs[:hls_index_pattern] = hls_index_pattern
  self
end

#with_hls_url(hls_url) ⇒ Object



65
66
67
68
# File 'lib/vidload/mp2t/api.rb', line 65

def with_hls_url(hls_url)
  @kwargs[:hls_url] = hls_url
  self
end

#with_kwargs(**kwargs) ⇒ Object



30
31
32
33
# File 'lib/vidload/mp2t/api.rb', line 30

def with_kwargs(**kwargs)
  @kwargs = kwargs
  self
end

#with_master_playlist_name(master_playlist_name) ⇒ Object



70
71
72
73
# File 'lib/vidload/mp2t/api.rb', line 70

def with_master_playlist_name(master_playlist_name)
  @kwargs[:master_playlist_name] = master_playlist_name
  self
end

#with_output_dir(output_dir) ⇒ Object



50
51
52
53
# File 'lib/vidload/mp2t/api.rb', line 50

def with_output_dir(output_dir)
  @kwargs[:output_dir] = output_dir
  self
end

#with_playwright_cli_path(playwright_cli_path) ⇒ Object



75
76
77
78
# File 'lib/vidload/mp2t/api.rb', line 75

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



85
86
87
88
# File 'lib/vidload/mp2t/api.rb', line 85

def with_ts_seg_pattern(ts_seg_pattern)
  @kwargs[:ts_seg_pattern] = ts_seg_pattern
  self
end

#with_video_name(video_name) ⇒ Object



40
41
42
43
# File 'lib/vidload/mp2t/api.rb', line 40

def with_video_name(video_name)
  @kwargs[:video_name] = video_name
  self
end

#with_video_referer(video_referer) ⇒ Object



80
81
82
83
# File 'lib/vidload/mp2t/api.rb', line 80

def with_video_referer(video_referer)
  @kwargs[:video_referer] = video_referer
  self
end

#with_video_url(video_url) ⇒ Object



35
36
37
38
# File 'lib/vidload/mp2t/api.rb', line 35

def with_video_url(video_url)
  @kwargs[:video_url] = video_url
  self
end