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.



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

def initialize
  @kwargs = {}
end

Instance Method Details

#buildObject



84
85
86
87
88
89
90
91
92
93
# File 'lib/vidload/mp2t/api.rb', line 84

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



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

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

#with_hls_index_pattern(hls_index_pattern) ⇒ Object



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

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

#with_hls_url(hls_url) ⇒ Object



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

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

#with_kwargs(**kwargs) ⇒ Object



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

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

#with_master_playlist_name(master_playlist_name) ⇒ Object



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

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

#with_output_dir(output_dir) ⇒ Object



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

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

#with_playwright_cli_path(playwright_cli_path) ⇒ Object



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

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



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

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

#with_video_name(video_name) ⇒ Object



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

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

#with_video_referer(video_referer) ⇒ Object



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

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

#with_video_url(video_url) ⇒ Object



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

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