mirror of
https://github.com/TheBeastLT/torrentio-scraper.git
synced 2026-04-21 11:01:55 +00:00
fix lapumia scraper
This commit is contained in:
parent
8199b50021
commit
d17c1b05c3
2 changed files with 13 additions and 9 deletions
|
|
@ -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);
|
||||||
torrents.push({
|
try {
|
||||||
name: row.find("div > a").text(),
|
torrents.push({
|
||||||
torrentId: row.find("div > a").attr("href")
|
name: row.find("div > a").text(),
|
||||||
});
|
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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue