172 lines
4.8 KiB
JavaScript
Executable File
172 lines
4.8 KiB
JavaScript
Executable File
'use strict';
|
|
|
|
const qu = require('../utils/qu');
|
|
const slugify = require('../utils/slugify');
|
|
|
|
function getEntryId(url) {
|
|
return slugify(new URL(url).pathname.match(/\/updates\/(.*)\.html/)?.[1], '-');
|
|
}
|
|
|
|
function scrapeAll(scenes) {
|
|
return scenes.map(({ query }) => {
|
|
const release = {};
|
|
|
|
release.url = query.url('a');
|
|
release.entryId = getEntryId(release.url);
|
|
|
|
release.title = query.cnt('.title-label a, .thumb-title a, .p-7, .text h3');
|
|
release.date = query.date('.date-label', 'MM/DD/YYYY');
|
|
|
|
release.actors = query.all(['.update_models a', '.tour_update_models a', '.pornstar-label span']).map((el) => ({
|
|
name: query.cnt(el),
|
|
url: query.url(el, null),
|
|
}));
|
|
|
|
release.poster = query.img('a img');
|
|
release.teaser = query.video('.leVideo source');
|
|
|
|
return release;
|
|
});
|
|
}
|
|
|
|
function scrapeScene({ query }, url) {
|
|
const release = {};
|
|
|
|
release.entryId = getEntryId(url);
|
|
release.title = query.cnt(['#media-holder .title', '.content-holder h1', '#scene h1', 'h2.titular', 'title'])?.replace(/\s+-$/, '');
|
|
|
|
release.date = query.date('#sceneInfo .date, #trailer-data .date', 'YYYY-MM-DD');
|
|
release.duration = query.duration('#sceneInfo .data-others, #trailer-data', /\d+:\d+/);
|
|
|
|
release.description = query.cnt('#sceneInfo .description, #trailer-data > div:first-child p');
|
|
|
|
release.actors = query.all('#sceneInfo .data-others a[href*="/models"], #trailer-data a[href*="/models"]').map((el) => ({
|
|
name: query.el(el, null, 'title'),
|
|
url: query.url(el, null),
|
|
}));
|
|
|
|
release.tags = query.cnts('.categories-holder a, #sceneInfo a[href*="/categories"], #trailer-data a[href*="/categories"]');
|
|
|
|
const poster = query.img(['#video-holder .update_thumb', '#noMore .update_thumb', '#hpromo .update_thumb', '.trailer-thumb']) || query.poster('#trailervideo');
|
|
const posterPathname = poster && new URL(poster)?.pathname;
|
|
|
|
release.poster = [poster, poster?.replace(/imgw=\w+/, 'imgw=680')];
|
|
|
|
release.photos = query.imgs('.photos-holder img')
|
|
.filter((src) => new URL(src).pathname !== posterPathname)
|
|
.map((src) => [
|
|
src.replace(/imgw=\d+/, 'imgw=1284'),
|
|
src,
|
|
]);
|
|
|
|
release.trailer = query.video('#trailervideo source[type="video/mp4"], #FulsSizeVideo source[type="video/mp4"]'); // sic
|
|
release.teaser = query.video('#trailer-video source[src*="/videothumbs"]');
|
|
|
|
return release;
|
|
}
|
|
|
|
function scrapeProfileScenes(scenes) {
|
|
return scenes.map(({ query }) => {
|
|
const release = {};
|
|
|
|
release.url = query.url('a[href*="/updates"]');
|
|
release.entryId = getEntryId(release.url);
|
|
|
|
release.title = query.cnt('.titular, h3 a');
|
|
release.date = query.date('.date-label', 'YYYY-MM-DD');
|
|
release.duration = query.number('.length-label') * 60;
|
|
|
|
release.description = query.cnt('.model-update-description');
|
|
|
|
release.actors = query.all('.model-labels a').map((el) => ({
|
|
name: query.cnt(el),
|
|
url: query.url(el, null),
|
|
}));
|
|
|
|
const poster = query.img('.update_thumb');
|
|
|
|
release.poster = [poster, poster?.replace(/imgw=\w+/, 'imgw=680')];
|
|
release.tags = query.cnts('.categories-holder a');
|
|
|
|
return release;
|
|
});
|
|
}
|
|
|
|
function scrapeProfile({ query, el }) {
|
|
const profile = {};
|
|
const bioKeys = query.cnts('.statsText b');
|
|
const bioValues = query.texts('.statsText');
|
|
|
|
const bio = bioKeys.reduce((acc, key, index) => ({
|
|
...acc,
|
|
[slugify(key, '_')]: bioValues[index],
|
|
}), {});
|
|
|
|
profile.description = query.cnt('.descriptionText');
|
|
profile.avatar = query.img('.model-bio-pic img');
|
|
|
|
profile.height = Number(bio.height?.match(/(\d+)\s?cm/i)?.[1]);
|
|
profile.dateOfBirth = qu.extractDate(bio.date_of_birth, 'MMMM D, YYYY');
|
|
|
|
profile.measurements = bio.measurements;
|
|
profile.butt = bio.ass_type;
|
|
profile.pussy = bio.pussy_type;
|
|
|
|
profile.ethnicity = bio.ethnicity;
|
|
profile.hairColor = bio.hair_color;
|
|
profile.eyes = bio.eye_color;
|
|
profile.nationality = bio.nationality;
|
|
|
|
if (/tattoo/i.test(bio.body_art)) {
|
|
profile.hasTattoos = true;
|
|
}
|
|
|
|
if (/piercing/i.test(bio.body_art)) {
|
|
profile.hasPiercings = true;
|
|
}
|
|
|
|
profile.scenes = scrapeProfileScenes(qu.initAll(el, '.model-update'));
|
|
|
|
return profile;
|
|
}
|
|
|
|
async function fetchLatest(channel, page) {
|
|
const res = await qu.getAll(`${channel.url}/categories/movies_${page}_d.html`, '.thumb-big, .thumb-video, .thumbnail, .thumbnail-popular, .full-thumbnail');
|
|
|
|
if (res.ok) {
|
|
return scrapeAll(res.items, channel);
|
|
}
|
|
|
|
return res.status;
|
|
}
|
|
|
|
async function fetchProfile(actor, channel) {
|
|
if (actor.url) {
|
|
const res = await qu.get(actor.url);
|
|
|
|
if (res.ok) {
|
|
return scrapeProfile(res.item);
|
|
}
|
|
}
|
|
|
|
const resA = await qu.get(`${channel.url}/models/${slugify(actor.name)}.html`);
|
|
|
|
if (resA.ok) {
|
|
return scrapeProfile(resA.item, channel);
|
|
}
|
|
|
|
const resB = await qu.get(`${channel.url}/models/${slugify(actor.name, '')}.html`);
|
|
|
|
if (resB.ok) {
|
|
return scrapeProfile(resB.item, channel);
|
|
}
|
|
|
|
return resB.status;
|
|
}
|
|
|
|
module.exports = {
|
|
fetchLatest,
|
|
fetchProfile,
|
|
scrapeScene,
|
|
};
|