Class: RbYoutubeDL::Runner

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

Overview

Utility class for running and managing youtube-dl

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 youtube-dl executable

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

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



22
23
24
25
26
# File 'lib/rb-youtube-dl/runner.rb', line 22

def initialize(url, options = {})
  @url = url
  @options = RbYoutubeDL::Options.new(options)
  @executable = 'youtube-dl'
end

Instance Attribute Details

#executableString

Returns Executable name to use.

Returns:

  • (String)

    Executable name to use



16
17
18
# File 'lib/rb-youtube-dl/runner.rb', line 16

def executable
  @executable
end

#executable_pathString (readonly)

Returns usable executable path for youtube-dl

Returns:

  • (String)

    usable executable path for youtube-dl



13
14
15
# File 'lib/rb-youtube-dl/runner.rb', line 13

def executable_path
  @executable_path
end

#optionsRbYoutubeDL::Options

Returns Options access.

Returns:



10
11
12
# File 'lib/rb-youtube-dl/runner.rb', line 10

def options
  @options
end

#urlString

Returns URL to download.

Returns:

  • (String)

    URL to download



7
8
9
# File 'lib/rb-youtube-dl/runner.rb', line 7

def url
  @url
end

Instance Method Details

#backend_runnerCommandLineRunner

Returns Terrapin’s runner engine

Returns:

  • (CommandLineRunner)

    backend runner class



38
39
40
# File 'lib/rb-youtube-dl/runner.rb', line 38

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.



46
47
48
# File 'lib/rb-youtube-dl/runner.rb', line 46

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



72
73
74
# File 'lib/rb-youtube-dl/runner.rb', line 72

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

#runString Also known as: download

Runs the command

Returns:

  • (String)

    the output of youtube-dl



61
62
63
# File 'lib/rb-youtube-dl/runner.rb', line 61

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



53
54
55
# File 'lib/rb-youtube-dl/runner.rb', line 53

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