2020-01-23 21:45:46 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const { ex } = require('../utils/q');
|
2020-11-22 23:05:02 +00:00
|
|
|
const http = require('../utils/http');
|
2020-01-23 21:45:46 +00:00
|
|
|
|
|
|
|
function scrapeProfile(html) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const { qu } = ex(html); /* eslint-disable-line object-curly-newline */
|
|
|
|
const profile = {};
|
2020-01-23 21:45:46 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const bio = qu.all('.infobox tr[valign="top"]')
|
2021-11-20 22:59:15 +00:00
|
|
|
.map((detail) => qu.all(detail, 'td', true))
|
2020-05-14 02:26:05 +00:00
|
|
|
.reduce((acc, [key, value]) => ({ ...acc, [key.slice(0, -1).replace(/[\s+|/]/g, '_')]: value }), {});
|
2020-01-23 21:45:46 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
/* unreliable, see: Syren De Mer
|
2020-01-23 21:45:46 +00:00
|
|
|
const catlinks = qa('#mw-normal-catlinks a', true);
|
|
|
|
const isTrans = catlinks.some(link => link.match(/shemale|transgender/i));
|
|
|
|
profile.gender = isTrans ? 'transsexual' : 'female';
|
2020-02-23 21:26:14 +00:00
|
|
|
*/
|
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
profile.birthdate = qu.date('.bday', 'YYYY-MM-DD');
|
2020-01-23 21:45:46 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
profile.description = qu.q('#mw-content-text > p', true);
|
2020-01-23 21:45:46 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.Born) profile.birthPlace = bio.Born.slice(bio.Born.lastIndexOf(')') + 1);
|
|
|
|
if (bio.Ethnicity) profile.ethnicity = bio.Ethnicity;
|
2020-01-23 21:45:46 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.Measurements) {
|
|
|
|
const measurements = bio.Measurements
|
|
|
|
.match(/\d+(\w+)?-\d+-\d+/g)
|
2021-02-21 21:58:46 +00:00
|
|
|
?.slice(-1)[0] // allow for both '34C-25-36' and '86-64-94 cm / 34-25-37 in'
|
|
|
|
.split('-');
|
2020-01-23 21:45:46 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
// account for measuemrents being just e.g. '32EE'
|
|
|
|
if (measurements) {
|
|
|
|
const [bust, waist, hip] = measurements;
|
2020-01-23 21:45:46 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (/[a-zA-Z]/.test(bust)) profile.bust = bust; // only use bust if cup size is included
|
2020-01-27 02:07:06 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
profile.waist = Number(waist);
|
|
|
|
profile.hip = Number(hip);
|
|
|
|
}
|
2020-01-27 02:07:06 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (/^\d+\w+$/.test(bio.Measurements)) profile.bust = bio.Measurements;
|
|
|
|
}
|
2020-01-23 21:45:46 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.Bra_cup_size) {
|
|
|
|
const bust = bio.Bra_cup_size.match(/^\d+\w+/);
|
|
|
|
if (bust) [profile.bust] = bust;
|
|
|
|
}
|
2020-01-23 21:45:46 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.Boobs === 'Enhanced') profile.naturalBoobs = false;
|
|
|
|
if (bio.Boobs === 'Natural') profile.naturalBoobs = true;
|
2020-01-23 21:45:46 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.Height) profile.height = Number(bio.Height.match(/\d+\.\d+/g).slice(-1)[0]) * 100;
|
|
|
|
if (bio.Weight) profile.weight = Number(bio.Weight.match(/\d+/g)[1]);
|
2020-01-23 21:45:46 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.Eye_color) profile.eyes = bio.Eye_color;
|
|
|
|
if (bio.Hair) [profile.hair] = bio.Hair.split(',');
|
2020-01-23 21:45:46 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (bio.Blood_group) profile.blood = bio.Blood_group;
|
|
|
|
if (bio.Also_known_as) profile.aliases = bio.Also_known_as.split(', ');
|
2020-01-23 21:45:46 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const avatarThumbPath = qu.img('.image img');
|
2020-01-23 21:45:46 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (avatarThumbPath && !/NoImageAvailable/.test(avatarThumbPath)) {
|
|
|
|
const avatarPath = avatarThumbPath.slice(0, avatarThumbPath.lastIndexOf('/')).replace('thumb/', '');
|
2020-01-23 21:45:46 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
profile.avatar = {
|
|
|
|
src: `http://www.boobpedia.com${avatarPath}`,
|
2020-07-15 01:24:47 +00:00
|
|
|
credit: null,
|
2020-05-14 02:26:05 +00:00
|
|
|
};
|
|
|
|
}
|
2020-01-23 21:45:46 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
profile.social = qu.urls('.infobox a.external');
|
2020-01-23 21:45:46 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return profile;
|
2020-01-23 21:45:46 +00:00
|
|
|
}
|
|
|
|
|
2020-07-20 23:44:51 +00:00
|
|
|
async function fetchProfile({ name: actorName }) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const actorSlug = actorName.replace(/\s+/, '_');
|
2020-11-22 23:05:02 +00:00
|
|
|
const res = await http.get(`http://www.boobpedia.com/boobs/${actorSlug}`);
|
2020-01-23 21:45:46 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
if (res.statusCode === 200) {
|
|
|
|
return scrapeProfile(res.body.toString());
|
|
|
|
}
|
2020-01-23 21:45:46 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return null;
|
2020-01-23 21:45:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
2020-05-14 02:26:05 +00:00
|
|
|
fetchProfile,
|
2020-01-23 21:45:46 +00:00
|
|
|
};
|