Skip to content

🕷️ Easily scrap the web for torrent and media files.

License

Notifications You must be signed in to change notification settings

kodjunkie/node-raspar

Repository files navigation

🕷️ Node Raspar

Easily scrap the web for torrent and media files.

downloads raspar CI License: MIT

Getting Started

Raspar exports a resolver function which accepts the configuration object as an argument and returns promises for all available methods.

Installation

To use Raspar in your project, run:

npm i node-raspar

Usage

Raspar follows the latest maintenance LTS version of Node and v14.x or greater is recommended.

Configuration

NOTE: You can use any promise based cache store engine from this list, raspar uses fs-hash by default.

const options = {
	driver: "1337x", // default: zippyshare
	perPage: 12, // results per page (default: 10)
	cache: { options: { ttl: 60 * 8 } }, // to disable caching set to "false"
};

Example 1 - get a list of music files (using the zippyshare driver)

// initialize by passing a custom options
// or leave empty for default
const raspar = require("node-raspar")(options);

// when using zippyshare driver
// you need to pass a genre as the second argument to the list method
// calling it without passing the genre returns a list of available genres
const page = 1;
const genre = "Hip Hop";

raspar.list(page, genre).then(console.log).catch(console.error);

Example 2 - search for torrent files (using the 1337x driver)

const raspar = require("node-raspar")(options);

(async () => {
	const page = 1;
	const keyword = "avengers";

	const results = await raspar.search(keyword, page);
	console.log(results);
})();

Available Drivers and Methods

Drivers Type Search (query, page) List (page)
Zippyshare Music
1337x Torrent
Netnaija Movie
Zoro Anime

Running / Deploying the API

This is the first step if you're trying to either run it with or without using docker, In your terminal run the following commands to get the code on your machine.

# first clone the repo
$ git clone https://github.com/kodjunkie/node-raspar.git raspar
# change directory
$ cd raspar
# chmod the cache directory
$ sudo chmod -R 777 temp/

Without Docker

Run these additional commands

# install dependencies
$ npm install
# start the server
$ npm start

With Docker

Run these additional commands

# build the container
$ docker build -t raspar-api .
# run the container mapping the ports
$ docker run --name raspar -it -p 3000:3000 raspar-api

With Docker Compose

Run these additional commands

# to boot-up first time only
# or whenever docker file is modified (builds the container)
$ docker compose up --build
# to boot-up without building the container (regular use)
$ docker compose up
# to shut-down
$ docker compose down

Solutions to problems you might encounter with docker compose

NOTE: Before you run any of the solutions below, you first need access to the rasper shell.

# To gain access to the shell, open a new terminal window and run
$ docker exec -it raspar bash
#
# to exit raspar shell, run (optional)
$ exit
#
# Problem 1: you might get module loading errors
# once in the raspar shell, run
$ npm install
#
# Problem 2: you might get "Could not locate (chrome) locally" error
# this happens when npm doesn't run puppeteer's post install script successfully
# once in the raspar shell, run
$ node ./node_modules/puppeteer/install.js

Deploying on Heroku

Heroku requires some additional dependencies that aren't included on the Linux box that Heroku spins up for you. To add the dependencies on deploy, add the Puppeteer Heroku buildpack to the list of buildpacks for your app under Settings > Buildpacks.

The url for the buildpack is https://github.com/CoffeeAndCode/puppeteer-heroku-buildpack

API Documentation

NOTE: localhost refers to the address your server is running on. By default, it runs on port 3000

Swagger: http://localhost:3000/docs

Liked it?

Hope you liked this project, don't forget to give it a star ⭐

Tests

$ npm test

# or via docker
$ docker exec -it raspar npm test

License

This project is opened under the MIT 2.0 License which allows very broad use for both academic and commercial purposes.