Sha256: 22a4f52c16ac34dbceb9307c52464f921bf0efb2260934fe73a8cc01327473d0

Contents?: true

Size: 716 Bytes

Versions: 7

Compression:

Stored size: 716 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

7 entries across 7 versions & 1 rubygems

Version Path
jetel-0.0.18 lib/jetel/downloaders/aria/aria.rb
jetel-0.0.17 lib/jetel/downloaders/aria/aria.rb
jetel-0.0.16 lib/jetel/downloaders/aria/aria.rb
jetel-0.0.15 lib/jetel/downloaders/aria/aria.rb
jetel-0.0.14 lib/jetel/downloaders/aria/aria.rb
jetel-0.0.12 lib/jetel/downloaders/aria/aria.rb
jetel-0.0.11 lib/jetel/downloaders/aria/aria.rb