Class: YtDlp::Runner

Inherits:
Object
  • Object
show all
Includes:
Support
Defined in:
lib/yt-dlp/runner.rb

Overview

Utility class for running and managing yt-dlp

Direct Known Subclasses

Video

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Support

#quoted, #terrapin_line, #usable_executable_path_for, #which

Constructor Details

#initialize(url, options = {}) ⇒ Runner

Command Line runner initializer

Parameters:

  • url (String)

    URL to pass to yt-dlp executable

  • options (Hash, Options) (defaults to: {})

    options to pass to the executable. Automatically converted to Options if it isn’t already



24
25
26
27
28
# File 'lib/yt-dlp/runner.rb', line 24

def initialize(url, options = {})
  @url = url
  @options = YtDlp::Options.new(options)
  @executable = 'yt-dlp'
end

Instance Attribute Details

#executableString

Returns Executable name to use.

Returns:

  • (String)

    Executable name to use



18
19
20
# File 'lib/yt-dlp/runner.rb', line 18

def executable
  @executable
end

#executable_pathString (readonly)

Returns usable executable path for yt-dlp

Returns:

  • (String)

    usable executable path for yt-dlp



15
16
17
# File 'lib/yt-dlp/runner.rb', line 15

def executable_path
  @executable_path
end

#optionsYtDlp::Options

Returns Options access.

Returns:



12
13
14
# File 'lib/yt-dlp/runner.rb', line 12

def options
  @options
end

#urlString

Returns URL to download.

Returns:

  • (String)

    URL to download



9
10
11
# File 'lib/yt-dlp/runner.rb', line 9

def url
  @url
end

Instance Method Details

#backend_runnerCommandLineRunner

Returns Terrapin’s runner engine

Returns:

  • (CommandLineRunner)

    backend runner class



40
41
42
# File 'lib/yt-dlp/runner.rb', line 40

def backend_runner
  Terrapin::CommandLine.runner
end

#backend_runner=(terrapin_runner) ⇒ Object

Sets Terrapin’s runner engine

Parameters:

  • terrapin_runner (CommandLineRunner)

    backend runner class

Returns:

  • (Object)

    whatever Terrapin::CommandLine.runner= returns.



48
49
50
# File 'lib/yt-dlp/runner.rb', line 48

def backend_runner=(terrapin_runner)
  Terrapin::CommandLine.runner = terrapin_runner
end

#configure(*a, &b) {|config| ... } ⇒ Object

Options configuration. Just aliases to options.configure

Parameters:

  • a (Array)

    arguments to pass to options#configure

  • b (Proc)

    block to pass to options#configure

Yields:

  • (config)

    options



74
75
76
# File 'lib/yt-dlp/runner.rb', line 74

def configure(*a, &b)
  options.configure(*a, &b)
end

#runString Also known as: download

Runs the command

Returns:

  • (String)

    the output of yt-dlp



63
64
65
# File 'lib/yt-dlp/runner.rb', line 63

def run
  terrapin_line(options_to_commands).run(@options.store)
end

#to_commandString Also known as: command

Returns the command string without running anything

Returns:

  • (String)

    command line string



55
56
57
# File 'lib/yt-dlp/runner.rb', line 55

def to_command
  terrapin_line(options_to_commands).command(@options.store)
end