Sha256: 2f5b45c2643fada8321055fcbe0df4e4c1f0aba7b1e01dfd8a1134a28613a21b

Contents?: true

Size: 713 Bytes

Versions: 3

Compression:

Stored size: 713 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)

        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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jetel-0.0.10 lib/jetel/downloader/backends/aria.rb
jetel-0.0.9 lib/jetel/downloader/backends/aria.rb
jetel-0.0.8 lib/jetel/downloader/backends/aria.rb