Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sayem314 committed Jan 13, 2020
0 parents commit 763124f
Show file tree
Hide file tree
Showing 34 changed files with 2,875 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"env": {
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module"
},
"globals": {
"g": true,
"describe": true,
"it": true
},
"rules": {
"indent": ["error", 2],
"no-console": 0,
"linebreak-style": ["error", "unix"],
"quotes": ["error", "double"],
"semi": ["error", "always"]
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vscode
node_modules
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: node_js
node_js:
- "8"
- "10"
- "12"
notifications:
email:
on_success: never
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2020 sayem314

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# torrent-indexer [![Build Status](https://travis-ci.org/sayem314/torrent-indexer.svg?branch=master)](https://travis-ci.org/sayem314/torrent-indexer)

Finds the best torrents (Movies, Series and Other stuff) across multiple sources.

## Install:

```bash
$ npm i torrent-indexer
or
$ yarn add torrent-indexer
```

## Usage:

```javascript
const torrentIndexer = require("torrent-indexer");

(async function() {
let results = await torrentIndexer.search("rick and morty s04e04", "series");

/*
[
{
"resolution": "720p",
"source": "hdtv",
"codec": "x264",
"season": 4,
"episode": 4,
"score": 23.213,
"title": "Rick and Morty",
"fileName": "Rick and Morty S04E04 Claw and Hoarder Special Ricktims Morty 720p HDTV x264-CRiMSON [eztv]",
"size": "542.7 MB",
"seeders": 587,
"site": "https://1337x.to/torrent/4169905/Rick-and-Morty-S04E04-Claw-and-Hoarder-Special-Ricktims-Morty-720p-HDTV-x264-CRiMSON-eztv/",
"uploaded": "Dec. 9th '19",
"sourceName": "1337x"
},
...
]
*/

results = await torrentIndexer.search("x-men: dark phoenix 2019", "movie");

/*
[
{
"year": 2019,
"resolution": "720p",
"title": "X-Men: Dark Phoenix",
"fileName": "X-Men: Dark Phoenix (2019) 720p",
"score": 0.522,
"size": "1023.6 MB",
"link": "https://yts.lt/torrent/download/1E52BF4B0AF8D9200486F2EF5F8BFCE805DB4F2C",
"seeders": 1455,
"uploaded": "2019-08-29",
"sourceName": "YTS"
},
...
]
*/
})();
```
17 changes: 17 additions & 0 deletions example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const torrentIndexer = require("./");

(async function() {
const series = await torrentIndexer.search("rick and morty s04e04", "series");
console.log("Series", series[0], series.length + " items");

if (!series[0].link) {
const torrentInfo = torrentIndexer.info(series[0].site);
}

const movies = await torrentIndexer.search(
"x-men: dark phoenix 2019",
"movie"
);

console.log("Movies", movies[0], movies.length + " items");
})();
23 changes: 23 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const torrentIndexer = require("./src/torrentIndexer");
const cheerio = require("cheerio");
const axios = require("axios");

const info = async url => {
try {
const { data } = await axios.get(url);
const $ = cheerio.load(data);

return (
$("a[href^=magnet]")
.eq(0)
.attr("href") ||
$(".torrenthash")
.find("a")
.text()
);
} catch (err) {
throw "There was a problem extracting " + url;
}
};

module.exports = { search: torrentIndexer, torrent: info };
42 changes: 42 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "torrent-indexer",
"version": "1.0.0",
"description": "Yet another node.js torrent scraper based on seek-torrent but made especially for movie and series (scrape from 1337x, eztv, limetorrents, rarbg, skytorrents, torrentproject, torrentz2, yts and zooqle)",
"main": "index.js",
"scripts": {
"test": "mocha test/**",
"pretest": "npm run eslint",
"eslint": "eslint src/"
},
"engines": {
"node": ">= 8.0.0"
},
"repository": {
"type": "git",
"url": "https://github.com/sayem314/torrent-indexer.git"
},
"keywords": [
"torrent",
"search",
"seek",
"index",
"download",
"movie",
"series",
"tracker",
"tvshow"
],
"author": "Sayem Chowdhury",
"license": "MIT",
"dependencies": {
"axios": "^0.19.1",
"cheerio": "^1.0.0-rc.3",
"parse-torrent-title": "^1.2.0",
"string-similarity": "^4.0.1"
},
"devDependencies": {
"chai": "4.2.0",
"eslint": "6.8.0",
"mocha": "7.0.0"
}
}
60 changes: 60 additions & 0 deletions src/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"sources": {
"kickass": {
"name": "Kickass",
"url": "https://katcr.co"
},
"limetorrents": {
"name": "LimeTorrents",
"url": "https://www.limetorrents.info"
},
"yts": {
"name": "YTS",
"url": "https://yts.lt"
},
"tpb": {
"name": "The Pirate Bay",
"url": "https://thepiratebay.org"
},
"sky": {
"name": "Sky Torrents",
"url": "https://skytorrents.lol"
},
"leetx": {
"name": "1337x",
"url": "https://1337x.to"
},
"nyaa": {
"name": "Nyaa",
"url": "http://www.nyaa.si"
},
"tokyotosho": {
"name": "Tokiotosho",
"url": "https://www.tokyotosho.info"
},
"eztv": {
"name": "Eztv",
"url": "https://www.eztv.ag"
},
"rarbg": {
"name": "Rarbg",
"url": "https://torrentapi.org"
},
"zooqle": {
"name": "Zooqle",
"url": "https://zooqle.com"
},
"xbit": {
"name": "x[BiT]",
"url": "https://xbit.pw"
},
"torrentproject": {
"name": "TorrentProject",
"url": "https://torrentproject.cc"
},
"torrentz2": {
"name": "Torrentz2",
"url": "https://torrentz2.eu"
}
}
}
62 changes: 62 additions & 0 deletions src/lib/1337x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const axios = require("axios");
const cheerio = require("cheerio");

const search = async (query, leetx_url, page) => {
let search_query = query.split(" ").join("+");
let search_url = `${leetx_url}/search/${search_query}/${page}/`;
let data_content = {};
let torrent_content = [];

try {
const { data } = await axios.get(search_url);
const $ = cheerio.load(data);

$(".table-list tbody tr").each((index, torrents) => {
let torrent_site = $(torrents)
.find(".name a")
.next()
.attr("href");
let title = $(torrents)
.find(".name a")
.text()
.replace("⭐", "")
.trim();
let seeds = $(torrents)
.find(".seeds")
.eq(0)
.text();

let leechs = $(torrents)
.find(".leeches")
.eq(0)
.text();

let size = $(torrents)
.find("td.coll-4")
.children()
.remove()
.end()
.text();
let date_added = $(torrents)
.find(".coll-date")
.text();

data_content = {
title: title,
category: "",
seeds: Number(seeds),
leechs: Number(leechs),
size: size,
torrent_site: leetx_url + torrent_site,
date_added: date_added
};

torrent_content.push(data_content);
});
return torrent_content;
} catch (err) {
throw "\u2717 There was a problem loading 1337x";
}
};

module.exports = { search };
61 changes: 61 additions & 0 deletions src/lib/eztv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
const axios = require("axios");
const cheerio = require("cheerio");

const search = async (query, eztv_url) => {
let search_query = query.split(" ").join("-");
let search_url = eztv_url + "/search/" + search_query;
let data_content = {};
let torrent_content = [];

try {
const { data } = await axios.get(search_url, {
headers: {
"User-Agent": "request"
}
});
const $ = cheerio.load(data);

let eztv_link,
torrent_title,
torrent_size,
torrent_seeds,
torrent_leech,
date_added;

$("tr.forum_header_border").each((index, torrent) => {
eztv_link = $(torrent)
.find("a.magnet")
.attr("href");
torrent_title = $(torrent)
.find("a.epinfo")
.text();
torrent_size = $(torrent)
.find("a.epinfo")
.attr("title")
.match(/\([^)]+\)$/)[0]
.slice(1, -1);
torrent_seeds = $("td.forum_thread_post_end", torrent).text();
torrent_leech = "";
date_added = $("td.forum_thread_post_end", torrent)
.prev()
.text();

data_content = {
title: torrent_title,
category: "",
seeds: Number(torrent_seeds),
leechs: torrent_leech,
size: torrent_size,
torrent_link: eztv_link,
date_added: date_added
};

torrent_content.push(data_content);
});
return torrent_content;
} catch (err) {
throw "\u2717 There was a problem loading Eztv";
}
};

module.exports = { search };
Loading

0 comments on commit 763124f

Please sign in to comment.