amplitude
Transmission RPC API Ruby Bindings
Because every transmission has its signal and amplitude.
Requirements
- Ruby 2.0.0 or above.
- Transmission 2.80 or above.
Installation
Add this line to your project’s Gemfile:
gem 'amplitude'
Don't forget to execute :
$ bundle
Usage
We need to setup amplitude
before we can use it, Let’s do this in an initializer
Add the following to config/initializers/amplitude.rb
:
Amplitude.configure do |config|
config.username = ENV['TRANSMISSION_USERNAME']
config.password = ENV['TRANSMISSION_PASSWORD']
config.url = 'http://127.0.0.1:9091/transmission/rpc' # your transmission rpc endpoint.
config.debug = true # (optional) will enable full http traces.
end
We’re pulling these keys out of environmental variables so as not to hardcode them.
Now, we can retrieve all running torrents:
torrents = Amplitude.all
Notes: You can always debug requests by turning the debug
options to true
in configurations.
By default all
only returns id
, name
and totalSize
properties.
You can always get additional properties, here is a list of available fields.
torrents = Amplitude.all(['rateDownload', 'rateUpload'])
Finding a specific torrent is also possible:
torrents = Amplitude.find(42)
torrents = Amplitude.find(42, ['rateDownload', 'rateUpload'])
Operations
Add a new torrent
Adding a torrent using its magnet or standard url :
Amplitude.add('http://website.tld/source.torrent')
Otherwise, you can put base64 content of the torrent file as a second argument:
Amplitude.add(nil, base64_content)
Extra options can be set as a third argument. Please read the spec for that.
Remove existing torrent
Amplitude.remove(id)
By default, local data are not deleted. If you want that simply add a true
flag to the remove
operation:
Amplitude.remove(id, true)
Starting or stopping a torrent
Amplitude.start(id)
Amplitude.start_now(id)
Amplitude.stop(id)
Setting properties using mutators
Amplitude.set('uploadLimit', 3600)
Mutators properties are available in spec.
Reading properties using accessors
Amplitude.get('uploadLimit')
Accessors properties are available in spec.
Executing a torrent verification
Amplitude.verify(id)
Asking tracker for more peer
Amplitude.reannounce(id)
Development & Contribution
Test cases can be run with :
$ bundle exec rake
- If you’re creating a small fix or patch to an existing feature, just a simple test will do.
- Please follow this Ruby style-guide when modifying code.
- Contributions will not be (of course) accepted without tests.