mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
adds kickass scrapper
This commit is contained in:
@@ -6,7 +6,7 @@ const decode = require('magnet-uri');
|
||||
const defaultProxies = [
|
||||
'https://1337x.to'
|
||||
];
|
||||
const defaultTimeout = 30000;
|
||||
const defaultTimeout = 10000;
|
||||
|
||||
const Categories = {
|
||||
MOVIE: 'Movies',
|
||||
@@ -20,12 +20,12 @@ const Categories = {
|
||||
OTHER: 'Other',
|
||||
};
|
||||
|
||||
function torrent(torrentSlug, config = {}, retries = 2) {
|
||||
if (!torrentSlug || retries === 0) {
|
||||
return Promise.reject(new Error(`Failed ${torrentSlug} query`));
|
||||
function torrent(torrentId, config = {}, retries = 2) {
|
||||
if (!torrentId || retries === 0) {
|
||||
return Promise.reject(new Error(`Failed ${torrentId} query`));
|
||||
}
|
||||
const proxyList = config.proxyList || defaultProxies;
|
||||
const slug = torrentSlug.startsWith('/torrent/') ? torrentSlug.replace('/torrent/', '') : torrentSlug;
|
||||
const slug = torrentId.startsWith('/torrent/') ? torrentId.replace('/torrent/', '') : torrentId;
|
||||
|
||||
return raceFirstSuccessful(proxyList
|
||||
.map((proxyUrl) => singleRequest(`${proxyUrl}/torrent/${slug}`, config)))
|
||||
@@ -53,7 +53,7 @@ function browse(config = {}, retries = 2) {
|
||||
}
|
||||
const proxyList = config.proxyList || defaultProxies;
|
||||
const page = config.page || 1;
|
||||
const category = config.category || 0;
|
||||
const category = config.category;
|
||||
|
||||
return raceFirstSuccessful(proxyList
|
||||
.map((proxyUrl) => singleRequest(`${proxyUrl}/cat/${category}/${page}/`, config)))
|
||||
@@ -92,7 +92,7 @@ function parseTableBody(body) {
|
||||
const row = $(element);
|
||||
torrents.push({
|
||||
name: row.find('a').eq(1).text(),
|
||||
slug: row.find('a').eq(1).attr('href').replace('/torrent/', ''),
|
||||
torrentId: row.find('a').eq(1).attr('href').replace('/torrent/', ''),
|
||||
seeders: parseInt(row.children('td.coll-2').text()),
|
||||
leechers: parseInt(row.children('td.coll-3').text()),
|
||||
size: parseSize(row.children('td.coll-4').text())
|
||||
@@ -116,9 +116,9 @@ function parseTorrentPage(body) {
|
||||
const imdbIdMatch = details.find('div[id=\'description\']').html().match(/imdb\.com\/title\/tt(\d+)/i);
|
||||
|
||||
const torrent = {
|
||||
name: decode(magnetLink).dn,
|
||||
name: decode(magnetLink).name.replace(/\+/g, ' '),
|
||||
infoHash: decode(magnetLink).infoHash,
|
||||
magnetLink: magnetLink,
|
||||
infoHash: details.find('strong:contains(\'Infohash\')').next().text(),
|
||||
seeders: parseInt(details.find('strong:contains(\'Seeders\')').next().text(), 10),
|
||||
leechers: parseInt(details.find('strong:contains(\'Leechers\')').next().text(), 10),
|
||||
category: details.find('strong:contains(\'Category\')').next().text(),
|
||||
|
||||
Reference in New Issue
Block a user