2019-04-04 02:00:28 +00:00
|
|
|
'use strict';
|
|
|
|
|
2019-04-07 03:19:44 +00:00
|
|
|
/* eslint-disable newline-per-chained-call */
|
2019-04-04 02:00:28 +00:00
|
|
|
const cheerio = require('cheerio');
|
|
|
|
const moment = require('moment');
|
|
|
|
|
2020-02-23 23:31:36 +00:00
|
|
|
const { get, geta } = require('../utils/q');
|
|
|
|
const slugify = require('../utils/slugify');
|
2020-11-22 23:05:02 +00:00
|
|
|
const http = require('../utils/http');
|
2020-02-23 23:31:36 +00:00
|
|
|
|
2019-11-16 02:33:36 +00:00
|
|
|
async function getPhotos(entryId, site) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const { hostname } = new URL(site.url);
|
2019-11-13 23:00:29 +00:00
|
|
|
|
2020-11-22 23:05:02 +00:00
|
|
|
const res = await http.get(`https://${hostname}/gallery.php?type=highres&id=${entryId}`);
|
2020-05-14 02:26:05 +00:00
|
|
|
const html = res.body.toString();
|
2019-11-05 00:41:13 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const $ = cheerio.load(html, { normalizeWhitespace: true });
|
|
|
|
const photos = $('a.fakethumb').map((photoIndex, photoElement) => $(photoElement).attr('data-src') || $(photoElement).attr('href')).toArray();
|
2019-11-05 00:41:13 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return photos;
|
2019-11-05 00:41:13 +00:00
|
|
|
}
|
|
|
|
|
2019-04-04 02:00:28 +00:00
|
|
|
function scrapeLatest(html, site) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const $ = cheerio.load(html, { normalizeWhitespace: true });
|
|
|
|
const sceneElements = $('.content-wrapper .scene').toArray();
|
|
|
|
|
|
|
|
return sceneElements.map((element) => {
|
|
|
|
const sceneLinkElement = $(element).find('h3 a');
|
|
|
|
const thumbnailElement = $(element).find('a img');
|
|
|
|
|
|
|
|
const url = sceneLinkElement.attr('href');
|
|
|
|
// const title = sceneLinkElement.text();
|
|
|
|
const entryId = url.split('/').slice(-1)[0];
|
|
|
|
|
|
|
|
const titleText = thumbnailElement.attr('alt');
|
|
|
|
const title = titleText.slice(titleText.indexOf(':') + 1).trim();
|
|
|
|
|
|
|
|
const date = moment.utc($(element).find('.scene-date'), ['MM/DD/YYYY', 'YYYY-MM-DD']).toDate();
|
|
|
|
|
|
|
|
const actors = $(element).find('.scene-models a').map((actorIndex, actorElement) => $(actorElement).text()).toArray();
|
|
|
|
const likes = Number($(element).find('.scene-votes').text());
|
|
|
|
|
|
|
|
const photoCount = Number(thumbnailElement.attr('thumbs_num'));
|
|
|
|
const poster = thumbnailElement.attr('src');
|
|
|
|
const photos = Array.from({ length: photoCount }, (val, index) => thumbnailElement.attr(`src${index + 1}`));
|
|
|
|
|
|
|
|
const scene = {
|
|
|
|
url,
|
|
|
|
entryId,
|
|
|
|
title,
|
|
|
|
actors,
|
|
|
|
date,
|
|
|
|
poster,
|
|
|
|
photos,
|
|
|
|
rating: {
|
|
|
|
likes,
|
|
|
|
},
|
|
|
|
site,
|
|
|
|
};
|
|
|
|
|
|
|
|
return scene;
|
|
|
|
});
|
2019-04-04 02:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function scrapeScene(html, url, site) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const $ = cheerio.load(html, { normalizeWhitespace: true });
|
|
|
|
const release = { url };
|
2020-02-08 03:52:32 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
[release.entryId] = url.split('/').slice(-1);
|
|
|
|
release.title = $('.video-wrapper meta[itemprop="name"]').attr('content');
|
|
|
|
release.description = $('.video-wrapper meta[itemprop="description"]').attr('content');
|
2019-04-04 02:00:28 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.date = moment.utc($('.video-wrapper meta[itemprop="uploadDate"]').attr('content'), 'MM/DD/YYYY').toDate();
|
|
|
|
release.actors = $('.content-wrapper .scene-models-list a').map((actorIndex, actorElement) => $(actorElement).text()).toArray();
|
2019-04-04 02:00:28 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const timestamp = $('.video-wrapper meta[itemprop="duration"]').attr('content');
|
2020-02-08 03:52:32 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (timestamp) {
|
|
|
|
const [minutes, seconds] = timestamp.match(/\d+/g);
|
|
|
|
release.duration = Number(minutes) * 60 + Number(seconds);
|
|
|
|
}
|
2019-04-04 02:00:28 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.tags = $('.content-desc .scene-tags a').map((tagIndex, tagElement) => $(tagElement).text()).toArray();
|
|
|
|
release.likes = Number($('.content-desc #social-actions #likes').text());
|
2019-04-04 02:00:28 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const posterScript = $('script:contains(poster)').html();
|
|
|
|
const posterLink = posterScript?.slice(posterScript.indexOf('https://'), posterScript.indexOf('.jpg') + 4);
|
|
|
|
release.poster = $('meta[property="og:image"]').attr('content') || posterLink || $('#trailer_player_finished img').attr('src');
|
2020-02-08 03:52:32 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const trailer = $('meta[property="og:video"]').attr('content') || $('#videojs-trailer source').attr('src');
|
2020-03-02 02:41:41 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (trailer) release.trailer = { src: trailer };
|
2019-11-13 23:00:29 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.photos = await getPhotos(release.entryId, site);
|
|
|
|
release.movie = $('a[data-track="FULL MOVIE"]').attr('href');
|
2020-02-08 03:52:32 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const siteElement = $('.content-wrapper .logos-sites a');
|
|
|
|
if (siteElement) release.channel = slugify(siteElement.text(), '');
|
2020-02-08 03:52:32 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return release;
|
2019-04-04 02:00:28 +00:00
|
|
|
}
|
|
|
|
|
2020-02-23 23:31:36 +00:00
|
|
|
function scrapeProfile({ html, q, qa, qtx }) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const profile = {};
|
2020-02-23 23:31:36 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const bio = qa('.model-facts li:not(.model-facts-long)', true).reduce((acc, fact) => {
|
|
|
|
const [key, value] = fact.split(':');
|
|
|
|
const trimmedValue = value.trim();
|
2020-02-23 23:31:36 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (trimmedValue.length === 0 || trimmedValue === '-') return acc;
|
|
|
|
return { ...acc, [slugify(key, '_')]: trimmedValue };
|
|
|
|
}, {});
|
2020-02-23 23:31:36 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const description = q('.model-facts-long', true);
|
|
|
|
if (description) profile.description = description;
|
2020-02-23 23:31:36 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const aliases = qtx('.aka')?.split(/,\s*/);
|
|
|
|
if (aliases) profile.aliases = aliases;
|
2020-02-23 23:31:36 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.birth_place) profile.birthPlace = bio.birth_place;
|
|
|
|
if (bio.nationality) profile.nationality = bio.nationality;
|
2020-02-23 23:31:36 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.measurements) {
|
|
|
|
const [bust, waist, hip] = bio.measurements.split('-');
|
2020-02-23 23:31:36 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bust) profile.bust = bust;
|
|
|
|
if (waist) profile.waist = Number(waist);
|
|
|
|
if (hip) profile.hip = Number(hip);
|
|
|
|
}
|
2020-02-23 23:31:36 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.weight) profile.weight = Number(bio.weight.match(/^\d+/)[0]);
|
|
|
|
if (bio.height) profile.height = Number(bio.height.match(/^\d+/)[0]);
|
2020-02-23 23:31:36 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.hair_color) profile.hair = bio.hair_color;
|
|
|
|
if (bio.eye_color) profile.eye = bio.eye_color;
|
2020-02-23 23:31:36 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.tattoos) {
|
|
|
|
profile.hasTattoos = true;
|
|
|
|
profile.tattoos = bio.tattoos;
|
|
|
|
}
|
2020-02-23 23:31:36 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.tattoos) {
|
|
|
|
profile.hasTattoos = true;
|
|
|
|
profile.tattoos = bio.tattoos;
|
|
|
|
}
|
2020-02-23 23:31:36 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.piercings) {
|
|
|
|
profile.hasPiercings = true;
|
|
|
|
profile.piercings = bio.piercings;
|
|
|
|
}
|
2020-02-23 23:31:36 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
profile.avatar = q('.img-pornstar img').dataset.src;
|
|
|
|
profile.releases = scrapeLatest(html);
|
2020-02-23 23:31:36 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return profile;
|
2020-02-23 23:31:36 +00:00
|
|
|
}
|
|
|
|
|
2019-04-05 01:45:40 +00:00
|
|
|
async function fetchLatest(site, page = 1) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const { hostname } = new URL(site.url);
|
2019-11-13 23:00:29 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (hostname.match('private.com')) {
|
2020-11-22 23:05:02 +00:00
|
|
|
const res = await http.get(`${site.url}/${page}/`);
|
2019-11-13 23:00:29 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return scrapeLatest(res.body.toString(), site);
|
|
|
|
}
|
2019-11-13 23:00:29 +00:00
|
|
|
|
2020-11-22 23:05:02 +00:00
|
|
|
const res = await http.get(`${site.url}/scenes/${page}/`);
|
2019-04-04 02:00:28 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return scrapeLatest(res.body.toString(), site);
|
2019-04-04 02:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function fetchScene(url, site) {
|
2020-11-22 23:05:02 +00:00
|
|
|
const res = await http.get(url);
|
2019-04-04 02:00:28 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return scrapeScene(res.body.toString(), url, site);
|
2019-04-04 02:00:28 +00:00
|
|
|
}
|
|
|
|
|
2020-07-20 23:44:51 +00:00
|
|
|
async function fetchProfile({ name: actorName }) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const actorSearchSlug = slugify(actorName, '+');
|
|
|
|
const url = `https://www.private.com/search.php?query=${actorSearchSlug}`;
|
|
|
|
const modelRes = await geta(url, '.model h3 a');
|
2020-02-23 23:31:36 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (modelRes.ok) {
|
|
|
|
const actorSlug = slugify(actorName);
|
|
|
|
const model = modelRes.items.find(({ text }) => slugify(text) === actorSlug);
|
2020-02-23 23:31:36 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (model) {
|
|
|
|
const res = await get(model.el.href);
|
2020-02-23 23:31:36 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return res.ok ? scrapeProfile(res.item) : res.status;
|
|
|
|
}
|
|
|
|
}
|
2020-02-23 23:31:36 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return null;
|
2020-02-23 23:31:36 +00:00
|
|
|
}
|
|
|
|
|
2019-04-04 02:00:28 +00:00
|
|
|
module.exports = {
|
2020-05-14 02:26:05 +00:00
|
|
|
fetchLatest,
|
|
|
|
fetchScene,
|
|
|
|
fetchProfile,
|
2019-04-04 02:00:28 +00:00
|
|
|
};
|