Sha256: 5cb6452fca2e1a528dece3acfbecf0fbaf0f64bd1f0ea9c0c2fff99834fa06a1

Contents?: true

Size: 635 Bytes

Versions: 2

Compression:

Stored size: 635 Bytes

Contents

# encoding: utf-8

require 'pty'

require_relative 'base_downloader'

module Jetel
  module Downloaders
    class Aria < BaseDownloader
      def download(url, opts = BaseDownloader::OPTS_DOWNLOAD)
        super

        $stdout.sync = true

        opts = BaseDownloader::OPTS_DOWNLOAD.merge(opts)

        cmd = "aria2c -j 4 -t #{opts[:timeout]} -d \"#{opts[:dir]}\" #{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
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jetel-0.0.7 lib/jetel/downloader/backends/aria.rb
jetel-0.0.6 lib/jetel/downloader/backends/aria.rb