Giter VIP home page Giter VIP logo

node-raspar's Introduction

πŸ•·οΈ 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.

node-raspar's People

Contributors

kodjunkie avatar

Stargazers

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

Watchers

 avatar  avatar

node-raspar's Issues

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.