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.
57 58 59 |
# File 'lib/vidload/mp4/api.rb', line 57 def initialize(**kwargs) @kwargs = kwargs end |
Class Method Details
.builder ⇒ Object
61 62 63 |
# File 'lib/vidload/mp4/api.rb', line 61 def self.builder DownloaderBuilder.new end |
.display_with_spinner(loading_msg = 'Loading...') ⇒ Object
89 90 91 92 93 94 |
# File 'lib/vidload/mp4/api.rb', line 89 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
65 66 67 |
# File 'lib/vidload/mp4/api.rb', line 65 def self.from_hash(hash) builder.with_kwargs(**hash).build end |
Instance Method Details
#display_calling_args ⇒ Object
82 83 84 85 86 87 |
# File 'lib/vidload/mp4/api.rb', line 82 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/
70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/vidload/mp4/api.rb', line 70 def download_video Playwright.create(playwright_cli_executable_path: @kwargs[:playwright_cli_path]) do |playwright| browser = playwright.chromium.launch page = browser.new_page manage_video_download(page) wait_until_video_downloaded browser.close end end |