Git Product home page Git Product logo

rarbg's Introduction

RARBG

npm

This is a very simple rarbg api wrapper in Node using Promises.

Installation

$ npm i rarbg --save

Usage

const RarbgApi = require('rarbg')

// Create a new instance of the module
const rarbg = new RarbgApi()

// Or create a new instance with different configuration
const rarbg = new RarbgApi({
  host: 'torrentapi.org',
  path: '/pubapi_v2.php?',
  app_id: 'my_application',
  user_agent: 'My Application 0.0.1'
})

Methods

There are two methods, search() and list() that you can use. The search() method takes an object of options (see below) for various searching and sorting capabilities. Both methods return an array of objects containing filename, category, and download properties, or an error in the case of nothing being found or a different error.

// Searching by various parameters
rarbg.search({
    search_string: 'star wars',
    sort: 'seeders',
    category: rarbg.categories.MOVIES_X264_1080,
    min_seeders: 50
  }).then(response => {
    console.log(response)
    // Output:
    // [
    //   {
    //     "filename": "Star.Wars.Episode.VII.The.Force.Awakens.2015.1080p.BluRay.H264.AAC-RARBG",
    //     "category": "Movies/x264/1080",
    //     "download": "magnet:?xt=urn:btih:..."
    //   },
    //   {
    //     "filename": "Star.Wars.Episode.VII.The.Force.Awakens.2015.1080p.BluRay.x264-Replica",
    //     "category": "Movies/x264/1080",
    //     "download": "magnet:?xt=urn:btih:..."
    //   }
    // ]
  }).catch(console.error)

// List recent torrents
rarbg.list().then(response => {
    console.log(response)
    // Output:
    // [
    //   {
    //     "filename": "Those.Who.Cant.S02E02.HDTV.x264-AMBIT[rartv]",
    //     "category": "TV Episodes",
    //     "download": "magnet:?xt=urn:btih:..."
    //   },
    //   {
    //     "filename": "Those.Who.Cant.S02E02.720p.HDTV.x264-AMBIT[rartv]",
    //     "category": "TV HD Episodes",
    //     "download": "magnet:?xt=urn:btih:..."
    //   }
    //   ...
    // ]
  }).catch(console.error)

Options

Searching

  • search_string: The string to search
  • search_imdb: Search by imdb id
  • search_tvdb: Search by tvdb id
  • search_themoviedb: Search by TMdb id

Categories

  • category: The only two string values can be 'movies' and 'tv', but you can use the following constants:
rarbg.categories.XXX
rarbg.categories.MOVIES_XVID
rarbg.categories.MOVIES_XVID_720
rarbg.categories.MOVIES_X264
rarbg.categories.MOVIES_X264_1080
rarbg.categories.MOVIES_X264_720
rarbg.categories.MOVIES_X264_3D
rarbg.categories.MOVIES_X264_4K
rarbg.categories.MOVIES_X265_4K
rarbg.categories.MOVIES_X265_4K_HDR
rarbg.categories.MOVIES_FULL_BD
rarbg.categories.MOVIES_BD_REMUX
rarbg.categories.TV_EPISODES
rarbg.categories.TV_HD_EPISODES
rarbg.categories.MUSIC_MP3
rarbg.categories.MUSIC_FLAC
rarbg.categories.GAMES_PC_ISO
rarbg.categories.GAMES_PC_RIP
rarbg.categories.GAMES_PS3
rarbg.categories.GAMES_XBOX_360
rarbg.categories.SOFTWARE_PC_ISO
rarbg.categories.E_BOOKS

// `category` can be an array to search in more than one category
rarbg.search({
  search_string: 'star wars',
  category: [rarbg.categories.MOVIES_X264_1080, rarbg.categories.MOVIES_X264_720]
}).then(res => {
  //
})

Sorting

  • sort: Possible values are 'seeders', 'leechers', or 'last'

Limiting

  • limit: Possible values are 25, 50, or 100. Default is 25

Minimum seeders/leechers

  • min_seeders: Numerical value for the minimum seeders available
  • min_leechers: Numerical value for the minimum leechers available

License

MIT

rarbg's People

Contributors

chrisalderson avatar dependabot[bot] avatar f-hj avatar grantholle avatar valentinmumble avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rarbg's Issues

Return peer stats in results - Enhancement Request

Would it be possible for this to also return peer stats? If you're not actively updating this anymore, I'll just fork, but figured I'd check first

EDIT: Based on torrentapi.org docs, looks like that isn't even returning that data, so I doubt this is possible, guess I'll have to go old school scraper for now, feel free to close

only latest torrent ???

Hi, no matter how I search (search_string, search_imdb...) I only get the latest torrent uploaded to their database

has something changed?

Error not caught by .catch

I noticed sometimes we get an error that is not catched by the .catch method

rarbg.search(...).then(...).catch(...)

undefined:1
<!DOCTYPE html>
^

SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at IncomingMessage.res.on (path/node_modules/rarbg/index.js:131:42)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1056:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.