Class: YoutubeDL::Runner

Inherits:
Object
  • Object
show all
Includes:
Support
Defined in:
lib/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

#cocaine_line, #quoted, #usable_executable_path_for, #which

Constructor Details

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

Command Line runner initializer


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

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

Instance Attribute Details

#executableString


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

def executable
  @executable
end

#executable_pathString (readonly)

Returns usable executable path for youtube-dl


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

def executable_path
  @executable_path
end

#optionsYoutubeDL::Options


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

def options
  @options
end

#urlString


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

def url
  @url
end

Instance Method Details

#backend_runnerCommandLineRunner

Returns Cocaine's runner engine


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

def backend_runner
  Cocaine::CommandLine.runner
end

#backend_runner=(cocaine_runner) ⇒ Object

Sets Cocaine's runner engine


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

def backend_runner=(cocaine_runner)
  Cocaine::CommandLine.runner = cocaine_runner
end

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

Options configuration. Just aliases to options.configure

Yields:

  • (config)

    options


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

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

#runString Also known as: download

Runs the command


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

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

#to_commandString Also known as: command

Returns the command string without running anything


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

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