Class: Vidload::Mp2t::Api::Downloader
- Inherits:
-
Object
- Object
- Vidload::Mp2t::Api::Downloader
- Defined in:
- lib/vidload/mp2t/api.rb
Instance Attribute Summary collapse
-
#hls_url ⇒ Object
readonly
Returns the value of attribute hls_url.
-
#master_playlist_name ⇒ Object
readonly
Returns the value of attribute master_playlist_name.
-
#playwright_cli_path ⇒ Object
readonly
Returns the value of attribute playwright_cli_path.
-
#video_name ⇒ Object
readonly
Returns the value of attribute video_name.
-
#video_referer ⇒ Object
readonly
Returns the value of attribute video_referer.
-
#video_url ⇒ Object
readonly
Returns the value of attribute video_url.
Class Method Summary collapse
Instance Method Summary collapse
- #display_calling_args ⇒ Object
-
#download_video(video_starter_callbacks: []) ⇒ Object
main func to be called in your own scripts defined under web/.
-
#initialize(video_url:, video_name:, hls_url:, master_playlist_name:, playwright_cli_path:, video_referer:) ⇒ Downloader
constructor
A new instance of Downloader.
Constructor Details
#initialize(video_url:, video_name:, hls_url:, master_playlist_name:, playwright_cli_path:, video_referer:) ⇒ Downloader
Returns a new instance of Downloader.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/vidload/mp2t/api.rb', line 12 def initialize( video_url:, video_name:, hls_url:, master_playlist_name:, playwright_cli_path:, video_referer: ) raise ArgumentError, "video_url must be provided" unless video_url raise ArgumentError, "video_name must be provided" unless video_name raise ArgumentError, "hls_url must be provided" unless hls_url raise ArgumentError, "master_playlist_name must be provided" unless master_playlist_name raise ArgumentError, "playwright_cli_path must be provided" unless playwright_cli_path raise ArgumentError, "video_referer must be provided" unless video_referer @video_url = video_url @video_name = video_name @hls_url = hls_url @master_playlist_name = master_playlist_name @playwright_cli_path = playwright_cli_path @video_referer = video_referer end |
Instance Attribute Details
#hls_url ⇒ Object (readonly)
Returns the value of attribute hls_url.
10 11 12 |
# File 'lib/vidload/mp2t/api.rb', line 10 def hls_url @hls_url end |
#master_playlist_name ⇒ Object (readonly)
Returns the value of attribute master_playlist_name.
10 11 12 |
# File 'lib/vidload/mp2t/api.rb', line 10 def master_playlist_name @master_playlist_name end |
#playwright_cli_path ⇒ Object (readonly)
Returns the value of attribute playwright_cli_path.
10 11 12 |
# File 'lib/vidload/mp2t/api.rb', line 10 def playwright_cli_path @playwright_cli_path end |
#video_name ⇒ Object (readonly)
Returns the value of attribute video_name.
10 11 12 |
# File 'lib/vidload/mp2t/api.rb', line 10 def video_name @video_name end |
#video_referer ⇒ Object (readonly)
Returns the value of attribute video_referer.
10 11 12 |
# File 'lib/vidload/mp2t/api.rb', line 10 def video_referer @video_referer end |
#video_url ⇒ Object (readonly)
Returns the value of attribute video_url.
10 11 12 |
# File 'lib/vidload/mp2t/api.rb', line 10 def video_url @video_url end |
Class Method Details
.display_with_spinner(loading_msg = "Loading...") ⇒ Object
71 72 73 74 75 76 |
# File 'lib/vidload/mp2t/api.rb', line 71 def self.display_with_spinner(loading_msg = "Loading...") spinner = TTY::Spinner.new("[:spinner] #{loading_msg}") spinner.auto_spin yield spinner.success("(done)") end |
.from_argv ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/vidload/mp2t/api.rb', line 35 def self.from_argv new( video_url: ARGV[0], video_name: ARGV[1], hls_url: ARGV[2], master_playlist_name: ARGV[3], playwright_cli_path: ARGV[4], video_referer: ARGV[5] ) end |
Instance Method Details
#display_calling_args ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/vidload/mp2t/api.rb', line 59 def display_calling_args puts "Constants:" puts "\tDEMUXER_PATH=#{DEMUXER_PATH}" puts "Called with:" puts "\tvideo_url=#{@video_url}" puts "\tvideo_name=#{@video_name}" puts "\thls_url=#{@hls_url}" puts "\tmaster_playlist_name=#{@master_playlist_name}" puts "\tplaywright_cli_path=#{@playwright_cli_path}" puts "\tvideo_referer=#{@video_referer}" end |
#download_video(video_starter_callbacks: []) ⇒ Object
main func to be called in your own scripts defined under web/
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/vidload/mp2t/api.rb', line 47 def download_video(video_starter_callbacks: []) Playwright.create(playwright_cli_executable_path: @playwright_cli_path) do |playwright| browser = playwright.chromium.launch page = browser.new_page manage_video_download(page, *video_starter_callbacks) wait_until_video_downloaded browser.close end end |