songjiz / aria2-ruby

Aria2 JSON RPC client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Aria2

Aria2 JSON RPC client

Installation

Add this line to your application's Gemfile:

gem 'aria2'

And then execute:

$ bundle

Or install it yourself as:

$ gem install aria2

Usage

  # create a client instance
  client = Aria2::Client.new(host: 'localhost', port: 6800)
  client.addUri 'http://example.com/images/1.jpg', 'http://example.com/images/2.jpg'
  # or
  client.add_uri 'http://example.com/images/1.jpg', 'http://example.com/images/2.jpg'
  client.xxxx
  ...
  
  # or 
  Aria2.with(host: 'localhost', port: 6800) do |client|
    client.addUri 'http://example.com/images/1.jpg', 'http://example.com/images/2.jpg'
    client.xxxx
    ...
  end

  # or
  Aria2.with(host: 'localhost', port: 6800) do
    addUri 'http://example.com/images/1.jpg', 'http://example.com/images/2.jpg'
    xxxx
    ...
  end

  # If you invoke method end with '!', then raise Aria2::Error when json contains 'error' key
  @client = Aria2::Client.new token: 'your_token'
  @client.getVersion!
  

Suport Methods (snakecase or camelCase)

See Methods

  • addUri(*uris)
  • addTorrent(torrent) torrent is the contents of the ".torrent" file
  • addMetalink(metalink)
  • remove(gid)
  • forceRemove(gid)
  • pause(gid)
  • pauseAll
  • forcePause(gid)
  • forcePauseAll
  • unpause(gid)
  • unpauseAll
  • tellStatus(gid)
  • getUris(gid)
  • getFiles(gid)
  • getPeers(gid)
  • getServers(gid)
  • tellActive
  • tellWaiting(offset, num)
  • tellStopped(offset, num)
  • changePosition(gid, pos, how)
  • changeUri(gid, fileIndex, delUris, addUris)
  • getOption(gid)
  • changeOption(gid, options)
  • getGlobalOption
  • changeGlobalOption(options)
  • getGlobalStat
  • purgeDownloadResult
  • removeDownloadResult(gid)
  • getVersion
  • shutdown
  • forceShutdown
  • saveSession

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/songjiz/aria2-ruby.

About

Aria2 JSON RPC client


Languages

Language:Ruby 97.2%Language:Shell 2.8%