2021-08-09 08:31:12 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const { decode } = require('html-entities');
|
|
|
|
|
|
|
|
const qu = require('../utils/qu');
|
2021-08-17 17:25:10 +00:00
|
|
|
const slugify = require('../utils/slugify');
|
2021-08-09 08:31:12 +00:00
|
|
|
|
|
|
|
function scrapeAll(items, _channel) {
|
|
|
|
return items.map(({ query }) => {
|
|
|
|
const release = {};
|
|
|
|
|
|
|
|
const { date, precision } = query.dateAgo('.fecha');
|
|
|
|
const poster = query.img('.thumb');
|
|
|
|
|
|
|
|
release.entryId = query.number(null, /\d+/, 'onclick');
|
|
|
|
release.url = query.url(null, 'href', { origin: 'https://www.cumlouder.com' });
|
|
|
|
|
|
|
|
release.date = date;
|
|
|
|
release.datePrecision = precision;
|
|
|
|
|
|
|
|
release.title = query.cnt('h2');
|
|
|
|
release.duration = query.duration('.minutos');
|
|
|
|
|
|
|
|
release.poster = [
|
|
|
|
poster.replace(/\/(\w+)\.jpg/, '/previewhd.jpg'),
|
|
|
|
poster,
|
|
|
|
];
|
|
|
|
|
|
|
|
return release;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function scrapeScene({ query }, channel, html) {
|
|
|
|
const release = {};
|
|
|
|
|
|
|
|
const { date, precision } = query.dateAgo('.sub-video .added');
|
|
|
|
|
|
|
|
release.entryId = html.match(/cumlouder_(\d+)/)?.[1];
|
|
|
|
|
|
|
|
release.title = query.cnt('.video-top h1');
|
|
|
|
release.description = query.text('.sub-video p');
|
|
|
|
|
|
|
|
release.date = date;
|
|
|
|
release.datePrecision = precision;
|
|
|
|
|
|
|
|
release.actors = query.all('.sub-video .pornstar-link').map(el => ({
|
|
|
|
name: query.cnt(el, null),
|
|
|
|
url: query.url(el, null, 'href', { origin: 'https://www.cumlouder.com' }),
|
|
|
|
}));
|
|
|
|
|
|
|
|
release.duration = query.duration('.video-top .duracion');
|
|
|
|
release.tags = query.cnts('.video-top .tag-link');
|
|
|
|
|
|
|
|
release.poster = query.poster() || html.match(/urlImg\s*=\s*'(.*)';/)?.[1];
|
2021-08-17 17:25:10 +00:00
|
|
|
release.video = query.video() || decode(html.match(/urlVideo\s*=\s*'(.*)';/)?.[1]); // no trailers but full-length videos
|
2021-08-09 08:31:12 +00:00
|
|
|
|
2021-08-17 17:25:10 +00:00
|
|
|
release.shootId = release.poster?.match(/\/rc(\d+)/)?.[1] || release.video?.match(/\/episodio_(\d+)/)?.[1];
|
2021-08-09 08:31:12 +00:00
|
|
|
|
|
|
|
return release;
|
|
|
|
}
|
|
|
|
|
2021-08-17 17:25:10 +00:00
|
|
|
function scrapeProfile({ query, el }, channel) {
|
2021-08-09 08:31:12 +00:00
|
|
|
const profile = {};
|
|
|
|
|
2021-08-17 17:25:10 +00:00
|
|
|
const bio = query.all('.data-bio li').reduce((acc, bioEl) => ({
|
|
|
|
...acc,
|
|
|
|
[slugify(query.cnt(bioEl, 'strong'), '_')]: query.text(bioEl),
|
|
|
|
}), {});
|
|
|
|
|
|
|
|
profile.nationality = bio.nationality;
|
|
|
|
profile.dateOfBirth = qu.extractDate(bio.date_of_birth, 'DD-MM-YYYY');
|
|
|
|
|
|
|
|
profile.height = Number(bio.height) * 100;
|
|
|
|
profile.weight = parseInt(bio.weight, 10);
|
|
|
|
profile.eyes = bio.eye_color;
|
|
|
|
profile.hairColor = bio.hair_color;
|
|
|
|
|
2021-08-09 08:31:12 +00:00
|
|
|
profile.description = query.cnt('.data-bio p:last-of-type');
|
|
|
|
profile.avatar = query.img('.thumb-bio');
|
|
|
|
|
2021-08-17 17:25:10 +00:00
|
|
|
profile.scenes = scrapeAll(qu.initAll(el, '.muestra-escena'), channel);
|
2021-08-09 08:31:12 +00:00
|
|
|
|
|
|
|
return profile;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function fetchLatest(channel, page) {
|
|
|
|
const res = await qu.getAll(`${channel.url}/${page}/`, '.muestra-escena');
|
|
|
|
|
|
|
|
if (res.ok) {
|
|
|
|
return scrapeAll(res.items, channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
return res.status;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function fetchScene(url, channel) {
|
|
|
|
const res = await qu.get(url);
|
|
|
|
|
|
|
|
if (res.ok) {
|
|
|
|
return scrapeScene(res.item, channel, res.html);
|
|
|
|
}
|
|
|
|
|
|
|
|
return res.status;
|
|
|
|
}
|
|
|
|
|
2021-08-17 17:25:10 +00:00
|
|
|
async function fetchProfile(actor, channel) {
|
2021-08-09 08:31:12 +00:00
|
|
|
const res = await qu.get(`https://www.cumlouder.com/girl/${actor.slug}/`, '.listado-escenas');
|
|
|
|
|
|
|
|
if (res.ok) {
|
2021-08-17 17:25:10 +00:00
|
|
|
return scrapeProfile(res.item, channel);
|
2021-08-09 08:31:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return res.status;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
fetchLatest,
|
|
|
|
fetchScene,
|
|
|
|
fetchProfile,
|
|
|
|
};
|