2019-04-07 03:01:06 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const bhttp = require('bhttp');
|
2020-02-06 22:15:28 +00:00
|
|
|
|
|
|
|
const { d, ex, exa, get } = require('../utils/q');
|
|
|
|
const slugify = require('../utils/slugify');
|
2019-04-07 03:01:06 +00:00
|
|
|
|
2019-04-07 03:19:44 +00:00
|
|
|
/* eslint-disable newline-per-chained-call */
|
2020-02-06 22:15:28 +00:00
|
|
|
function scrapeAll(html, site, origin) {
|
|
|
|
return exa(html, '.card.m-1:not(.pornstar-card)').map(({ q, qa, qd }) => {
|
|
|
|
const release = {};
|
2019-04-07 03:01:06 +00:00
|
|
|
|
2020-02-06 22:15:28 +00:00
|
|
|
release.title = q('a', 'title');
|
|
|
|
release.url = `${site?.url || origin || 'https://ddfnetwork.com'}${q('a', 'href')}`;
|
|
|
|
[release.entryId] = release.url.split('/').slice(-1);
|
2019-04-07 03:01:06 +00:00
|
|
|
|
2020-02-06 22:15:28 +00:00
|
|
|
release.date = qd('small[datetime]', 'YYYY-MM-DD HH:mm:ss', null, 'datetime');
|
|
|
|
release.actors = qa('.card-subtitle a', true).filter(Boolean);
|
2019-04-07 03:01:06 +00:00
|
|
|
|
2020-02-06 22:15:28 +00:00
|
|
|
const duration = parseInt(q('.card-info div:nth-child(2) .card-text', true), 10) * 60;
|
|
|
|
if (duration) release.duration = duration;
|
2019-10-30 03:45:42 +00:00
|
|
|
|
2020-02-06 22:15:28 +00:00
|
|
|
release.poster = q('img').dataset.src;
|
2019-04-07 03:01:06 +00:00
|
|
|
|
2020-02-06 22:15:28 +00:00
|
|
|
return release;
|
2019-04-07 03:01:06 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-02-06 22:15:28 +00:00
|
|
|
async function scrapeScene(html, url, _site) {
|
|
|
|
const { q, qa, qd, qm, qp, qus } = ex(html);
|
|
|
|
const release = {};
|
|
|
|
|
|
|
|
[release.entryId] = url.split('/').slice(-1);
|
|
|
|
|
|
|
|
release.title = qm('itemprop=name');
|
|
|
|
release.description = q('.descr-box p', true);
|
|
|
|
release.date = qd('meta[itemprop=uploadDate]', 'YYYY-MM-DD', null, 'content')
|
|
|
|
|| qd('.title-border:nth-child(2) p', 'MM.DD.YYYY');
|
|
|
|
|
|
|
|
release.actors = qa('.pornstar-card > a', 'title');
|
|
|
|
release.tags = qa('.tags-tab .tags a', true);
|
|
|
|
|
|
|
|
release.duration = parseInt(q('.icon-video-red + span', true), 10) * 60;
|
|
|
|
release.likes = Number(q('.icon-like-red + span', true));
|
|
|
|
|
|
|
|
release.poster = qp();
|
|
|
|
release.photos = qus('.photo-slider-guest .card a');
|
|
|
|
|
|
|
|
release.trailer = qa('source[type="video/mp4"]').map(trailer => ({
|
|
|
|
src: trailer.src,
|
|
|
|
quality: Number(trailer.attributes.res.value),
|
|
|
|
}));
|
|
|
|
|
|
|
|
return release;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function fetchActorReleases(urls) {
|
|
|
|
// DDF Network and DDF Network Stream list all scenes, exclude
|
|
|
|
const sources = urls.filter(url => !/ddfnetwork/.test(url));
|
|
|
|
|
|
|
|
const releases = await Promise.all(sources.map(async (url) => {
|
|
|
|
const { html } = await get(url);
|
|
|
|
|
|
|
|
return scrapeAll(html, null, new URL(url).origin);
|
|
|
|
}));
|
|
|
|
|
|
|
|
// DDF cross-releases scenes between sites, filter duplicates by entryId
|
|
|
|
return Object.values(releases
|
|
|
|
.flat()
|
|
|
|
.sort((releaseA, releaseB) => releaseB.date - releaseA.date) // sort by date so earliest scene remains
|
|
|
|
.reduce((acc, release) => ({ ...acc, [release.entryId]: release }), {}));
|
2019-04-07 03:01:06 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 04:55:32 +00:00
|
|
|
async function scrapeProfile(html, _url, actorName) {
|
2020-02-06 22:15:28 +00:00
|
|
|
const { q, qa, qus } = ex(html);
|
2019-11-30 04:55:32 +00:00
|
|
|
|
2020-02-06 22:15:28 +00:00
|
|
|
const keys = qa('.about-title', true).map(key => slugify(key, { delimiter: '_' }));
|
|
|
|
const values = qa('.about-info').map((el) => {
|
2019-11-30 04:55:32 +00:00
|
|
|
if (el.children.length > 0) {
|
|
|
|
return Array.from(el.children, child => child.textContent.trim()).join(', ');
|
|
|
|
}
|
|
|
|
|
|
|
|
return el.textContent.trim();
|
|
|
|
});
|
|
|
|
|
|
|
|
const bio = keys.reduce((acc, key, index) => {
|
2020-02-06 22:15:28 +00:00
|
|
|
if (values[index] === '-') return acc;
|
2019-11-30 04:55:32 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
...acc,
|
|
|
|
[key]: values[index],
|
|
|
|
};
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
const profile = {
|
|
|
|
name: actorName,
|
|
|
|
};
|
|
|
|
|
2020-02-06 22:15:28 +00:00
|
|
|
profile.description = q('.description-box', true);
|
|
|
|
profile.birthdate = d(bio.birthday, 'MMMM DD, YYYY');
|
|
|
|
|
|
|
|
if (bio.nationality) profile.nationality = bio.nationality;
|
2019-11-30 04:55:32 +00:00
|
|
|
|
2020-02-06 22:15:28 +00:00
|
|
|
if (bio.bra_size) [profile.bust] = bio.bra_size.match(/\d+\w+/);
|
|
|
|
if (bio.waist) profile.waist = Number(bio.waist.match(/\d+/)[0]);
|
|
|
|
if (bio.hips) profile.hip = Number(bio.hips.match(/\d+/)[0]);
|
2019-11-30 04:55:32 +00:00
|
|
|
|
2020-02-06 22:15:28 +00:00
|
|
|
if (bio.height) profile.height = Number(bio.height.match(/\d{2,}/)[0]);
|
2019-11-30 04:55:32 +00:00
|
|
|
|
2020-02-06 22:15:28 +00:00
|
|
|
if (bio.tit_style && /Enhanced/.test(bio.tit_style)) profile.naturalBoobs = false;
|
|
|
|
if (bio.tit_style && /Natural/.test(bio.tit_style)) profile.naturalBoobs = true;
|
2019-11-30 04:55:32 +00:00
|
|
|
|
2020-02-06 22:15:28 +00:00
|
|
|
if (bio.body_art && /Tattoo/.test(bio.body_art)) profile.hasTattoos = true;
|
|
|
|
if (bio.body_art && /Piercing/.test(bio.body_art)) profile.hasPiercings = true;
|
2019-11-30 04:55:32 +00:00
|
|
|
|
2020-02-06 22:15:28 +00:00
|
|
|
if (bio.hair_style) profile.hair = bio.hair_style.split(',')[0].trim().toLowerCase();
|
|
|
|
if (bio.eye_color) profile.eyes = bio.eye_color.match(/\w+/)[0].toLowerCase();
|
2019-11-30 04:55:32 +00:00
|
|
|
|
2020-02-06 22:15:28 +00:00
|
|
|
if (bio.shoe_size) profile.shoes = Number(bio.shoe_size.split('|')[1]);
|
2019-11-30 04:55:32 +00:00
|
|
|
|
2020-02-06 22:15:28 +00:00
|
|
|
const avatarEl = q('.pornstar-details .card-img-top');
|
2019-12-09 23:30:55 +00:00
|
|
|
if (avatarEl && avatarEl.dataset.src.match('^//')) profile.avatar = `https:${avatarEl.dataset.src}`;
|
2019-11-30 04:55:32 +00:00
|
|
|
|
2020-02-06 22:15:28 +00:00
|
|
|
profile.releases = await fetchActorReleases(qus('.find-me-tab li a'));
|
|
|
|
|
2019-11-30 04:55:32 +00:00
|
|
|
return profile;
|
|
|
|
}
|
|
|
|
|
2019-04-07 03:01:06 +00:00
|
|
|
async function fetchLatest(site, page = 1) {
|
2020-02-06 22:15:28 +00:00
|
|
|
const url = site.parameters?.native
|
|
|
|
? `${site.url}/videos/search/latest/ever/allsite/-/${page}`
|
|
|
|
: `https://ddfnetwork.com/videos/search/latest/ever/${new URL(site.url).hostname}/-/${page}`;
|
|
|
|
|
2020-01-27 21:54:14 +00:00
|
|
|
console.log(url);
|
|
|
|
const res = await bhttp.get(url);
|
2019-04-07 03:01:06 +00:00
|
|
|
|
2020-02-06 22:15:28 +00:00
|
|
|
return scrapeAll(res.body.toString(), site);
|
2019-04-07 03:01:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function fetchScene(url, site) {
|
|
|
|
const res = await bhttp.get(`https://ddfnetwork.com${new URL(url).pathname}`);
|
|
|
|
|
|
|
|
return scrapeScene(res.body.toString(), url, site);
|
|
|
|
}
|
|
|
|
|
2019-11-30 04:55:32 +00:00
|
|
|
async function fetchProfile(actorName) {
|
|
|
|
const resSearch = await bhttp.post('https://ddfnetwork.com/search/ajax',
|
|
|
|
{
|
|
|
|
type: 'hints',
|
|
|
|
word: actorName,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
decodeJSON: true,
|
|
|
|
headers: {
|
|
|
|
'x-requested-with': 'XMLHttpRequest',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
if (resSearch.statusCode !== 200 || Array.isArray(resSearch.body.list)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!resSearch.body.list.pornstarsName || resSearch.body.list.pornstarsName.length === 0) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const [actor] = resSearch.body.list.pornstarsName;
|
|
|
|
const url = `https://ddfnetwork.com${actor.href}`;
|
|
|
|
|
|
|
|
const resActor = await bhttp.get(url);
|
|
|
|
|
|
|
|
if (resActor.statusCode !== 200) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return scrapeProfile(resActor.body.toString(), url, actorName);
|
|
|
|
}
|
|
|
|
|
2019-04-07 03:01:06 +00:00
|
|
|
module.exports = {
|
|
|
|
fetchLatest,
|
2019-11-30 04:55:32 +00:00
|
|
|
fetchProfile,
|
2019-04-07 03:01:06 +00:00
|
|
|
fetchScene,
|
|
|
|
};
|