Class: YtDlp::Video

Inherits:
Object
  • Object
show all
Defined in:
lib/yt_dlp/video.rb

Overview

Data model for a video accessed from an URL.

Constant Summary collapse

MANDATORY_OPTIONS =

Required to get informations about the video.

{
  dump_json: true,
  simulate: false
}.freeze
INFORMATION_OPTIONS =

Optimisation purpose. Do not download the video if you only need information.

MANDATORY_OPTIONS.merge(skip_download: true).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, executable_path = YtDlp.config.executable_path, **options) ⇒ Video

Initialize a Video.

Parameters:



26
27
28
29
30
# File 'lib/yt_dlp/video.rb', line 26

def initialize(url, executable_path = YtDlp.config.executable_path, **options)
  @url = url
  @executable_path = executable_path
  @options = options
end

Instance Attribute Details

#executable_pathObject (readonly)

Returns the value of attribute executable_path.



8
9
10
# File 'lib/yt_dlp/video.rb', line 8

def executable_path
  @executable_path
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/yt_dlp/video.rb', line 8

def options
  @options
end

#urlObject (readonly)

Returns the value of attribute url.



8
9
10
# File 'lib/yt_dlp/video.rb', line 8

def url
  @url
end

Instance Method Details

#downloadObject



32
33
34
35
# File 'lib/yt_dlp/video.rb', line 32

def download
  @information = run_with_options(options.merge(MANDATORY_OPTIONS))
  @information[:filename]
end

#informationObject



37
38
39
# File 'lib/yt_dlp/video.rb', line 37

def information
  @information ||= run_with_options(options.merge(INFORMATION_OPTIONS))
end