2020-02-12 00:54:54 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const { get, geta, ctxa } = require('../utils/q');
|
|
|
|
|
|
|
|
function extractActors(actorString) {
|
2020-05-14 02:26:05 +00:00
|
|
|
return actorString
|
2021-02-21 21:58:46 +00:00
|
|
|
?.replace(/.*:|\(.*\)|\d+(-|\s)year(-|\s)old|nurses?|tangled/ig, '') // remove Patient:, (date) and other nonsense
|
|
|
|
.split(/\band\b|\bvs\b|\/|,|&/ig)
|
|
|
|
.map(actor => actor.trim())
|
|
|
|
.filter(actor => !!actor && !/\banal\b|\bschool\b|\bgamer\b|\breturn\b|\bfor\b|\bare\b|\bpart\b|realdoll|bimbo|p\d+/ig.test(actor))
|
2020-02-12 00:54:54 +00:00
|
|
|
|| [];
|
|
|
|
}
|
|
|
|
|
|
|
|
function matchActors(actorString, models) {
|
2020-08-14 21:05:25 +00:00
|
|
|
if (!actorString) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
return models.filter(model => new RegExp(model.name, 'i').test(actorString));
|
2020-02-12 00:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function scrapeLatest(scenes, site, models) {
|
2020-05-14 02:26:05 +00:00
|
|
|
return scenes.map(({ qu }) => {
|
|
|
|
const release = {};
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const pathname = qu.url('a.itemimg').slice(1);
|
|
|
|
[release.entryId] = pathname.split('/').slice(-1);
|
|
|
|
release.url = `${site.url}${pathname}`;
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.title = qu.q('.itemimg img', 'alt') || qu.q('h4 a', true);
|
|
|
|
release.description = qu.q('.mas_longdescription', true);
|
|
|
|
release.date = qu.date('.movie_info2', 'MM/DD/YY', /\d{2}\/\d{2}\/\d{2}/);
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const actorString = qu.q('.mas_description', true);
|
|
|
|
const actors = matchActors(actorString, models);
|
2020-09-17 12:49:45 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (actors.length > 0) release.actors = actors;
|
|
|
|
else release.actors = extractActors(actorString);
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const posterPath = qu.img('.itemimg img');
|
|
|
|
release.poster = `${site.url}/${posterPath}`;
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return release;
|
|
|
|
});
|
2020-02-12 00:54:54 +00:00
|
|
|
}
|
|
|
|
|
2020-07-17 21:27:59 +00:00
|
|
|
function scrapeScene({ html, qu }, url, site, include, models) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const release = { url };
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
[release.entryId] = url.split('/').slice(-1);
|
|
|
|
release.title = qu.q('.mas_title', true);
|
|
|
|
release.description = qu.q('.mas_longdescription', true);
|
|
|
|
release.date = qu.date('.mas_description', 'MMMM DD, YYYY', /\w+ \d{1,2}, \d{4}/);
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-09-17 12:49:45 +00:00
|
|
|
if (models) {
|
|
|
|
const actorString = qu.q('.mas_description', true).replace(/\w+ \d{1,2}, \d{4}/, '');
|
|
|
|
const actors = matchActors(actorString, models);
|
|
|
|
if (actors.length > 0) release.actors = actors;
|
|
|
|
else release.actors = extractActors(actorString);
|
|
|
|
}
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.tags = qu.all('.tags a', true);
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.photos = qu.imgs('.stills img').map(photoPath => `${site.url}/${photoPath}`);
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const posterIndex = 'splash:';
|
|
|
|
const poster = html.slice(html.indexOf('faceimages/', posterIndex), html.indexOf('.jpg', posterIndex) + 4);
|
|
|
|
if (poster) release.poster = `${site.url}/${poster}`;
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const trailerIndex = html.indexOf('video/mp4');
|
|
|
|
const trailer = html.slice(html.indexOf('/content', trailerIndex), html.indexOf('.mp4', trailerIndex) + 4);
|
|
|
|
if (trailer) release.trailer = { src: `${site.url}${trailer}` };
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return release;
|
2020-02-12 00:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function extractModels({ el }, site) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const models = ctxa(el, '.item');
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return models.map(({ qu }) => {
|
|
|
|
const actor = { gender: 'female' };
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const avatar = qu.q('.itemimg img');
|
|
|
|
actor.avatar = `${site.url}/${avatar.src}`;
|
|
|
|
actor.name = avatar.alt
|
|
|
|
.split(':').slice(-1)[0]
|
|
|
|
.replace(/xtreme girl|nurse/ig, '')
|
|
|
|
.trim();
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const actorPath = qu.url('.itemimg');
|
|
|
|
actor.url = `${site.url}${actorPath.slice(1)}`;
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return actor;
|
|
|
|
});
|
2020-02-12 00:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function fetchModels(site, page = 1, accModels = []) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const url = `${site.url}/?models/${page}`;
|
|
|
|
const res = await get(url);
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (res.ok) {
|
|
|
|
const models = extractModels(res.item, site);
|
|
|
|
const nextPage = res.item.qa('.pagenumbers', true)
|
|
|
|
.map(pageX => Number(pageX))
|
|
|
|
.filter(Boolean) // remove << and >>
|
|
|
|
.includes(page + 1);
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (nextPage) {
|
|
|
|
return fetchModels(site, page + 1, accModels.concat(models));
|
|
|
|
}
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return accModels.concat(models, { name: 'Dr. Gray' });
|
|
|
|
}
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return [];
|
2020-02-12 00:54:54 +00:00
|
|
|
}
|
|
|
|
|
2020-09-17 12:49:45 +00:00
|
|
|
async function fetchLatest(site, page = 1, include, { beforeFetchLatest }) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const url = `${site.url}/show.php?a=${site.parameters.a}_${page}`;
|
|
|
|
const res = await geta(url, '.item');
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-09-17 12:49:45 +00:00
|
|
|
return res.ok ? scrapeLatest(res.items, site, beforeFetchLatest) : res.status;
|
2020-02-12 00:54:54 +00:00
|
|
|
}
|
|
|
|
|
2020-09-17 12:49:45 +00:00
|
|
|
async function fetchScene(url, site, release, include, beforeFetchLatest) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const models = beforeFetchLatest || await fetchModels(site);
|
|
|
|
const res = await get(url);
|
2020-02-12 00:54:54 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return res.ok ? scrapeScene(res.item, url, site, models) : res.status;
|
2020-02-12 00:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
2020-05-14 02:26:05 +00:00
|
|
|
fetchLatest,
|
|
|
|
fetchScene,
|
|
|
|
beforeFetchLatest: fetchModels,
|
2020-02-12 00:54:54 +00:00
|
|
|
};
|