Class: YtDlp::Video
Overview
Video model for using and downloading a single video.
Instance Attribute Summary collapse
-
#download_options ⇒ YtDlp::Options
readonly
Download Options for the last download.
Attributes inherited from Runner
#executable, #executable_path, #options, #url
Class Method Summary collapse
-
.download(url, options = {}) ⇒ YtDlp::Video
Instantiate a new Video model and download the video.
-
.get ⇒ YtDlp::Video
Instantiate a new Video model and download the video.
- .information(url, options = {}) ⇒ Object
Instance Method Summary collapse
-
#download ⇒ Object
(also: #get)
Download the video.
-
#filename ⇒ String
Returns the expected filename.
-
#information ⇒ OpenStruct
Metadata information for the video, gotten from –print-json.
-
#initialize(url, options = {}) ⇒ Video
constructor
Instantiate new model.
-
#method_missing(method, *args, &block) ⇒ Object
Redirect methods for information getting.
Methods inherited from Runner
#backend_runner, #backend_runner=, #configure, #run, #to_command
Methods included from Support
#quoted, #terrapin_line, #usable_executable_path_for, #which
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
Redirect methods for information getting
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/yt-dlp/video.rb', line 71 def method_missing(method, *args, &block) value = if information.is_a?(Array) information.first[method] else information[method] end if value.nil? super else value end end |
Instance Attribute Details
#download_options ⇒ YtDlp::Options (readonly)
Returns Download Options for the last download.
29 30 31 |
# File 'lib/yt-dlp/video.rb', line 29 def @download_options end |
Class Method Details
.download(url, options = {}) ⇒ YtDlp::Video
15 16 17 18 19 |
# File 'lib/yt-dlp/video.rb', line 15 def download(url, = {}) video = new(url, ) video.download video end |
.get ⇒ YtDlp::Video
20 21 22 23 24 |
# File 'lib/yt-dlp/video.rb', line 20 def download(url, = {}) video = new(url, ) video.download video end |
.information(url, options = {}) ⇒ Object
22 23 24 25 |
# File 'lib/yt-dlp/video.rb', line 22 def information(url, = {}) video = new(url, ) video.information end |
Instance Method Details
#download ⇒ Object Also known as: get
Download the video.
42 43 44 45 46 47 |
# File 'lib/yt-dlp/video.rb', line 42 def download raise ArgumentError, 'url cannot be nil' if @url.nil? raise ArgumentError, 'url cannot be empty' if @url.empty? set_information_from_json(YtDlp::Runner.new(url, ).run) end |
#filename ⇒ String
Returns the expected filename
54 55 56 |
# File 'lib/yt-dlp/video.rb', line 54 def filename _filename end |
#information ⇒ OpenStruct
Metadata information for the video, gotten from –print-json
61 62 63 |
# File 'lib/yt-dlp/video.rb', line 61 def information @information || grab_information_without_download end |