Module: Overscribe::YoutubeDL

Defined in:
lib/overscribe/youtube_dl.rb

Class Method Summary collapse

Class Method Details

.download(url:, args:, options:) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/overscribe/youtube_dl.rb', line 3

def self.download(url:, args:, options:)
  command = %w[youtube-dl --add-metadata]
  command += %w[--yes-playlist]
  command += %w[--ignore-errors --no-call-home]
  command += %w[--download-archive .youtube-dl.archive]

  command += %w[--get-filename] if options['simulate'] == true
  command += %W[--max-downloads #{options['limit']}] unless options['limit'].nil? || options['limit'].zero?
  command += %W[--output #{options['filename_pattern']}] unless options['filename_pattern'].nil?
  command += args

  command += [url]
  run command
end

.run(command) ⇒ Object



18
19
20
21
22
23
# File 'lib/overscribe/youtube_dl.rb', line 18

def self.run(command)
  puts "Running '#{command}'"
  system(*command)
  status = $CHILD_STATUS
  puts status
end