Class: YoutubeDL::Video
Overview
Video model for using and downloading a single video.
Instance Attribute Summary collapse
-
#download_options ⇒ YoutubeDL::Options
readonly
Download Options for the last download.
Attributes inherited from Runner
#executable, #executable_path, #options, #url
Class Method Summary collapse
-
.download(url, options = {}) ⇒ YoutubeDL::Video
Instantiate a new Video model and download the video.
-
.get ⇒ YoutubeDL::Video
Instantiate a new Video model and download the video.
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
#cocaine_line, #quoted, #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
64 65 66 67 68 69 70 71 72 |
# File 'lib/youtube-dl/video.rb', line 64 def method_missing(method, *args, &block) value = information[method] if value.nil? super else value end end |
Instance Attribute Details
#download_options ⇒ YoutubeDL::Options (readonly)
Returns Download Options for the last download.
22 23 24 |
# File 'lib/youtube-dl/video.rb', line 22 def @download_options end |
Class Method Details
.download(url, options = {}) ⇒ YoutubeDL::Video
13 14 15 16 17 |
# File 'lib/youtube-dl/video.rb', line 13 def download(url, = {}) video = new(url, ) video.download video end |
.get ⇒ YoutubeDL::Video
18 19 20 21 22 |
# File 'lib/youtube-dl/video.rb', line 18 def download(url, = {}) video = new(url, ) video.download video end |
Instance Method Details
#download ⇒ Object Also known as: get
Download the video.
35 36 37 38 39 40 |
# File 'lib/youtube-dl/video.rb', line 35 def download raise ArgumentError.new('url cannot be nil') if @url.nil? raise ArgumentError.new('url cannot be empty') if @url.empty? set_information_from_json(YoutubeDL::Runner.new(url, ).run) end |
#filename ⇒ String
Returns the expected filename
47 48 49 |
# File 'lib/youtube-dl/video.rb', line 47 def filename self._filename end |
#information ⇒ OpenStruct
Metadata information for the video, gotten from –print-json
54 55 56 |
# File 'lib/youtube-dl/video.rb', line 54 def information @information || grab_information_without_download end |