2020-03-05 01:47:52 +00:00
|
|
|
'use strict';
|
|
|
|
|
2020-03-05 02:44:27 +00:00
|
|
|
const util = require('util');
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-06-25 00:26:25 +00:00
|
|
|
const { get, geta, ed, formatDate, ctxa } = require('../utils/q');
|
2020-03-05 01:47:52 +00:00
|
|
|
const slugify = require('../utils/slugify');
|
2020-03-06 01:49:55 +00:00
|
|
|
const { feetInchesToCm } = require('../utils/convert');
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-03-05 19:31:11 +00:00
|
|
|
function deriveEntryId(release) {
|
2020-05-14 02:26:05 +00:00
|
|
|
if (release.date && release.title) {
|
2020-06-25 00:26:25 +00:00
|
|
|
return `${slugify(formatDate(release.date, 'YYYY-MM-DD'))}-${slugify(release.title)}`;
|
2020-05-14 02:26:05 +00:00
|
|
|
}
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return null;
|
2020-03-05 19:31:11 +00:00
|
|
|
}
|
|
|
|
|
2020-03-05 02:44:27 +00:00
|
|
|
function extractPoster(posterPath, site, baseRelease) {
|
2020-05-14 02:26:05 +00:00
|
|
|
if (posterPath && !/400.jpg/.test(posterPath)) {
|
|
|
|
const poster = `${site.parameters?.media || site.url}${posterPath}`;
|
|
|
|
const posterSources = [
|
|
|
|
poster,
|
|
|
|
// upscaled
|
|
|
|
poster.replace('-1x', '-2x'),
|
|
|
|
poster.replace('-1x', '-3x'),
|
|
|
|
];
|
|
|
|
|
|
|
|
if (baseRelease?.poster) {
|
|
|
|
return [posterSources, [baseRelease.poster]];
|
|
|
|
}
|
|
|
|
|
|
|
|
return [posterSources, []];
|
|
|
|
}
|
|
|
|
|
|
|
|
return [baseRelease?.poster || null, []];
|
2020-03-05 02:44:27 +00:00
|
|
|
}
|
|
|
|
|
2020-03-06 01:49:55 +00:00
|
|
|
function getImageWithFallbacks(q, selector, site, el) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const sources = el
|
|
|
|
? [
|
|
|
|
q(el, selector, 'src0_3x'),
|
|
|
|
q(el, selector, 'src0_2x'),
|
|
|
|
q(el, selector, 'src0_1x'),
|
|
|
|
]
|
|
|
|
: [
|
|
|
|
q(selector, 'src0_3x'),
|
|
|
|
q(selector, 'src0_2x'),
|
|
|
|
q(selector, 'src0_1x'),
|
|
|
|
];
|
|
|
|
|
|
|
|
return sources.filter(Boolean).map(src => `${site.parameters?.media || site.url}${src}`);
|
2020-03-06 01:49:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function scrapeAll(scenes, site) {
|
2020-05-14 02:26:05 +00:00
|
|
|
return scenes.map(({ qu }) => {
|
|
|
|
const release = {};
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.title = qu.q('h3 a', 'title') || qu.q('h3 a', true);
|
|
|
|
release.url = qu.url('h3 a');
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.date = qu.date('.modeldata p', 'YYYY-MM-DD', /\d{4}-\d{2}-\d{2}/);
|
|
|
|
release.duration = qu.dur('.modeldata p');
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (/bts|behind the scenes/i.test(release.title)) release.tags = ['behind the scenes'];
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.poster = getImageWithFallbacks(qu.q, '.modelimg img', site);
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
// release.entryId = q('.modelimg img', 'id').match(/set-target-(\d+)/)[1];
|
|
|
|
release.entryId = deriveEntryId(release);
|
2020-03-06 02:15:49 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return release;
|
|
|
|
});
|
2020-03-05 01:47:52 +00:00
|
|
|
}
|
|
|
|
|
2020-08-22 02:22:56 +00:00
|
|
|
function scrapeAllT1(scenes, site, accNetworkReleases) {
|
2020-05-14 02:26:05 +00:00
|
|
|
return scenes.map(({ qu }) => {
|
|
|
|
const release = {};
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.title = qu.q('h4 a', 'title') || qu.q('h4 a', true);
|
|
|
|
release.url = qu.url('h4 a');
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.date = qu.date('.more-info-div', 'MMM D, YYYY');
|
|
|
|
release.duration = qu.dur('.more-info-div');
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (/bts|behind the scenes/i.test(release.title)) release.tags = ['behind the scenes'];
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const posterPath = qu.q('.img-div img', 'src0_1x') || qu.img('img.video_placeholder');
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (posterPath) {
|
|
|
|
const poster = /^http/.test(posterPath) ? posterPath : `${site.parameters?.media || site.url}${posterPath}`;
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.poster = [
|
|
|
|
poster.replace('-1x', '-3x'),
|
|
|
|
poster.replace('-1x', '-2x'),
|
|
|
|
poster,
|
|
|
|
];
|
|
|
|
}
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
// release.entryId = q('.img-div img', 'id')?.match(/set-target-(\d+)/)[1];
|
|
|
|
release.entryId = deriveEntryId(release);
|
2020-03-05 19:31:11 +00:00
|
|
|
|
2020-08-22 02:22:56 +00:00
|
|
|
if (site.parameters?.accFilter && accNetworkReleases?.map(accRelease => accRelease.entryId).includes(release.entryId)) {
|
2020-06-15 01:58:35 +00:00
|
|
|
// filter out releases that were already scraped from a categorized site, requires sequential site scraping
|
2020-05-14 02:26:05 +00:00
|
|
|
return null;
|
|
|
|
}
|
2020-03-05 22:01:03 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return release;
|
|
|
|
}).filter(Boolean);
|
2020-03-05 19:31:11 +00:00
|
|
|
}
|
|
|
|
|
2020-03-06 01:49:55 +00:00
|
|
|
function scrapeAllTour(scenes) {
|
2020-05-14 02:26:05 +00:00
|
|
|
return scenes.map(({ qu }) => {
|
|
|
|
const release = {};
|
2020-03-05 19:31:11 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.title = qu.q('h4 a', true);
|
|
|
|
release.url = qu.url('a');
|
|
|
|
release.date = qu.date('.tour_update_models + span', 'YYYY-MM-DD');
|
2020-03-05 19:31:11 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.actors = qu.all('.tour_update_models a', true);
|
2020-03-05 19:31:11 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.poster = qu.img('a img');
|
2020-03-05 19:31:11 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.entryId = deriveEntryId(release);
|
2020-03-05 19:31:11 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return release;
|
|
|
|
});
|
2020-03-05 01:47:52 +00:00
|
|
|
}
|
|
|
|
|
2020-03-11 23:15:25 +00:00
|
|
|
function scrapeScene({ html, qu }, site, url, baseRelease) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const release = { url };
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.title = qu.q('.centerwrap h2', true);
|
|
|
|
release.description = qu.q('.videocontent p', true);
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-06-25 00:26:25 +00:00
|
|
|
release.date = qu.date('.videodetails .date', ['MM/DD/YYYY', 'YYYY-MM-DD']);
|
2020-05-14 02:26:05 +00:00
|
|
|
release.duration = qu.dur('.videodetails .date');
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.actors = qu.all('.modelname a', true);
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const posterPath = html.match(/poster="([\w-/.]+)"/)?.[1];
|
|
|
|
[release.poster, release.photos] = extractPoster(posterPath, site, baseRelease);
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const trailerPath = html.match(/\/trailers\/.*.mp4/);
|
|
|
|
if (trailerPath) release.trailer = { src: `${site.parameters?.media || site.url}${trailerPath}` };
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const stars = qu.q('.modelrates + p', true).match(/\d.\d/)?.[0];
|
|
|
|
if (stars) release.stars = Number(stars);
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
// release.entryId = html.match(/set-target-(\d+)/)[1];
|
|
|
|
release.entryId = deriveEntryId(release);
|
2020-03-06 02:15:49 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return release;
|
2020-03-05 01:47:52 +00:00
|
|
|
}
|
|
|
|
|
2020-08-23 01:31:37 +00:00
|
|
|
function scrapeSceneT1({ html, qu }, site, url, baseRelease) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const release = { url };
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.title = qu.q('.trailer-section-head .section-title', true);
|
|
|
|
release.description = qu.text('.row .update-info-block');
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.date = qu.date('.update-info-row', 'MMM D, YYYY', /\w+ \d{1,2}, \d{4}/);
|
|
|
|
release.duration = qu.dur('.update-info-row:nth-child(2)');
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.actors = qu.all('.models-list-thumbs a').map(el => ({
|
|
|
|
name: qu.q(el, 'span', true),
|
|
|
|
avatar: getImageWithFallbacks(qu.q, 'img', site, el),
|
|
|
|
}));
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.tags = qu.all('.tags a', true);
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
// const posterPath = html.match(/poster="(.*\.jpg)/)?.[1];
|
|
|
|
const posterPath = qu.q('.player-thumb img', 'src0_1x');
|
|
|
|
[release.poster, release.photos] = extractPoster(posterPath, site, baseRelease);
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const trailer = html.match(/<video.*src="(.*\.mp4)/)?.[1];
|
|
|
|
if (trailer && /^http/.test(trailer)) release.trailer = { src: trailer, referer: url };
|
|
|
|
else if (trailer) release.trailer = { src: `${site.parameters?.media || site.url}${trailer}`, referer: url };
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const stars = qu.q('.update-rating', true).match(/\d.\d/)?.[0];
|
|
|
|
if (stars) release.stars = Number(stars);
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-08-23 01:31:37 +00:00
|
|
|
if (site.type === 'network') {
|
|
|
|
const channelRegExp = new RegExp(site.children.map(channel => channel.parameters?.match || channel.name).join('|'), 'i');
|
2020-05-14 02:26:05 +00:00
|
|
|
const channel = release.tags.find(tag => channelRegExp.test(tag));
|
2020-03-05 04:07:14 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (channel) {
|
2020-08-23 01:31:37 +00:00
|
|
|
release.channel = slugify(channel, '');
|
2020-05-14 02:26:05 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-05 02:44:27 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
// release.entryId = q('.player-thumb img', 'id')?.match(/set-target-(\d+)/)[1];
|
|
|
|
release.entryId = deriveEntryId(release);
|
2020-03-05 19:31:11 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return release;
|
2020-03-05 19:31:11 +00:00
|
|
|
}
|
|
|
|
|
2020-03-11 23:15:25 +00:00
|
|
|
function scrapeSceneTour({ html, qu }, site, url) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const release = {};
|
2020-03-05 19:31:11 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (url) release.url = url;
|
|
|
|
release.title = qu.q('.update_title, .video-title', true);
|
|
|
|
release.description = qu.q('.latest_update_description, .video-summary', true);
|
2020-03-05 19:31:11 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const date = qu.date('.availdate, .update_date', 'YYYY-MM-DD');
|
|
|
|
if (date) release.date = date;
|
2020-03-05 19:31:11 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
release.actors = qu.all('.update_block_info .tour_update_models a, .video-model .tour_update_models a', true);
|
|
|
|
release.tags = qu.all('.update_tags a, .tour_update_tags a', true);
|
2020-03-05 19:31:11 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const [photo, poster, ...photos] = qu.imgs('.update_image img:not(.play_icon_overlay)');
|
|
|
|
if (poster || photo) release.poster = poster || photo;
|
|
|
|
if ((photo && poster) || photos) release.photos = poster ? [photo, ...photos] : photos; // don't use first photo when already used as fallback poster
|
2020-03-05 19:31:11 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (release.date) release.entryId = deriveEntryId(release);
|
2020-03-05 19:31:11 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const trailerCode = qu.q('.update_image a', 'onclick');
|
|
|
|
const trailerPath = trailerCode?.match(/tload\('(.*)'\)/)?.[1] || html.match(/\/trailer\/.*\.mp4/)?.[0];
|
|
|
|
if (trailerPath && /^http/.test(trailerPath)) release.trailer = { src: trailerPath };
|
|
|
|
else if (trailerPath) release.trailer = { src: `${site.parameters?.media || site.url}${trailerPath}` };
|
2020-03-05 19:31:11 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return release;
|
2020-03-05 01:47:52 +00:00
|
|
|
}
|
|
|
|
|
2020-03-11 23:15:25 +00:00
|
|
|
function scrapeProfile({ el, qu }, site) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const profile = {};
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const bio = qu.texts('.stats p').reduce((acc, info) => {
|
|
|
|
const [key, value] = info.split(':');
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return {
|
|
|
|
...acc,
|
|
|
|
[slugify(key, '_')]: value.trim(),
|
|
|
|
};
|
|
|
|
}, {});
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.measurements) {
|
|
|
|
const [bust, waist, hip] = bio.measurements.split('-');
|
2020-03-06 01:49:55 +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-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.age) profile.age = Number(bio.age);
|
|
|
|
if (bio.height) profile.height = feetInchesToCm(bio.height);
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
profile.avatar = getImageWithFallbacks(qu.q, '.profileimg img', site);
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const qReleases = ctxa(el, '.modelFeatures .modelfeature');
|
|
|
|
profile.releases = scrapeAll(qReleases, site);
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return profile;
|
2020-03-06 01:49:55 +00:00
|
|
|
}
|
|
|
|
|
2020-03-11 23:15:25 +00:00
|
|
|
function scrapeProfileT1({ el, qu }, site) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const profile = {};
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const bio = qu.all('.detail-div + .detail-div p, .detail-div p', true).reduce((acc, info) => {
|
|
|
|
const [key, value] = info.split(':');
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (!value) return acc;
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return {
|
|
|
|
...acc,
|
|
|
|
[slugify(key, '_')]: value.trim(),
|
|
|
|
};
|
|
|
|
}, {});
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.measurements) {
|
|
|
|
const [bust, waist, hip] = bio.measurements.split('-');
|
2020-03-06 01:49:55 +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-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.fun_fact) profile.description = bio.fun_fact;
|
|
|
|
if (bio.age) profile.age = Number(bio.age);
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const heightMetric = bio.height?.match(/(\d{3})(\b|c)/);
|
|
|
|
const heightImperial = bio.height?.match(/\d{1}(\.\d)?/g);
|
|
|
|
if (heightMetric) profile.height = Number(heightMetric[1]);
|
|
|
|
if (heightImperial) profile.height = feetInchesToCm(Number(heightImperial[0]), Number(heightImperial[1]));
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
profile.avatar = getImageWithFallbacks(qu.q, '.img-div img', site);
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const qReleases = ctxa(el, '.item-video');
|
|
|
|
profile.releases = scrapeAllT1(qReleases, site);
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return profile;
|
2020-03-06 01:49:55 +00:00
|
|
|
}
|
|
|
|
|
2020-03-11 23:15:25 +00:00
|
|
|
function scrapeProfileTour({ el, qu }, site) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const profile = {};
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const bio = qu.texts('.model_bio').reduce((acc, info) => {
|
|
|
|
const [key, value] = info.split(':');
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return {
|
|
|
|
...acc,
|
|
|
|
[slugify(key, '_')]: value.trim(),
|
|
|
|
};
|
|
|
|
}, {});
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.date_of_birth) profile.birthdate = ed(bio.date_of_birth, 'MMMM D, YYYY');
|
|
|
|
if (bio.birthplace) profile.birthPlace = bio.birthplace;
|
|
|
|
if (bio.fun_fact) profile.description = bio.fun_fact;
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.ethnicity) profile.ethnicity = bio.ethnicity;
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.height) profile.height = Number(bio.height.match(/^\d{2,3}/)?.[0]);
|
|
|
|
if (bio.weight) profile.weight = Number(bio.weight.match(/^\d{2,3}/)?.[0]);
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.measurements) {
|
|
|
|
const [bust, waist, hip] = bio.measurements.split('-');
|
2020-03-06 01:49:55 +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-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.natural_breasts && /yes/i.test(bio.natural_breasts)) profile.naturalBoobs = true;
|
|
|
|
if (bio.natural_breasts && /no/i.test(bio.natural_breasts)) profile.naturalBoobs = false;
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.tattoos && /yes/i.test(bio.tattoos)) profile.hasTattoos = true;
|
|
|
|
if (bio.tattoos && /no/i.test(bio.tattoos)) profile.hasTattoos = false;
|
|
|
|
if (bio.piercings && /yes/i.test(bio.piercings)) profile.hasPiercings = true;
|
|
|
|
if (bio.piercings && /no/i.test(bio.piercings)) profile.hasPiercings = false;
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.aliases) profile.aliases = bio.aliases.split(',').map(alias => alias.trim());
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
profile.avatar = getImageWithFallbacks(qu.q, '.model_picture img', site);
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const qReleases = ctxa(el, '.update_block');
|
|
|
|
profile.releases = qReleases.map((qRelease) => {
|
|
|
|
const url = qRelease.qu.url('.update_image a[href]');
|
|
|
|
const release = scrapeSceneTour(qRelease, site);
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (!/\/(signup|join)/i.test(url)) release.url = url;
|
|
|
|
release.entryId = deriveEntryId(release);
|
|
|
|
release.site = site;
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return release;
|
|
|
|
});
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return profile;
|
2020-03-06 01:49:55 +00:00
|
|
|
}
|
|
|
|
|
2020-08-23 00:43:10 +00:00
|
|
|
async function fetchLatest(site, page = 1, include, { uniqueReleases, duplicateReleases }) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const url = (site.parameters?.latest && util.format(site.parameters.latest, page))
|
2020-03-05 02:44:27 +00:00
|
|
|
|| (site.parameters?.t1 && `${site.url}/t1/categories/movies_${page}_d.html`)
|
|
|
|
|| `${site.url}/categories/movies_${page}_d.html`;
|
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const res = await geta(url, '.modelfeature, .item-video, .updateItem');
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (!res.ok) return res.status;
|
2020-08-23 00:43:10 +00:00
|
|
|
if (site.parameters?.t1) return scrapeAllT1(res.items, site, [...uniqueReleases, ...duplicateReleases]);
|
|
|
|
if (site.parameters?.tour) return scrapeAllTour(res.items, site);
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-08-23 00:43:10 +00:00
|
|
|
return scrapeAll(res.items, site, uniqueReleases);
|
2020-03-05 01:47:52 +00:00
|
|
|
}
|
|
|
|
|
2020-08-23 01:31:37 +00:00
|
|
|
async function fetchScene(url, site, baseRelease) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const res = await get(url);
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (!res.ok) return res.status;
|
2020-08-23 01:31:37 +00:00
|
|
|
if (site.parameters?.t1) return scrapeSceneT1(res.item, site, url, baseRelease);
|
2020-05-14 02:26:05 +00:00
|
|
|
if (site.parameters?.tour) return scrapeSceneTour(res.item, site, url, baseRelease);
|
2020-03-05 01:47:52 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return scrapeScene(res.item, site, url, baseRelease);
|
2020-03-05 01:47:52 +00:00
|
|
|
}
|
|
|
|
|
2020-07-20 23:44:51 +00:00
|
|
|
async function fetchProfile({ name: actorName }, { site }) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const actorSlugA = slugify(actorName, '');
|
|
|
|
const actorSlugB = slugify(actorName);
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const t1 = site.parameters?.t1 ? 't1/' : '';
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const res1 = site.parameters?.profile
|
|
|
|
? await get(util.format(site.parameters.profile, actorSlugA))
|
|
|
|
: await get(`${site.url}/${t1}models/${actorSlugA}.html`);
|
2020-03-08 03:23:10 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const res = (res1.ok && res1)
|
|
|
|
|| (site.parameters?.profile && await get(util.format(site.parameters.profile, actorSlugB)))
|
|
|
|
|| await get(`${site.url}/${t1}models/${actorSlugB}.html`);
|
2020-03-08 03:23:10 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (!res.ok) return res.status;
|
|
|
|
if (site.parameters?.t1) return scrapeProfileT1(res.item, site);
|
|
|
|
if (site.parameters?.tour) return scrapeProfileTour(res.item, site);
|
2020-03-06 01:49:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return scrapeProfile(res.item, site);
|
2020-03-06 01:49:55 +00:00
|
|
|
}
|
|
|
|
|
2020-03-05 01:47:52 +00:00
|
|
|
module.exports = {
|
2020-05-14 02:26:05 +00:00
|
|
|
fetchLatest,
|
|
|
|
fetchScene,
|
|
|
|
fetchProfile,
|
2020-03-05 01:47:52 +00:00
|
|
|
};
|