From f04eb7289152aed2507271b445e78fc2f9c8dd4d Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Sun, 28 Nov 2021 01:20:39 +0100 Subject: [PATCH] Added upcoming scraper to PurgatoryX. --- src/scrapers/purgatoryx.js | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/scrapers/purgatoryx.js b/src/scrapers/purgatoryx.js index a824a374..34d9656c 100644 --- a/src/scrapers/purgatoryx.js +++ b/src/scrapers/purgatoryx.js @@ -37,12 +37,26 @@ function scrapeAll(scenes) { } } - console.log(release.photos); - return release; }); } +function scrapeUpcoming({ query }) { + const release = {}; + + release.url = query.url('.bottom-info a'); + release.entryId = new URL(release.url).pathname.match(/\/view\/(\d+)/)?.[1]; + release.title = query.cnt('.title'); + + release.actors = query.all('.model-wrap li').map((el) => ({ + name: query.cnt(el, 'h5'), + url: query.url(el, '.model-thumb a'), + avatar: query.img(el, '.model-thumb img'), + })); + + return release; +} + function scrapeScene({ query }, url) { const release = {}; @@ -65,8 +79,6 @@ function scrapeScene({ query }, url) { release.comment = query.cnt('.series'); - console.log(release); - return release; } @@ -80,6 +92,16 @@ async function fetchLatest(channel, page) { return res.status; } +async function fetchUpcoming(channel) { + const res = await qu.get(channel.url, '.upcoming-info-wrap'); + + if (res.ok && res.item) { + return [scrapeUpcoming(res.item, channel)]; + } + + return res.status; +} + function scrapeProfile({ query }, url) { const profile = { url }; @@ -101,9 +123,6 @@ function scrapeProfile({ query }, url) { profile.scenes = scrapeAll(qu.initAll(query.all('.content-item'))); - console.log(bio); - console.log(profile); - return profile; } @@ -147,6 +166,7 @@ async function fetchProfile(baseActor, context, include, retry = false) { module.exports = { fetchLatest, fetchProfile, + fetchUpcoming, scrapeAll, scrapeScene, };