forked from DebaucheryLibrarian/traxxx
59 lines
2.2 KiB
JavaScript
Executable File
59 lines
2.2 KiB
JavaScript
Executable File
'use strict';
|
|
|
|
const unprint = require('unprint');
|
|
|
|
const slugify = require('../utils/slugify');
|
|
|
|
async function scrapeProfile({ query }, _url) {
|
|
const profile = {};
|
|
|
|
const entries = query.contents('.infoPiece').map((content) => content.split(':'));
|
|
const bio = entries.reduce((acc, [key, value]) => (key ? { ...acc, [slugify(key, '_')]: value.trim() } : acc), {});
|
|
|
|
profile.description = query.content('div[itemprop="description"]') || query.content('.longBio');
|
|
|
|
if (bio.gender) profile.gender = bio.gender;
|
|
if (bio.ethnicity) profile.ethnicity = bio.ethnicity;
|
|
|
|
if (bio.birthday && !/-0001/.test(bio.birthday)) profile.dateOfBirth = unprint.extractDate(bio.Birthday, 'MMM D, YYYY'); // birthyear sometimes -0001, see Spencer Bradley as of january 2020
|
|
if (bio.born) profile.dateOfBirth = unprint.extractDate(bio.born, 'YYYY-MM-DD');
|
|
|
|
profile.birthPlace = bio.birth_place || bio.birthplace;
|
|
profile.residencePlace = bio.city_and_country;
|
|
|
|
if (bio.measurements && bio.measurements !== '--') profile.measurements = bio.measurements;
|
|
if (bio.fake_boobs) profile.naturalBoobs = bio.fake_boobs.toLowerCase() === 'no';
|
|
|
|
if (bio.height) profile.height = unprint.extractNumber(bio.height, { match: /\((\d+)\s*cm\)/, matchIndex: 1 });
|
|
if (bio.weight) profile.weight = unprint.extractNumber(bio.weight, { match: /\((\d+)\s*kg\)/, matchIndex: 1 });
|
|
if (bio.hair_color) profile.hairColor = bio.hair_color;
|
|
if (bio.eyes) profile.eyeColor = bio.eye_color;
|
|
|
|
if (/yes/i.test(bio.piercings)) profile.hasPiercings = true;
|
|
if (/no/i.test(bio.piercings)) profile.hasPiercings = false;
|
|
|
|
if (/yes/i.test(bio.tattoos)) profile.hasTattoos = true;
|
|
if (/no/i.test(bio.tattoos)) profile.hasTattoos = false;
|
|
|
|
const avatar = query.img('#getAvatar') || query.img('.thumbImage img');
|
|
|
|
if (avatar && !/default\//.test(avatar)) {
|
|
profile.avatar = avatar;
|
|
}
|
|
|
|
profile.socials = query.urls('.socialList a').filter((link) => link !== 'https://www.twitter.com/'); // PH links to Twitter itself for some reason
|
|
|
|
return profile;
|
|
}
|
|
|
|
async function fetchProfile(actor) {
|
|
const url = `https://www.pornhub.com/pornstar/${actor.slug}`;
|
|
const res = await unprint.get(url);
|
|
|
|
return scrapeProfile(res.context, url);
|
|
}
|
|
|
|
module.exports = {
|
|
fetchProfile,
|
|
};
|