class Jetel::Downloaders::Aria

Public Instance Methods

download(url, opts = BaseDownloader::OPTS_DOWNLOAD) click to toggle source
Calls superclass method
# File lib/jetel/downloaders/aria/aria.rb, line 10
def download(url, opts = BaseDownloader::OPTS_DOWNLOAD)
  super

  $stdout.sync = true

  opts = BaseDownloader::OPTS_DOWNLOAD.merge(opts)

  filename = opts[:filename] || url.split('/').last

  cmd = "aria2c -j 4 -t #{opts[:timeout]} -d \"#{opts[:dir]}\" -o \"#{filename}\" #{url}"
  puts(cmd)

  PTY.spawn(cmd) do |stdout, stdin, pid|
    begin
      # Do stuff with the output here. Just printing to show it works
      stdout.each { |line| print line }
    end
  end
end