From 2fef4b4314f36e365513b06d318131dd097e985f Mon Sep 17 00:00:00 2001 From: Niels Simenon Date: Fri, 31 Jan 2020 00:39:49 +0100 Subject: [PATCH] Fetching and returning releases for Evil Angel actors. --- src/scrapers/evilangel.js | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/scrapers/evilangel.js b/src/scrapers/evilangel.js index 7d6b0e06..e58794b3 100644 --- a/src/scrapers/evilangel.js +++ b/src/scrapers/evilangel.js @@ -102,7 +102,7 @@ async function scrapeScene(html, url, site) { }; } -function scrapeActor(data) { +function scrapeActor(data, releases) { const actor = {}; if (data.male === 1) actor.gender = 'male'; @@ -118,6 +118,8 @@ function scrapeActor(data) { const avatarPath = Object.values(data.pictures).reverse()[0]; actor.avatar = `https://images01-evilangel.gammacdn.com/actors${avatarPath}`; + actor.releases = releases.map(release => `https://evilangel.com/en/video/${release.url_title}/${release.clip_id}`); + return actor; } @@ -172,6 +174,28 @@ async function fetchScene(url, site) { return scrapeScene(res.body.toString(), url, site); } +async function fetchActorScenes(actorName, apiUrl) { + const res = await bhttp.post(apiUrl, { + requests: [ + { + indexName: 'all_scenes', + params: `query=&hitsPerPage=36&maxValuesPerFacet=100&page=0&facetFilters=[["lesbian:"],["bisex:"],["shemale:"],["actors.name:${actorName}"]]`, + }, + ], + }, { + headers: { + Referer: 'https://www.evilangel.com/en/videos', + }, + encodeJSON: true, + }); + + if (res.statusCode === 200 && res.body.results[0].hits.length > 0) { + return res.body.results[0].hits; + } + + return []; +} + async function fetchProfile(actorName) { const { apiUrl } = await fetchApiCredentials(); const actorSlug = encodeURI(actorName); @@ -194,7 +218,9 @@ async function fetchProfile(actorName) { const actorData = res.body.results[0].hits.find(actor => actor.name === actorName); if (actorData) { - return scrapeActor(actorData); + const actorScenes = await fetchActorScenes(actorName, apiUrl); + + return scrapeActor(actorData, actorScenes); } }