RARBG
Ruby wrapper for RARBG Torrent API.
Installation
Install as a gem
$ gem install rarbg
Or add it to your Gemfile and execute bundle install
gem 'rarbg', '~> 1.0'
Usage
This gem wraps all API methods available from RARBG TorrentAPI.
An authentication token is automatically generated on first request, stored with timestamp and renewed every 800 seconds.
Getting started
Require the gem and initialize a new RARBG::API
object.
require 'rarbg'
rarbg = RARBG::API.new
Methods
Use list
to list torrents.
Additional parameters are passed as keyword arguments and can be mixed together.
All successful method calls return an array of hashes.
# List last 100 torrents.
rarbg.list(limit: 100)
# List all torrents with at least 20 seeders, sorted by seeders.
rarbg.list(min_seeders: 100, sort: :seeders)
# List torrents with extended json infos.
rarbg.list(format: :json_extended)
Use search
to search torrents.
One search type parameter among string
, imdb
, themoviedb
and tvdb
is required.
# Search torrents using literal string query.
rarbg.search(string: 'Force Awakens')
# Search by IMDB id, in `Movies/x264/1080` and `Movies/x264/720`.
# Note that 'tt' can be omitted when passing an IMDB id.
rarbg.search(imdb: 'tt2488496', category: [44, 45])
# Search unranked torrents by TheMovieDB id, sorted by last.
rarbg.search(themoviedb: 140607, ranked: false, sort: :last)
Errors
API endpoint errors will raise a RARBG::APIError
exception with the API error message.
rarbg.list(sort: :name)
# => RARBG::APIError: Invalid sort
rarbg.search(string: 'Star Wars', min_seeders: 'notanumber')
# => RARBG::APIError: Invalid value for min_seeders
rarbg.search(imdb: 'tt0121765')
# => RARBG::APIError: Service unavailable (503)
Parameter validation errors on client side will raise an ArgumentError
.
rarbg.list('a string instead of an hash')
# => ArgumentError: Expected params hash
rarbg.search(limit: 50)
# => ArgumentError: At least one parameter required among string, imdb, tvdb, themoviedb for search mode.
Contributing
Bug reports and pull requests are welcome on GitHub.
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Code of Conduct.
You can contribute changes by forking the project and submitting a pull request. To get started:
- Fork the repo
- Install the dependencies (
bin/setup
) - Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Pass the test suite (
rake spec
) - Push to the branch (
git push origin my-new-feature
) - Create a new pull request
License
This gem is released as open source under the terms of the MIT License.