mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
fix lapumia scraper
This commit is contained in:
@@ -21,12 +21,11 @@ function torrent(torrentId, config = {}, retries = 2) {
|
|||||||
if (!torrentId || retries === 0) {
|
if (!torrentId || retries === 0) {
|
||||||
return Promise.reject(new Error(`Failed ${torrentId} query`));
|
return Promise.reject(new Error(`Failed ${torrentId} query`));
|
||||||
}
|
}
|
||||||
const slug = torrentId.split('?p=')[1];
|
return singleRequest(`${baseUrl}/${torrentId}`, config)
|
||||||
return singleRequest(`${baseUrl}/?p=${slug}`, config)
|
|
||||||
.then((body) => parseTorrentPage(body))
|
.then((body) => parseTorrentPage(body))
|
||||||
.then((torrent) => torrent.map(el => ({ torrentId: slug, ...el })))
|
.then((torrent) => torrent.map(el => ({ torrentId, ...el })))
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.warn(`Failed Lapumia ${slug} request: `, err);
|
console.warn(`Failed Lapumia ${torrentId} request: `, err);
|
||||||
return torrent(torrentId, config, retries - 1)
|
return torrent(torrentId, config, retries - 1)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -90,10 +89,14 @@ function parseTableBody(body) {
|
|||||||
|
|
||||||
$('div.post').each((i, element) => {
|
$('div.post').each((i, element) => {
|
||||||
const row = $(element);
|
const row = $(element);
|
||||||
|
try {
|
||||||
torrents.push({
|
torrents.push({
|
||||||
name: row.find("div > a").text(),
|
name: row.find("div > a").text(),
|
||||||
torrentId: row.find("div > a").attr("href")
|
torrentId: row.find("div > a").attr("href").split('/')[3]
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Failed parsing Lupumia table entry")
|
||||||
|
}
|
||||||
});
|
});
|
||||||
resolve(torrents);
|
resolve(torrents);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ async function updateSeeders(torrent) {
|
|||||||
|
|
||||||
async function scrapeLatestTorrents() {
|
async function scrapeLatestTorrents() {
|
||||||
const allowedCategories = [
|
const allowedCategories = [
|
||||||
lapumia.Categories.MOVIE
|
lapumia.Categories.MOVIE,
|
||||||
|
lapumia.Categories.TV
|
||||||
];
|
];
|
||||||
|
|
||||||
return Promises.sequence(allowedCategories
|
return Promises.sequence(allowedCategories
|
||||||
|
|||||||
Reference in New Issue
Block a user