Class: RbYoutubeDL::Video
Overview
Video model for using and downloading a single video.
Instance Attribute Summary collapse
-
#download_options ⇒ RbYoutubeDL::Options
readonly
Download Options for the last download.
Attributes inherited from Runner
#executable, #executable_path, #options, #url
Class Method Summary collapse
-
.download(url, options = {}) ⇒ RbYoutubeDL::Video
Instantiate a new Video model and download the video.
-
.get ⇒ RbYoutubeDL::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
#quoted, #terrapin_line, #usable_executable_path_for, #which
Constructor Details
#initialize(url, options = {}) ⇒ Video
Instantiate new model
28 29 30 31 32 |
# File 'lib/rb-youtube-dl/video.rb', line 28 def initialize(url, = {}) @url = url @options = RbYoutubeDL::Options.new(.merge()) @options.banned_keys = banned_keys end |
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/rb-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 ⇒ RbYoutubeDL::Options (readonly)
Returns Download Options for the last download.
22 23 24 |
# File 'lib/rb-youtube-dl/video.rb', line 22 def @download_options end |
Class Method Details
.download(url, options = {}) ⇒ RbYoutubeDL::Video
Instantiate a new Video model and download the video
RbYoutubeDL.download 'https://www.youtube.com/watch?v=KLRDLIIl8bA' # => #<RbYoutubeDL::Video:0x00000000000000>
RbYoutubeDL.get 'https://www.youtube.com/watch?v=ia1diPnNBgU', extract_audio: true, audio_quality: 0
13 14 15 16 17 |
# File 'lib/rb-youtube-dl/video.rb', line 13 def download(url, = {}) video = new(url, ) video.download video end |
.get ⇒ RbYoutubeDL::Video
Instantiate a new Video model and download the video
RbYoutubeDL.download 'https://www.youtube.com/watch?v=KLRDLIIl8bA' # => #<RbYoutubeDL::Video:0x00000000000000>
RbYoutubeDL.get 'https://www.youtube.com/watch?v=ia1diPnNBgU', extract_audio: true, audio_quality: 0
18 19 20 21 22 |
# File 'lib/rb-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/rb-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(RbYoutubeDL::Runner.new(url, ).run) end |
#filename ⇒ String
Returns the expected filename
47 48 49 |
# File 'lib/rb-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/rb-youtube-dl/video.rb', line 54 def information @information || grab_information_without_download end |