2020-02-13 02:44:04 +00:00
|
|
|
'use strict';
|
|
|
|
|
2020-02-13 03:11:32 +00:00
|
|
|
const { get, geta, ctxa, ed } = require('../utils/q');
|
2020-02-13 02:44:04 +00:00
|
|
|
const slugify = require('../utils/slugify');
|
|
|
|
|
|
|
|
function scrapeAll(scenes, site) {
|
2020-03-09 01:02:29 +00:00
|
|
|
return scenes.map(({ qu }) => {
|
|
|
|
const url = qu.url('.text-thumb a');
|
2020-02-13 02:44:04 +00:00
|
|
|
const { pathname } = new URL(url);
|
2020-03-09 01:02:29 +00:00
|
|
|
const channelUrl = qu.url('.badge');
|
2020-02-13 02:44:04 +00:00
|
|
|
|
2020-03-09 01:02:29 +00:00
|
|
|
if (site?.parameters?.extract && qu.q('.badge', true) !== site.name) {
|
2020-02-13 02:44:04 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const release = {};
|
|
|
|
|
|
|
|
release.url = channelUrl ? `${channelUrl}${pathname}` : url;
|
|
|
|
release.entryId = pathname.match(/\/\d+/)[0].slice(1);
|
2020-03-09 01:02:29 +00:00
|
|
|
release.title = qu.q('.text-thumb a', true);
|
2020-02-13 02:44:04 +00:00
|
|
|
|
2020-03-09 01:02:29 +00:00
|
|
|
release.date = qu.date('.date', 'YYYY-MM-DD', /\d{4}-\d{2}-\d{2}/);
|
|
|
|
release.duration = qu.dur('.date', /(\d{2}:)?\d{2}:\d{2}/);
|
2020-02-13 02:44:04 +00:00
|
|
|
|
2020-03-09 01:02:29 +00:00
|
|
|
release.actors = qu.all('.category a', true);
|
2020-02-13 02:44:04 +00:00
|
|
|
|
2020-03-09 01:02:29 +00:00
|
|
|
release.poster = qu.img('img.video_placeholder, .video-images img');
|
|
|
|
release.teaser = { src: qu.trailer() };
|
2020-02-13 02:44:04 +00:00
|
|
|
|
|
|
|
return release;
|
|
|
|
}).filter(Boolean);
|
|
|
|
}
|
|
|
|
|
|
|
|
function scrapeScene({ q, qd, qa }, url, _site, baseRelease) {
|
|
|
|
const release = { url };
|
|
|
|
|
|
|
|
const { pathname } = new URL(url);
|
|
|
|
release.entryId = pathname.match(/\/\d+/)[0].slice(1);
|
|
|
|
|
|
|
|
release.title = q('.trailer-block_title', true);
|
|
|
|
release.description = q('.info-block:nth-child(3) .text', true);
|
|
|
|
release.date = qd('.info-block_data .text', 'MMMM D, YYYY', /\w+ \d{1,2}, \d{4}/);
|
|
|
|
|
|
|
|
const duration = baseRelease?.duration || Number(q('.info-block_data .text', true).match(/(\d+)\s+min/)?.[1]) * 60;
|
|
|
|
if (duration) release.duration = duration;
|
|
|
|
|
|
|
|
release.actors = qa('.info-block_data a[href*="/models"]', true);
|
|
|
|
release.tags = qa('.info-block a[href*="/categories"]', true);
|
|
|
|
|
|
|
|
const posterEl = q('.update_thumb');
|
|
|
|
const poster = posterEl.getAttribute('src0_3x') || posterEl.getAttribute('src0_2x') || posterEl.dataset.src;
|
|
|
|
|
|
|
|
if (poster && baseRelease?.poster) release.photos = [poster];
|
|
|
|
else if (poster) release.poster = poster;
|
|
|
|
|
|
|
|
return release;
|
|
|
|
}
|
|
|
|
|
|
|
|
function scrapeProfile({ q, qa, qtx }) {
|
|
|
|
const profile = {};
|
|
|
|
|
|
|
|
const keys = qa('.model-descr_line:not(.model-descr_rait) p.text span', true);
|
|
|
|
const values = qa('.model-descr_line:not(.model-descr_rait) p.text').map(el => qtx(el));
|
2020-03-16 03:10:52 +00:00
|
|
|
const bio = keys.reduce((acc, key, index) => ({ ...acc, [slugify(key, '_')]: values[index] }), {});
|
2020-02-13 02:44:04 +00:00
|
|
|
|
|
|
|
if (bio.height) profile.height = Number(bio.height.match(/\((\d+)cm\)/)[1]);
|
|
|
|
if (bio.weight) profile.weight = Number(bio.weight.match(/\((\d+)kg\)/)[1]);
|
|
|
|
if (bio.race) profile.ethnicity = bio.race;
|
|
|
|
|
2020-02-13 03:11:32 +00:00
|
|
|
if (bio.date_of_birth) profile.birthdate = ed(bio.date_of_birth, 'MMMM D, YYYY');
|
2020-02-13 02:44:04 +00:00
|
|
|
if (bio.birthplace) profile.birthPlace = bio.birthplace;
|
|
|
|
|
|
|
|
if (bio.measurements) {
|
|
|
|
const [bust, waist, hip] = bio.measurements.split('-');
|
|
|
|
if (!/\?/.test(bust)) profile.bust = bust;
|
|
|
|
if (!/\?/.test(waist)) profile.waist = waist;
|
|
|
|
if (!/\?/.test(hip)) profile.hip = hip;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bio.hair) profile.hair = bio.hair;
|
|
|
|
if (bio.eyes) profile.eyes = bio.eyes;
|
|
|
|
|
|
|
|
if (/various/i.test(bio.tattoos)) profile.hasTattoos = true;
|
|
|
|
else if (/none/i.test(bio.tattoos)) profile.hasTattoos = false;
|
|
|
|
else if (bio.tattoos) {
|
|
|
|
profile.hasTattoos = true;
|
|
|
|
profile.tattoos = bio.tattoos;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (/various/i.test(bio.piercings)) profile.hasPiercings = true;
|
|
|
|
else if (/none/i.test(bio.piercings)) profile.hasPiercings = false;
|
|
|
|
else if (bio.piercings) {
|
|
|
|
profile.hasPiercings = true;
|
|
|
|
profile.piercings = bio.piercings;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bio.aliases) profile.aliases = bio.aliases.split(',').map(alias => alias.trim());
|
|
|
|
|
|
|
|
const avatar = q('.model-img img');
|
|
|
|
profile.avatar = avatar.getAttribute('src0_3x') || avatar.getAttribute('src0_2x') || avatar.dataset.src;
|
|
|
|
|
|
|
|
const releases = qa('.video-thumb');
|
|
|
|
profile.releases = scrapeAll(ctxa(releases));
|
|
|
|
|
|
|
|
return profile;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function fetchLatest(site, page = 1) {
|
|
|
|
const url = site.parameters?.extract
|
|
|
|
? `https://cherrypimps.com/categories/movies_${page}.html`
|
|
|
|
: `${site.url}/categories/movies_${page}.html`;
|
2020-03-08 03:23:10 +00:00
|
|
|
const res = await geta(url, 'div.video-thumb');
|
2020-02-13 02:44:04 +00:00
|
|
|
|
2020-03-08 03:23:10 +00:00
|
|
|
return res.ok ? scrapeAll(res.items, site) : res.status;
|
2020-02-13 02:44:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function fetchScene(url, site, release) {
|
2020-03-08 03:23:10 +00:00
|
|
|
const res = await get(url);
|
2020-02-13 02:44:04 +00:00
|
|
|
|
2020-03-08 03:23:10 +00:00
|
|
|
return res.ok ? scrapeScene(res.item, url, site, release) : res.status;
|
2020-02-13 02:44:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function fetchProfile(actorName, scraperSlug) {
|
|
|
|
const actorSlug = slugify(actorName);
|
2020-03-16 03:10:52 +00:00
|
|
|
const actorSlug2 = slugify(actorName, '');
|
2020-02-13 02:44:04 +00:00
|
|
|
|
|
|
|
const [url, url2] = ['cherrypimps', 'wildoncam'].includes(scraperSlug)
|
|
|
|
? [`https://${scraperSlug}.com/models/${actorSlug}.html`, `https://${scraperSlug}.com/models/${actorSlug2}.html`]
|
|
|
|
: [`https://${scraperSlug.replace('xxx', '')}.xxx/models/${actorSlug}.html`, `https://${scraperSlug.replace('xxx', '')}.xxx/models/${actorSlug2}.html`];
|
|
|
|
|
2020-03-08 03:23:10 +00:00
|
|
|
const res = await get(url);
|
|
|
|
if (res.ok) return scrapeProfile(res.item);
|
2020-02-13 02:44:04 +00:00
|
|
|
|
2020-03-08 03:23:10 +00:00
|
|
|
const res2 = await get(url2);
|
|
|
|
return res2.ok ? scrapeProfile(res2.item) : res2.status;
|
2020-02-13 02:44:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
fetchLatest,
|
|
|
|
fetchScene,
|
|
|
|
fetchProfile,
|
|
|
|
};
|