1.1.0 • Published 7 years ago

gazelle-api v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

Gazelle API

Javascript Gazelle API based on promises. Quick and dirty fork of whatcd-api by Christilut to be used on other trackers. All credit goes to him/her for this awesome script.

Installation

Requires Node >= 6.0

npm install gazelle-api

Usage

Check WhatCD API for all available endpoints. For example, the browse action (which searches the tracker) requires a searchstr parameter so you must add that in the object passed to gazelle.action().

const GazelleAPI = require('gazelle-api')

const gazelle = new GazelleAPI('username', 'password', 'hostname')

gazelle.action('browse', {
  searchstr: 'my favourite band'
}).then(response => {
  console.log(response)
})

Rate limited

This library is rate limited to 5 requests per 10 seconds as specified by the WhatCD API documentation. So if you notice a few fast requests and sometimes a slow one, its probably waiting on rate limiting.

API

gazelle.action(action=string, parameters=object): Low level method to perform any action as described in the WhatCD API documentation.

gazelle.search(artist=string, album=string): Helper method that searches for an artist/album. It will start at 320kbps and search for a V0 release if nothing was found.

gazelle.download(id=integer, path=string): Helper method to download a .torrent file from the torrent ID that was supplied. Will save to specified path. Path must not include a filename.

Testing

npm test (will use fixtures)

Some tests require a username and password:
env GAZELLE_USERNAME='' GAZELLE_PASSWORD='' GAZELLE_HOSTNAME='' npm run test

For a live test (not currently working):
env GAZELLE_USERNAME='' GAZELLE_PASSWORD='' LIVE=true npm test -- -g 'search'

Careful not to get banned for multiple false login attempts.

Contribute

Pull requests very welcome! <3
Please create an issue if you find a bug.

License

MIT aka do whatever you want.