Class: YtDlp::Runner

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

Overview

Wraps the execution of the yt-dlp command.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(executable_path:, url:, options: {}) ⇒ Runner

Initialize the runner.

Parameters:

  • executable_path (String)

    Executable to run

  • url (<Type>)

    Download URL

  • options (options) (defaults to: {})

    Command options



17
18
19
20
21
# File 'lib/yt_dlp/runner.rb', line 17

def initialize(executable_path:, url:, options: {})
  @executable_path = executable_path
  @url = url
  @options = options
end

Instance Attribute Details

#executable_pathObject (readonly)

Returns the value of attribute executable_path.



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

def executable_path
  @executable_path
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end

Instance Method Details

#runString

Run the executable with the specified options.

Returns:

  • (String)

    execution output



28
29
30
31
32
# File 'lib/yt_dlp/runner.rb', line 28

def run
  command_line.run
rescue Terrapin::CommandLineError
  raise Errors::YtDlpError
end