2019-03-04 01:46:33 +00:00
|
|
|
'use strict';
|
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
const qu = require('../utils/qu');
|
|
|
|
const slugify = require('../utils/slugify');
|
|
|
|
const { feetInchesToCm, lbsToKg } = require('../utils/convert');
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-07-12 03:25:27 +00:00
|
|
|
function scrapeAll(scenes, entity) {
|
2020-07-12 03:10:23 +00:00
|
|
|
return scenes.map(({ query }) => {
|
|
|
|
const release = {};
|
2020-05-14 02:26:05 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
release.url = query.url('.videoPic a');
|
|
|
|
release.entryId = query.q('.videoPic img', 'id').match(/set-target-(\d+)/)[1];
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
release.title = query.q('h3 a', true);
|
|
|
|
release.description = query.q('.runtime + p', true);
|
2019-03-04 03:19:03 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
release.date = query.date('.date', 'MM-DD-YYYY');
|
|
|
|
release.duration = query.dur('.runtime');
|
|
|
|
|
|
|
|
release.actors = query.all('.tour_update_models a', true);
|
|
|
|
|
|
|
|
release.poster = query.img('.videoPic img');
|
2020-07-12 03:25:27 +00:00
|
|
|
release.entity = entity;
|
2020-07-12 03:10:23 +00:00
|
|
|
|
|
|
|
return release;
|
|
|
|
});
|
|
|
|
}
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
function scrapeScene({ query }) {
|
|
|
|
const release = {};
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
release.entryId = query.q('.trailerLeft img', 'id').match(/set-target-(\d+)/)[1];
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
release.title = query.q('.infoHeader h1', true);
|
|
|
|
release.description = query.q('.infoBox p', true);
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
release.actors = query.all('.tour_update_models a', true);
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
release.poster = query.img('.posterimg');
|
|
|
|
release.photos = query.imgs('.trailerSnaps img').slice(1); // first photo is poster in lower quality
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
const trailer = query.q('script')?.textContent.match(/\/trailers\/.+\.mp4/)?.[0];
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
if (trailer) {
|
|
|
|
release.trailer = {
|
|
|
|
src: `https://pervcity.com${trailer}`,
|
|
|
|
};
|
|
|
|
}
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return release;
|
2019-12-05 00:26:22 +00:00
|
|
|
}
|
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
function scrapeProfile({ query }) {
|
|
|
|
const profile = {};
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
const bio = query.all('.moreInfo li').reduce((acc, el) => ({
|
|
|
|
...acc,
|
|
|
|
[slugify(query.q(el, 'span', true), '_')]: query.text(el),
|
|
|
|
}), {});
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
profile.description = query.q('.aboutModel p', true);
|
|
|
|
profile.dateOfBirth = qu.extractDate(bio.date_of_birth, ['MMMM D, YYYY', 'DD-MMM-YY']);
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
profile.birthPlace = bio.birth_location;
|
|
|
|
profile.ethnicity = bio.ethnicity;
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
profile.height = feetInchesToCm(bio.height);
|
|
|
|
profile.weight = lbsToKg(bio.weight);
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
profile.eyes = bio.eye_color;
|
|
|
|
profile.hairColor = bio.hair_color;
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
profile.avatar = query.img('.starPic img');
|
|
|
|
profile.releases = scrapeAll(qu.initAll(query.all('.aboutScenes .videoBlock')));
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
return profile;
|
2019-12-05 00:26:22 +00:00
|
|
|
}
|
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
async function fetchLatest(channel, page = 1) {
|
2020-07-12 03:25:27 +00:00
|
|
|
if (channel.parameters?.siteId) {
|
|
|
|
const url = `https://pervcity.com/search.php?site[]=${channel.parameters.siteId}&page=${page}`;
|
|
|
|
const res = await qu.getAll(url, '.videoBlock');
|
2019-03-04 01:46:33 +00:00
|
|
|
|
2020-07-12 03:25:27 +00:00
|
|
|
return res.ok ? scrapeAll(res.items, channel) : res.status;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function fetchUpcoming(channel) {
|
|
|
|
const url = 'https://pervcity.com';
|
|
|
|
const res = await qu.getAll(url, '.upcoming .videoBlock');
|
|
|
|
|
|
|
|
return res.ok ? scrapeAll(res.items, channel.parent) : res.status;
|
2019-03-04 01:46:33 +00:00
|
|
|
}
|
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
async function fetchScene(url, entity) {
|
|
|
|
const res = await qu.get(url, '.trailerArea');
|
|
|
|
|
|
|
|
return res.ok ? scrapeScene(res.item, entity) : res.status;
|
|
|
|
}
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
async function fetchProfile(actorName) {
|
|
|
|
const url = `https://pervcity.com/models/${slugify(actorName)}.html`;
|
|
|
|
const res = await qu.get(url);
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
if (res.ok) {
|
|
|
|
return scrapeProfile(res.item);
|
|
|
|
}
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
const url2 = `https://pervcity.com/models/${slugify(actorName, '')}.html`;
|
|
|
|
const res2 = await qu.get(url2);
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
if (res2.ok) {
|
|
|
|
return scrapeProfile(res2.item);
|
2020-05-14 02:26:05 +00:00
|
|
|
}
|
2019-12-05 00:26:22 +00:00
|
|
|
|
2020-07-12 03:10:23 +00:00
|
|
|
return res2.status;
|
2019-12-05 00:26:22 +00:00
|
|
|
}
|
|
|
|
|
2019-03-23 21:48:39 +00:00
|
|
|
module.exports = {
|
2020-05-14 02:26:05 +00:00
|
|
|
fetchLatest,
|
|
|
|
fetchScene,
|
2020-07-12 03:10:23 +00:00
|
|
|
fetchProfile,
|
2020-07-12 03:25:27 +00:00
|
|
|
fetchUpcoming,
|
2019-03-23 21:48:39 +00:00
|
|
|
};
|