2020-02-06 22:15:28 +00:00
|
|
|
'use strict';
|
|
|
|
|
2020-02-07 02:40:11 +00:00
|
|
|
const {
|
2020-05-14 02:26:05 +00:00
|
|
|
fetchLatest,
|
|
|
|
fetchApiLatest,
|
|
|
|
fetchUpcoming,
|
|
|
|
fetchApiUpcoming,
|
|
|
|
fetchScene,
|
|
|
|
fetchProfile,
|
|
|
|
fetchApiProfile,
|
|
|
|
scrapeAll,
|
2020-02-07 02:40:11 +00:00
|
|
|
} = require('./gamma');
|
2021-02-02 23:46:59 +00:00
|
|
|
|
2020-05-18 01:22:03 +00:00
|
|
|
const { get } = require('../utils/qu');
|
2020-02-07 02:40:11 +00:00
|
|
|
const slugify = require('../utils/slugify');
|
2020-02-06 22:15:28 +00:00
|
|
|
|
|
|
|
function extractLowArtActors(release) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const actors = release.title
|
|
|
|
.replace(/solo/i, '')
|
|
|
|
.split(/,|\band\b/ig)
|
|
|
|
.map(actor => actor.trim());
|
|
|
|
|
|
|
|
return {
|
|
|
|
...release,
|
|
|
|
actors,
|
|
|
|
};
|
2020-02-06 22:15:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function networkFetchLatest(site, page = 1) {
|
2020-05-14 02:26:05 +00:00
|
|
|
if (site.parameters?.api) return fetchApiLatest(site, page, false);
|
2020-02-06 22:15:28 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const releases = await fetchLatest(site, page);
|
2020-02-06 22:15:28 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (site.slug === 'lowartfilms') {
|
|
|
|
return releases.map(release => extractLowArtActors(release));
|
|
|
|
}
|
2020-02-06 22:15:28 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return releases;
|
2020-02-06 22:15:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function networkFetchScene(url, site) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const release = await fetchScene(url, site);
|
2020-02-06 22:15:28 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (site.slug === 'lowartfilms') {
|
|
|
|
return extractLowArtActors(release);
|
|
|
|
}
|
2020-02-06 22:15:28 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return release;
|
2020-02-06 22:15:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function networkFetchUpcoming(site, page = 1) {
|
2020-05-14 02:26:05 +00:00
|
|
|
if (site.parameters?.api) return fetchApiUpcoming(site, page, true);
|
2020-02-06 22:15:28 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return fetchUpcoming(site, page);
|
2020-02-06 22:15:28 +00:00
|
|
|
}
|
|
|
|
|
2020-02-07 00:59:43 +00:00
|
|
|
function getActorReleasesUrl(actorPath, page = 1) {
|
2020-05-14 02:26:05 +00:00
|
|
|
return `https://www.peternorth.com/en/videos/All-Categories/0${actorPath}/All-Dvds/0/latest/${page}`;
|
2020-02-07 00:59:43 +00:00
|
|
|
}
|
|
|
|
|
2020-05-18 01:22:03 +00:00
|
|
|
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 }) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const actorSlug = slugify(actorName);
|
2020-02-07 02:40:11 +00:00
|
|
|
|
2020-05-18 01:22:03 +00:00
|
|
|
const url = `${site.url}/en/pornstars`;
|
2020-05-14 02:26:05 +00:00
|
|
|
const pornstarsRes = await get(url);
|
2020-02-07 02:40:11 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (!pornstarsRes.ok) return null;
|
2020-03-09 01:02:29 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const actorPath = pornstarsRes.item.qa('option[value*="/pornstar"]')
|
|
|
|
.find(el => slugify(el.textContent) === actorSlug)
|
2021-02-21 21:58:46 +00:00
|
|
|
?.value;
|
2020-02-07 02:40:11 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (actorPath) {
|
2020-05-18 01:22:03 +00:00
|
|
|
const actorUrl = `${site.url}${actorPath}`;
|
2020-05-14 02:26:05 +00:00
|
|
|
const res = await get(actorUrl);
|
2020-02-07 02:40:11 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (res.ok) {
|
2020-05-18 01:22:03 +00:00
|
|
|
return scrapeClassicProfile(res.item, site);
|
2020-05-14 02:26:05 +00:00
|
|
|
}
|
|
|
|
}
|
2020-02-07 02:40:11 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return null;
|
2020-02-07 02:40:11 +00:00
|
|
|
}
|
|
|
|
|
2020-07-20 23:44:51 +00:00
|
|
|
async function networkFetchProfile({ name: actorName }, context, include) {
|
2020-05-19 02:46:49 +00:00
|
|
|
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
|
2020-07-20 23:44:51 +00:00
|
|
|
|| fetchProfile({ name: actorName }, context, true, getActorReleasesUrl, include));
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-05-18 01:22:03 +00:00
|
|
|
return profile;
|
2020-02-06 22:15:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
2020-05-14 02:26:05 +00:00
|
|
|
fetchLatest: networkFetchLatest,
|
|
|
|
fetchProfile: networkFetchProfile,
|
|
|
|
fetchScene: networkFetchScene,
|
|
|
|
fetchUpcoming: networkFetchUpcoming,
|
2020-02-06 22:15:28 +00:00
|
|
|
};
|