Passing context object with site or network instead of scraper slug and 'site or network' to all profile scrapers.
This commit is contained in:
@@ -10,7 +10,7 @@ const {
|
||||
fetchApiProfile,
|
||||
scrapeAll,
|
||||
} = require('./gamma');
|
||||
const { get } = require('../utils/q');
|
||||
const { get } = require('../utils/qu');
|
||||
const slugify = require('../utils/slugify');
|
||||
|
||||
function extractLowArtActors(release) {
|
||||
@@ -57,10 +57,19 @@ function getActorReleasesUrl(actorPath, page = 1) {
|
||||
return `https://www.peternorth.com/en/videos/All-Categories/0${actorPath}/All-Dvds/0/latest/${page}`;
|
||||
}
|
||||
|
||||
async function fetchClassicProfile(actorName, siteSlug) {
|
||||
function scrapeClassicProfile({ qu, html }, site) {
|
||||
const profile = {};
|
||||
|
||||
profile.avatar = qu.img('.actorPicture');
|
||||
profile.releases = scrapeAll(html, null, site.url, false);
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
async function fetchClassicProfile(actorName, { site }) {
|
||||
const actorSlug = slugify(actorName);
|
||||
|
||||
const url = `https://${siteSlug}.com/en/pornstars`;
|
||||
const url = `${site.url}/en/pornstars`;
|
||||
const pornstarsRes = await get(url);
|
||||
|
||||
if (!pornstarsRes.ok) return null;
|
||||
@@ -70,41 +79,23 @@ async function fetchClassicProfile(actorName, siteSlug) {
|
||||
?.value;
|
||||
|
||||
if (actorPath) {
|
||||
const actorUrl = `https://${siteSlug}.com${actorPath}`;
|
||||
const actorUrl = `${site.url}${actorPath}`;
|
||||
const res = await get(actorUrl);
|
||||
|
||||
if (res.ok) {
|
||||
const releases = scrapeAll(res.item, null, `https://www.${siteSlug}.com`, false);
|
||||
|
||||
return { releases };
|
||||
return scrapeClassicProfile(res.item, site);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
async function networkFetchProfile(actorName, scraperSlug, site, include) {
|
||||
// not all Fame Digital sites offer Gamma actors
|
||||
const [devils, rocco, peter, silvia] = await Promise.all([
|
||||
fetchApiProfile(actorName, 'devilsfilm', true),
|
||||
fetchApiProfile(actorName, 'roccosiffredi'),
|
||||
include.scenes ? fetchProfile(actorName, 'peternorth', true, getActorReleasesUrl, include) : [],
|
||||
include.scenes ? fetchClassicProfile(actorName, 'silviasaint') : [],
|
||||
include.scenes ? fetchClassicProfile(actorName, 'silverstonedvd') : [],
|
||||
]);
|
||||
async function networkFetchProfile(actorName, context, include) {
|
||||
const profile = await ((context.site.parameters.api && fetchApiProfile(actorName, context, include))
|
||||
|| (context.site.parameters.classic && include.scenes && fetchClassicProfile(actorName, context, include)) // classic profiles only have scenes, no bio
|
||||
|| fetchProfile(actorName, context, true, getActorReleasesUrl, include));
|
||||
|
||||
if (devils || rocco || peter) {
|
||||
const releases = [].concat(devils?.releases || [], rocco?.releases || [], peter?.releases || [], silvia?.releases || []);
|
||||
|
||||
return {
|
||||
...peter,
|
||||
...rocco,
|
||||
...devils,
|
||||
releases,
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
return profile;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user