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:, author_name:) ⇒ 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:, author_name:) ⇒ 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 48 |
# 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:, author_name: ) raise ArgumentError, "video_url must be provided" unless video_url 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 @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] @author_name = @video_name = if @author_name then "#{@author_name}_#{video_name}" else nil end 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
92 93 94 95 96 97 |
# File 'lib/vidload/mp2t/api.rb', line 92 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
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/vidload/mp2t/api.rb', line 50 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], author_name: ARGV[8], ) end |
Instance Method Details
#display_calling_args ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/vidload/mp2t/api.rb', line 77 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}" puts "\tts_seg_pattern=#{@ts_seg_pattern}" puts "\thls_index_pattern=#{@hls_index_pattern}" puts "\tauthor_name=#{@author_name}" end |
#download_video(video_starter_callbacks: []) ⇒ Object
main func to be called in your own scripts defined under web/
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/vidload/mp2t/api.rb', line 65 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 |