From 101c84763aa0c202e714b228035a683b5492027a Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Mon, 9 Feb 2026 02:10:40 +0100 Subject: [PATCH] Refactored Boobpedia for unprint. --- src/scrapers/boobpedia.js | 80 +++++++++++++++------------------------ 1 file changed, 30 insertions(+), 50 deletions(-) diff --git a/src/scrapers/boobpedia.js b/src/scrapers/boobpedia.js index ea4a3759..7fb4cfe7 100755 --- a/src/scrapers/boobpedia.js +++ b/src/scrapers/boobpedia.js @@ -1,15 +1,15 @@ 'use strict'; -const { ex } = require('../utils/q'); -const http = require('../utils/http'); +const unprint = require('unprint'); -function scrapeProfile(html) { - const { qu } = ex(html); /* eslint-disable-line object-curly-newline */ +const slugify = require('../utils/slugify'); + +function scrapeProfile({ query }) { const profile = {}; - const bio = qu.all('.infobox tr[valign="top"]') - .map((detail) => qu.all(detail, 'td', true)) - .reduce((acc, [key, value]) => ({ ...acc, [key.slice(0, -1).replace(/[\s+|/]/g, '_')]: value }), {}); + const bio = query.all('.infobox tr[valign="top"]') + .map((detail) => unprint.query.contents(detail, 'td')) + .reduce((acc, [key, value]) => ({ ...acc, [slugify(key, '_')]: value }), {}); /* unreliable, see: Syren De Mer const catlinks = qa('#mw-normal-catlinks a', true); @@ -17,71 +17,51 @@ function scrapeProfile(html) { profile.gender = isTrans ? 'transsexual' : 'female'; */ - profile.birthdate = qu.date('.bday', 'YYYY-MM-DD'); + profile.dateOfBirth = query.date('.bday', 'YYYY-MM-DD'); - profile.description = qu.q('#mw-content-text > p', true); + profile.description = query.content('.mw-parser-output > p'); - if (bio.Born) profile.birthPlace = bio.Born.slice(bio.Born.lastIndexOf(')') + 1); - if (bio.Ethnicity) profile.ethnicity = bio.Ethnicity; + profile.placeOfBirth = bio.born; + profile.ethnicity = bio.ethnicity; + profile.nationality = bio.nationality.split(',')[0]; - if (bio.Measurements) { - const measurements = bio.Measurements - .match(/\d+(\w+)?-\d+-\d+/g) - ?.slice(-1)[0] // allow for both '34C-25-36' and '86-64-94 cm / 34-25-37 in' - .split('-'); + profile.measurements = bio.measurements; - // account for measuemrents being just e.g. '32EE' - if (measurements) { - const [bust, waist, hip] = measurements; - - if (/[a-zA-Z]/.test(bust)) profile.bust = bust; // only use bust if cup size is included - - profile.waist = Number(waist); - profile.hip = Number(hip); - } - - if (/^\d+\w+$/.test(bio.Measurements)) profile.bust = bio.Measurements; + if (bio.bra_cup_size) { + [profile.bust] = bio.bra_cup_size.match(/^\d+\w+/) || []; } - if (bio.Bra_cup_size) { - const bust = bio.Bra_cup_size.match(/^\d+\w+/); - if (bust) [profile.bust] = bust; - } + if (/enhanced/i.test(bio.boobs)) profile.naturalBoobs = false; + if (/natural/i.test(bio.boobs)) profile.naturalBoobs = true; - if (bio.Boobs === 'Enhanced') profile.naturalBoobs = false; - if (bio.Boobs === 'Natural') profile.naturalBoobs = true; + 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]); - 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]); + if (bio.eye_color) profile.eyes = bio.eye_color; + if (bio.hair) [profile.hairColor] = bio.hair.split(/(?=[A-Z])/); // field concatted to BrunetteLong - if (bio.Eye_color) profile.eyes = bio.Eye_color; - if (bio.Hair) [profile.hair] = bio.Hair.split(','); + if (bio.blood_group) profile.blood = bio.blood_group; + if (bio.also_known_as) profile.aliases = bio.also_known_as.split(', '); - if (bio.Blood_group) profile.blood = bio.Blood_group; - if (bio.Also_known_as) profile.aliases = bio.Also_known_as.split(', '); - - const avatarThumbPath = qu.img('.image img'); + const avatarThumbPath = query.img('.infobox .mw-file-description img'); if (avatarThumbPath && !/NoImageAvailable/.test(avatarThumbPath)) { const avatarPath = avatarThumbPath.slice(0, avatarThumbPath.lastIndexOf('/')).replace('thumb/', ''); - profile.avatar = { - src: `http://www.boobpedia.com${avatarPath}`, - credit: null, - }; + profile.avatar = unprint.prefixUrl(avatarPath, 'https://www.boobpedia.com'); } - profile.social = qu.urls('.infobox a.external'); + profile.socials = query.urls('.infobox a.external'); return profile; } async function fetchProfile({ name: actorName }) { - const actorSlug = actorName.replace(/\s+/, '_'); - const res = await http.get(`http://www.boobpedia.com/boobs/${actorSlug}`); + const actorSlug = slugify(actorName, '_', { lower: false }); + const res = await unprint.get(`https://www.boobpedia.com/boobs/${actorSlug}`); - if (res.statusCode === 200) { - return scrapeProfile(res.body.toString()); + if (res.ok) { + return scrapeProfile(res.context); } return null;