From d17c1b05c3bb1e7498b309b404b1168ab82ec99f Mon Sep 17 00:00:00 2001 From: TheBeastLT Date: Tue, 24 May 2022 09:29:44 +0200 Subject: [PATCH] fix lapumia scraper --- scraper/scrapers/lapumia/lapumia_api.js | 19 +++++++++++-------- scraper/scrapers/lapumia/lapumia_scraper.js | 3 ++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/scraper/scrapers/lapumia/lapumia_api.js b/scraper/scrapers/lapumia/lapumia_api.js index d68b1cb..49fc88e 100644 --- a/scraper/scrapers/lapumia/lapumia_api.js +++ b/scraper/scrapers/lapumia/lapumia_api.js @@ -21,12 +21,11 @@ function torrent(torrentId, config = {}, retries = 2) { if (!torrentId || retries === 0) { return Promise.reject(new Error(`Failed ${torrentId} query`)); } - const slug = torrentId.split('?p=')[1]; - return singleRequest(`${baseUrl}/?p=${slug}`, config) + return singleRequest(`${baseUrl}/${torrentId}`, config) .then((body) => parseTorrentPage(body)) - .then((torrent) => torrent.map(el => ({ torrentId: slug, ...el }))) + .then((torrent) => torrent.map(el => ({ torrentId, ...el }))) .catch((err) => { - console.warn(`Failed Lapumia ${slug} request: `, err); + console.warn(`Failed Lapumia ${torrentId} request: `, err); return torrent(torrentId, config, retries - 1) }); } @@ -90,10 +89,14 @@ function parseTableBody(body) { $('div.post').each((i, element) => { const row = $(element); - torrents.push({ - name: row.find("div > a").text(), - torrentId: row.find("div > a").attr("href") - }); + try { + torrents.push({ + 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); }); diff --git a/scraper/scrapers/lapumia/lapumia_scraper.js b/scraper/scrapers/lapumia/lapumia_scraper.js index 0d264c3..e5ec085 100644 --- a/scraper/scrapers/lapumia/lapumia_scraper.js +++ b/scraper/scrapers/lapumia/lapumia_scraper.js @@ -33,7 +33,8 @@ async function updateSeeders(torrent) { async function scrapeLatestTorrents() { const allowedCategories = [ - lapumia.Categories.MOVIE + lapumia.Categories.MOVIE, + lapumia.Categories.TV ]; return Promises.sequence(allowedCategories