265 lines
6.8 KiB
JavaScript
265 lines
6.8 KiB
JavaScript
'use strict';
|
|
|
|
const qu = require('../utils/q');
|
|
const slugify = require('../utils/slugify');
|
|
const { feetInchesToCm, lbsToKg } = require('../utils/convert');
|
|
|
|
function scrapeAll(scenes, channel) {
|
|
return scenes.map(({ query }) => {
|
|
const release = {};
|
|
|
|
release.url = query.url('.scene-update-details, .feature-update-details', 'href', { origin: channel.url });
|
|
release.entryId = new URL(release.url).pathname.match(/\/(\d+)/)[1];
|
|
|
|
release.title = query.q('.scene-img-wrapper img', 'alt').replace(/\s*image$/i, '');
|
|
|
|
release.date = query.date('.scene-update-stats span, .feature-update-details span', 'MMM DD, YYYY');
|
|
release.actors = query.cnt('.scene-update-details h3, .feature-update-details h2')?.split(/\s*\|\s*/).map(actor => actor.trim());
|
|
|
|
const poster = query.img('.scene-img-wrapper img');
|
|
release.poster = [
|
|
poster.replace(/\/res\/\d+/, '/res/1920'),
|
|
poster.replace(/\/res\/\d+/, '/res/1600'),
|
|
poster,
|
|
];
|
|
|
|
release.trailer = { src: query.video('.scene-img-wrapper source') };
|
|
|
|
return release;
|
|
});
|
|
}
|
|
|
|
function scrapeMovieScenes(scenes) {
|
|
return scenes.map(({ query }) => {
|
|
const release = {};
|
|
|
|
release.title = query.cnt('.scene-title a');
|
|
release.url = query.url('.scene-title a', 'href', { origin: 'https://www.elegantangel.com' });
|
|
release.entryId = new URL(release.url).pathname.match(/\/(\d+)/)[1];
|
|
|
|
release.duration = query.number('.scene-length') * 60;
|
|
release.actors = query.cnts('.scene-cast-list a');
|
|
|
|
release.poster = query.img('a img');
|
|
|
|
return release;
|
|
});
|
|
}
|
|
|
|
async function scrapeRelease({ query, html }, url, channel, baseRelease, type = 'scene') {
|
|
const release = {};
|
|
|
|
release.entryId = new URL(url).pathname.match(/\/(\d+)/)[1];
|
|
|
|
release.title = query.cnt('.scene-page .description, .video-page .description');
|
|
release.date = query.date('.release-date:first-child', 'MMM DD, YYYY', /\w{3} \d{2}, \d{4}/);
|
|
|
|
release.actors = query.all('.video-performer').map((el) => {
|
|
const avatar = qu.query.img(el, 'img', 'data-bgsrc');
|
|
|
|
return {
|
|
name: qu.query.cnt(el, 'span'),
|
|
url: qu.query.url(el, 'a', 'href', { origin: channel.url }),
|
|
avatar: [
|
|
avatar.replace(/\/actor\/\d+/, '/actor/1600'),
|
|
avatar,
|
|
],
|
|
};
|
|
});
|
|
|
|
release.tags = query.cnts('.tags a, .categories a');
|
|
release.studio = slugify(query.cnt('.studio span:last-child'), '');
|
|
|
|
if (type === 'scene') {
|
|
release.director = query.text('.director');
|
|
release.duration = query.number('.release-date:last-child') * 60;
|
|
release.poster = baseRelease?.poster || query.url('link[rel="image_src"]') || query.meta('property="og:image"');
|
|
}
|
|
|
|
if (type === 'movie') {
|
|
release.director = query.cnt('.director a');
|
|
release.covers = query.imgs('.carousel-item > img');
|
|
|
|
release.scenes = scrapeMovieScenes(qu.initAll(query.all('#scenes .grid-item')), channel);
|
|
}
|
|
|
|
release.photos = query.imgs('#dv_frames a > img').map(photo => [
|
|
photo.replace(/(\/p\/\d+\/)\d+/, (match, path) => `${path}1920`),
|
|
photo.replace(/(\/p\/\d+\/)\d+/, (match, path) => `${path}1600`),
|
|
photo,
|
|
]);
|
|
|
|
const trailerId = html.match(/item: (\d+),/)?.[1];
|
|
|
|
if (trailerId) {
|
|
const trailerUrl = `https://www.adultempire.com/videoEmbed/${trailerId}?type=preview`;
|
|
const trailerRes = await qu.get(trailerUrl);
|
|
|
|
if (trailerRes.ok) {
|
|
const stream = trailerRes.item.query.video();
|
|
|
|
release.trailer = { stream };
|
|
}
|
|
}
|
|
|
|
return release;
|
|
}
|
|
|
|
function scrapeMovies(movies, channel) {
|
|
return movies.map(({ query }) => {
|
|
const release = {};
|
|
|
|
release.url = query.url('.boxcover', 'href', { origin: channel.url });
|
|
release.entryId = new URL(release.url).pathname.match(/\/(\d+)/)[1];
|
|
|
|
release.title = query.cnt('span');
|
|
|
|
const cover = query.img('picture img');
|
|
|
|
release.covers = [
|
|
// filename is ignored, back-cover has suffix after media ID
|
|
cover.replace('_sq.jpg', '/front.jpg').replace(/\/product\/\d+/, '/product/500'),
|
|
cover.replace('_sq.jpg', 'b/back.jpg').replace(/\/product\/\d+/, '/product/500'),
|
|
];
|
|
|
|
return release;
|
|
});
|
|
}
|
|
|
|
function scrapeActorScenes(scenes, channel) {
|
|
return scenes.map(({ query }) => {
|
|
const release = {};
|
|
|
|
release.url = query.url('a', 'href', { origin: channel.url });
|
|
release.entryId = new URL(release.url).pathname.match(/\/(\d+)/)[1];
|
|
|
|
release.title = query.cnt('.grid-item-title');
|
|
|
|
const poster = query.img('a img');
|
|
release.poster = [
|
|
poster.replace(/\/\d+\//, '/1600/'),
|
|
poster,
|
|
];
|
|
|
|
return release;
|
|
});
|
|
}
|
|
|
|
async function scrapeProfile({ query }, url, channel, include) {
|
|
const profile = {};
|
|
|
|
const bio = query.cnts('.performer-page-header li').reduce((acc, info) => {
|
|
const [key, value] = info.split(':');
|
|
|
|
return {
|
|
...acc,
|
|
[slugify(key, '_')]: value.trim(),
|
|
};
|
|
}, {});
|
|
|
|
const measurements = bio.meas?.match(/(\d+)(\w+)-(\d+)-(\d+)/);
|
|
|
|
if (measurements) {
|
|
[profile.bust, profile.cup, profile.waist, profile.hip] = measurements.slice(1);
|
|
}
|
|
|
|
profile.hair = bio.hair;
|
|
profile.eyes = bio.eyes;
|
|
profile.ethnicity = bio.ethnicity;
|
|
|
|
profile.height = feetInchesToCm(bio.height);
|
|
profile.weight = lbsToKg(bio.weight);
|
|
|
|
profile.avatar = query.img('picture img');
|
|
|
|
if (include) {
|
|
const actorId = new URL(url).pathname.match(/\/(\d+)/)[1];
|
|
const res = await qu.getAll(`https://www.elegantangel.com/streaming-video-by-scene.html?cast=${actorId}`, '.grid-item', null, {
|
|
rejectUnauthorized: false,
|
|
});
|
|
|
|
if (res.ok) {
|
|
profile.releases = scrapeActorScenes(res.items, channel);
|
|
}
|
|
}
|
|
|
|
return profile;
|
|
}
|
|
|
|
async function fetchLatest(channel, page = 1) {
|
|
const url = `${channel.url}/tour?page=${page}`;
|
|
const res = await qu.getAll(url, '.scene-update', null, {
|
|
// invalid certificate
|
|
rejectUnauthorized: false,
|
|
});
|
|
|
|
if (res.ok) {
|
|
return scrapeAll(res.items, channel);
|
|
}
|
|
|
|
return res.status;
|
|
}
|
|
|
|
async function fetchScene(url, channel, baseRelease) {
|
|
const res = await qu.get(url, null, null, {
|
|
// invalid certificate
|
|
rejectUnauthorized: false,
|
|
});
|
|
|
|
if (res.ok) {
|
|
return scrapeRelease(res.item, url, channel, baseRelease);
|
|
}
|
|
|
|
return res.status;
|
|
}
|
|
|
|
async function fetchMovie(url, channel, baseRelease) {
|
|
const res = await qu.get(url, null, null, {
|
|
// invalid certificate
|
|
rejectUnauthorized: false,
|
|
});
|
|
|
|
if (res.ok) {
|
|
return scrapeRelease(res.item, url, channel, baseRelease, 'movie');
|
|
}
|
|
|
|
return res.status;
|
|
}
|
|
|
|
async function fetchMovies(channel, page = 1) {
|
|
const res = await qu.getAll(`https://www.elegantangel.com/streaming-elegant-angel-dvds-on-video.html?page=${page}`, '.grid-item', null, {
|
|
// invalid certificate
|
|
rejectUnauthorized: false,
|
|
});
|
|
|
|
if (res.ok) {
|
|
return scrapeMovies(res.items, channel);
|
|
}
|
|
|
|
return res.status;
|
|
}
|
|
|
|
async function fetchProfile(baseActor, channel, include) {
|
|
if (!baseActor.url) {
|
|
return null;
|
|
}
|
|
|
|
const res = await qu.get(baseActor.url, '.performer-page', null, {
|
|
rejectUnauthorized: false,
|
|
});
|
|
|
|
if (res.ok) {
|
|
return scrapeProfile(res.item, baseActor.url, channel, include);
|
|
}
|
|
|
|
return res.status;
|
|
}
|
|
|
|
module.exports = {
|
|
fetchLatest,
|
|
fetchScene,
|
|
fetchMovies,
|
|
fetchMovie,
|
|
fetchProfile,
|
|
};
|