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:, ts_seg_pattern:, hls_index_pattern:) ⇒ Downloader
constructor
A new instance of Downloader.
Constructor Details
#initialize(video_url:, video_name:, hls_url:, master_playlist_name:, playwright_cli_path:, video_referer:, ts_seg_pattern:, hls_index_pattern:) ⇒ Downloader
Returns a new instance of Downloader.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/vidload/mp2t/api.rb', line 19 def initialize( video_url:, video_name:, hls_url:, master_playlist_name:, playwright_cli_path:, video_referer:, ts_seg_pattern:, hls_index_pattern: ) 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 raise ArgumentError, "ts_seg_pattern must be provided" unless ts_seg_pattern raise ArgumentError, "hls_index_pattern must be provided" unless hls_index_pattern @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 @ts_seg_pattern = ts_seg_pattern @hls_index_pattern = hls_index_pattern @max_lines = IO.console.winsize[0] end |
Instance Attribute Details
#hls_url ⇒ Object (readonly)
Returns the value of attribute hls_url.
17 18 19 |
# File 'lib/vidload/mp2t/api.rb', line 17 def hls_url @hls_url end |
#master_playlist_name ⇒ Object (readonly)
Returns the value of attribute master_playlist_name.
17 18 19 |
# File 'lib/vidload/mp2t/api.rb', line 17 def master_playlist_name @master_playlist_name end |
#playwright_cli_path ⇒ Object (readonly)
Returns the value of attribute playwright_cli_path.
17 18 19 |
# File 'lib/vidload/mp2t/api.rb', line 17 def playwright_cli_path @playwright_cli_path end |
#video_name ⇒ Object (readonly)
Returns the value of attribute video_name.
17 18 19 |
# File 'lib/vidload/mp2t/api.rb', line 17 def video_name @video_name end |
#video_referer ⇒ Object (readonly)
Returns the value of attribute video_referer.
17 18 19 |
# File 'lib/vidload/mp2t/api.rb', line 17 def video_referer @video_referer end |
#video_url ⇒ Object (readonly)
Returns the value of attribute video_url.
17 18 19 |
# File 'lib/vidload/mp2t/api.rb', line 17 def video_url @video_url end |
Class Method Details
.display_with_spinner(loading_msg = "Loading...") ⇒ Object
87 88 89 90 91 92 |
# File 'lib/vidload/mp2t/api.rb', line 87 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
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/vidload/mp2t/api.rb', line 49 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], ts_seg_pattern: ARGV[6], hls_index_pattern: ARGV[7], ) end |
Instance Method Details
#display_calling_args ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/vidload/mp2t/api.rb', line 75 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/
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/vidload/mp2t/api.rb', line 63 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 |