2019-04-07 03:01:06 +00:00
|
|
|
'use strict';
|
|
|
|
|
2020-07-12 20:36:53 +00:00
|
|
|
const qu = require('../utils/qu');
|
2020-02-06 22:15:28 +00:00
|
|
|
const slugify = require('../utils/slugify');
|
2020-11-22 23:05:02 +00:00
|
|
|
const http = require('../utils/http');
|
2019-04-07 03:01:06 +00:00
|
|
|
|
2020-07-12 20:36:53 +00:00
|
|
|
function scrapeAll(scenes, site, origin) {
|
|
|
|
return scenes.map(({ query }) => {
|
2020-05-14 02:26:05 +00:00
|
|
|
const release = {};
|
2019-04-07 03:01:06 +00:00
|
|
|
|
2020-07-12 20:36:53 +00:00
|
|
|
release.title = query.q('.card-title a, .videoContent h4 a', 'title');
|
|
|
|
release.url = `${site?.url || origin || 'https://pornworld.com'}${query.q('a', 'href')}`;
|
|
|
|
release.entryId = release.url.match(/\/(\d+)$/)[1];
|
2019-04-07 03:01:06 +00:00
|
|
|
|
2020-07-12 20:36:53 +00:00
|
|
|
release.date = query.date('small[datetime]', 'YYYY-MM-DD HH:mm:ss', null, 'datetime');
|
|
|
|
release.actors = query.all('.card-subtitle a, .featuring a', true).filter(Boolean);
|
2019-04-07 03:01:06 +00:00
|
|
|
|
2020-07-12 20:36:53 +00:00
|
|
|
release.description = query.q('h4 + p', true);
|
|
|
|
|
|
|
|
const duration = parseInt(query.q('.card-info div:nth-child(2) .card-text', true), 10) * 60;
|
2020-05-14 02:26:05 +00:00
|
|
|
if (duration) release.duration = duration;
|
2020-07-12 20:36:53 +00:00
|
|
|
else release.duration = query.dur('.time');
|
2019-10-30 03:45:42 +00:00
|
|
|
|
2020-07-12 20:36:53 +00:00
|
|
|
release.poster = query.img();
|
2019-04-07 03:01:06 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return release;
|
|
|
|
});
|
2019-04-07 03:01:06 +00:00
|
|
|
}
|
|
|
|
|
2021-02-05 00:54:06 +00:00
|
|
|
async function scrapeScene({ query }, url, channel) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const release = {};
|
2020-02-06 22:15:28 +00:00
|
|
|
|
2020-07-12 20:36:53 +00:00
|
|
|
release.entryId = url.match(/\/(\d+)$/)[1];
|
|
|
|
|
2021-01-25 22:53:56 +00:00
|
|
|
release.title = query.meta('itemprop=name') || query.cnt('.video-title h1, .about-text .story-title, .video-specs h1') || query.cnt('h3');
|
|
|
|
release.description = query.cnt('.descr-box p') || query.cnt('.about-text p:not(.story-title)') || query.text('.description p');
|
2020-02-06 22:15:28 +00:00
|
|
|
|
2020-07-12 20:36:53 +00:00
|
|
|
release.date = query.date('meta[itemprop=uploadDate]', 'YYYY-MM-DD', null, 'content')
|
|
|
|
|| query.date('.actors time', 'MMMM DD, YYYY')
|
|
|
|
|| query.date('.title-border:nth-child(2) p', 'MM.DD.YYYY')
|
|
|
|
|| query.date('.length', 'MMMM DD, YYYY', /\w+ \d{2}, \d{4}/);
|
2020-02-06 22:15:28 +00:00
|
|
|
|
2020-07-12 20:36:53 +00:00
|
|
|
if (query.exists('.pornstar-card > a')) release.actors = query.all('.pornstar-card > a', 'title');
|
2021-01-25 22:53:56 +00:00
|
|
|
else if (query.exists('.actors a')) release.actors = query.cnts('.actors a');
|
2020-02-06 22:15:28 +00:00
|
|
|
|
2021-01-25 22:53:56 +00:00
|
|
|
if (query.exists('.tags-tab')) release.tags = query.cnts('.tags-tab .tags a');
|
|
|
|
else if (query.exists('.tags-box')) release.tags = query.cnts('.tags-box .tags li');
|
2020-02-06 22:15:28 +00:00
|
|
|
|
2021-01-25 22:53:56 +00:00
|
|
|
release.duration = parseInt(query.cnt('.icon-video-red + span'), 10) * 60 || query.dur('.length') || null;
|
|
|
|
release.likes = Number(query.cnt('.icon-like-red + span')) || null;
|
2020-02-06 22:15:28 +00:00
|
|
|
|
2021-01-25 22:53:56 +00:00
|
|
|
release.poster = query.poster() || query.poster('dl8-video') || query.img('#videoBlock img');
|
2020-07-12 20:36:53 +00:00
|
|
|
release.photos = query.urls('.photo-slider-guest .card a');
|
|
|
|
|
|
|
|
release.trailer = query.all('source[type="video/mp4"]').map(trailer => ({
|
2020-05-14 02:26:05 +00:00
|
|
|
src: trailer.src,
|
2020-07-12 20:36:53 +00:00
|
|
|
quality: Number(trailer.attributes.res?.value || trailer.attributes.quality?.value.slice(0, -1)) || null,
|
2021-02-05 00:54:06 +00:00
|
|
|
vr: channel.tags?.some(tag => tag.slug === 'vr'),
|
2020-05-14 02:26:05 +00:00
|
|
|
}));
|
2020-02-06 22:15:28 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return release;
|
2020-02-06 22:15:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function fetchActorReleases(urls) {
|
2020-05-14 02:26:05 +00:00
|
|
|
// DDF Network and DDF Network Stream list all scenes, exclude
|
|
|
|
const sources = urls.filter(url => !/ddfnetwork/.test(url));
|
2020-02-06 22:15:28 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const releases = await Promise.all(sources.map(async (url) => {
|
2020-07-12 20:36:53 +00:00
|
|
|
const res = await qu.getAll(url, '.card.m-1:not(.pornstar-card)');
|
2020-02-06 22:15:28 +00:00
|
|
|
|
2020-07-12 20:36:53 +00:00
|
|
|
return res.ok ? scrapeAll(res.items, null, new URL(url).origin) : null;
|
2020-05-14 02:26:05 +00:00
|
|
|
}));
|
2020-02-06 22:15:28 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
// 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
|
|
|
}
|
|
|
|
|
2020-07-12 20:36:53 +00:00
|
|
|
async function scrapeProfile({ query }, _url, actorName) {
|
|
|
|
const keys = query.all('.about-title', true).map(key => slugify(key, '_'));
|
|
|
|
const values = query.all('.about-info').map((el) => {
|
2020-05-14 02:26:05 +00:00
|
|
|
if (el.children.length > 0) {
|
|
|
|
return Array.from(el.children, child => child.textContent.trim()).join(', ');
|
|
|
|
}
|
2019-11-30 04:55:32 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return el.textContent.trim();
|
|
|
|
});
|
2019-11-30 04:55:32 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const bio = keys.reduce((acc, key, index) => {
|
|
|
|
if (values[index] === '-') return acc;
|
2019-11-30 04:55:32 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return {
|
|
|
|
...acc,
|
|
|
|
[key]: values[index],
|
|
|
|
};
|
|
|
|
}, {});
|
2019-11-30 04:55:32 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const profile = {
|
|
|
|
name: actorName,
|
|
|
|
};
|
2019-11-30 04:55:32 +00:00
|
|
|
|
2020-07-12 20:36:53 +00:00
|
|
|
profile.description = query.q('.description-box', true);
|
|
|
|
profile.birthdate = qu.extractDate(bio.birthday, 'MMMM DD, YYYY');
|
2020-02-06 22:15:28 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.nationality) profile.nationality = bio.nationality;
|
2019-11-30 04:55:32 +00:00
|
|
|
|
2020-05-14 02:26:05 +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-05-14 02:26:05 +00:00
|
|
|
if (bio.height) profile.height = Number(bio.height.match(/\d{2,}/)[0]);
|
2019-11-30 04:55:32 +00:00
|
|
|
|
2020-05-14 02:26:05 +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-05-14 02:26:05 +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-05-14 02:26:05 +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-05-14 02:26:05 +00:00
|
|
|
if (bio.shoe_size) profile.shoes = Number(bio.shoe_size.split('|')[1]);
|
2019-11-30 04:55:32 +00:00
|
|
|
|
2020-07-12 20:36:53 +00:00
|
|
|
const avatarEl = query.q('.pornstar-details .card-img-top');
|
2020-05-14 02:26:05 +00:00
|
|
|
if (avatarEl && avatarEl.dataset.src.match('^//')) profile.avatar = `https:${avatarEl.dataset.src}`;
|
2019-11-30 04:55:32 +00:00
|
|
|
|
2020-07-12 20:36:53 +00:00
|
|
|
profile.releases = await fetchActorReleases(query.urls('.find-me-tab li a'));
|
2020-02-06 22:15:28 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return profile;
|
2019-11-30 04:55:32 +00:00
|
|
|
}
|
|
|
|
|
2020-07-12 20:36:53 +00:00
|
|
|
async function fetchLatest(channel, page = 1) {
|
|
|
|
/* ddfnetwork.com redirects to pornworld.com
|
2020-05-14 02:26:05 +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-07-12 20:36:53 +00:00
|
|
|
*/
|
2020-02-06 22:15:28 +00:00
|
|
|
|
2020-07-12 20:36:53 +00:00
|
|
|
const url = channel.parameters?.latest || `${channel.url}/videos/search/latest/ever/allsite/-/${page}`;
|
|
|
|
const res = await qu.getAll(url, '.card.m-1:not(.pornstar-card), .allVideos .videoBlock');
|
2019-04-07 03:01:06 +00:00
|
|
|
|
2020-07-12 20:36:53 +00:00
|
|
|
if (res.ok) {
|
|
|
|
return scrapeAll(res.items, channel);
|
2020-05-14 02:26:05 +00:00
|
|
|
}
|
2020-02-20 01:35:23 +00:00
|
|
|
|
2020-07-12 20:36:53 +00:00
|
|
|
return res.status;
|
2019-04-07 03:01:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function fetchScene(url, site) {
|
2020-05-14 02:26:05 +00:00
|
|
|
// DDF's main site moved to Porn World
|
2020-11-22 23:05:02 +00:00
|
|
|
// const res = await http.get(`https://ddfnetwork.com${new URL(url).pathname}`);
|
2020-07-12 20:36:53 +00:00
|
|
|
const res = await qu.get(url, '.content, #content, .taspVideoPage');
|
2019-04-07 03:01:06 +00:00
|
|
|
|
2020-07-12 20:36:53 +00:00
|
|
|
return res.ok ? scrapeScene(res.item, url, site) : res.status;
|
2019-04-07 03:01:06 +00:00
|
|
|
}
|
|
|
|
|
2020-07-20 23:44:51 +00:00
|
|
|
async function fetchProfile({ name: actorName }) {
|
2020-11-22 23:05:02 +00:00
|
|
|
const resSearch = await http.post('https://ddfnetwork.com/search/ajax',
|
2020-05-14 02:26:05 +00:00
|
|
|
{
|
|
|
|
type: 'hints',
|
|
|
|
word: actorName,
|
|
|
|
},
|
|
|
|
{
|
2020-07-12 20:36:53 +00:00
|
|
|
decodeJSON: false,
|
2020-05-14 02:26:05 +00:00
|
|
|
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}`;
|
|
|
|
|
2020-11-22 23:05:02 +00:00
|
|
|
const resActor = await http.get(url);
|
2020-05-14 02:26:05 +00:00
|
|
|
|
|
|
|
if (resActor.statusCode !== 200) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return scrapeProfile(resActor.body.toString(), url, actorName);
|
2019-11-30 04:55:32 +00:00
|
|
|
}
|
|
|
|
|
2019-04-07 03:01:06 +00:00
|
|
|
module.exports = {
|
2020-05-14 02:26:05 +00:00
|
|
|
fetchLatest,
|
|
|
|
fetchProfile,
|
|
|
|
fetchScene,
|
2019-04-07 03:01:06 +00:00
|
|
|
};
|