Class: Vidload::Mp4::Api::Downloader
- Inherits:
-
Object
- Object
- Vidload::Mp4::Api::Downloader
- Defined in:
- lib/vidload/mp4/api.rb
Class Method Summary collapse
- .builder ⇒ Object
- .display_with_spinner(loading_msg = 'Loading...') ⇒ Object
- .from_hash(hash) ⇒ Object
Instance Method Summary collapse
- #display_calling_args ⇒ Object
-
#download_video ⇒ Object
main func to be called in your own scripts defined under web/.
-
#initialize(**kwargs) ⇒ Downloader
constructor
A new instance of Downloader.
Constructor Details
#initialize(**kwargs) ⇒ Downloader
Returns a new instance of Downloader.
62 63 64 |
# File 'lib/vidload/mp4/api.rb', line 62 def initialize(**kwargs) @kwargs = kwargs end |
Class Method Details
.builder ⇒ Object
66 67 68 |
# File 'lib/vidload/mp4/api.rb', line 66 def self.builder DownloaderBuilder.new end |
.display_with_spinner(loading_msg = 'Loading...') ⇒ Object
94 95 96 97 98 99 |
# File 'lib/vidload/mp4/api.rb', line 94 def self.display_with_spinner(loading_msg = 'Loading...') spinner = TTY::Spinner.new("[:spinner] #{loading_msg}") spinner.auto_spin yield spinner.success('(done)') end |
.from_hash(hash) ⇒ Object
70 71 72 |
# File 'lib/vidload/mp4/api.rb', line 70 def self.from_hash(hash) builder.with_kwargs(**hash).build end |
Instance Method Details
#display_calling_args ⇒ Object
87 88 89 90 91 92 |
# File 'lib/vidload/mp4/api.rb', line 87 def display_calling_args puts 'Called with:' @kwargs.each do |key, value| puts "\t#{key}=#{value}" end end |
#download_video ⇒ Object
main func to be called in your own scripts defined under web/
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/vidload/mp4/api.rb', line 75 def download_video Playwright.create(playwright_cli_executable_path: @kwargs[:playwright_cli_path]) do |playwright| browser = playwright.chromium.launch(headless: @kwargs[:headless]) page = browser.new_page manage_video_download(page) wait_until_video_downloaded browser.close end end |