Added BaDoink profile scraper. Improved convert wrapper.

This commit is contained in:
DebaucheryLibrarian
2021-02-03 21:03:35 +01:00
parent cd417f40a8
commit 79b51eca67
5 changed files with 87 additions and 9 deletions

View File

@@ -1,6 +1,8 @@
'use strict';
const qu = require('../utils/qu');
const slugify = require('../utils/slugify');
const { convert } = require('../utils/convert');
function getPoster(posterSources) {
if (posterSources?.[0]) {
@@ -80,6 +82,38 @@ function scrapeScene({ query }, url, channel) {
return release;
}
function scrapeProfile({ query }, url, entity) {
const profile = { url };
const bio = query.all('.girl-details-stats-item').reduce((acc, el) => ({
...acc,
[slugify(qu.query.cnt(el, '.girl-details-stat'))]: qu.query.cnt(el, '.girl-details-stat-value'),
}), {});
profile.description = query.cnt('.girl-details-bio');
profile.age = bio.age;
profile.birthPlace = bio.country;
profile.ethnicity = bio.ethnicity;
profile.height = convert(bio.height, 'cm');
profile.weight = convert(bio.weight, 'lb', 'kg');
profile.measurements = bio.measurements;
profile.hairColor = bio.hair;
profile.eyes = bio.eyes;
const avatarSources = query.srcset('.girl-details-photo-content picture source', 'srcset') || [query.img('.girl-details-photo')];
profile.avatar = getPoster(avatarSources);
profile.social = query.urls('.girl-details-social-media-list a');
profile.scenes = scrapeAll(qu.initAll(query.all('.video-card')), entity);
return profile;
}
async function fetchLatest(channel, page) {
const res = await qu.getAll(`${channel.url}/${channel.parameters?.latest || 'vrpornvideos'}/${page}`, '.video-card', {
Cookie: 'affsubid=12345-;', // required to show teaser video, exact number doesn't seem to matter
@@ -92,7 +126,19 @@ async function fetchLatest(channel, page) {
return res.status;
}
async function fetchProfile(baseActor, { entity }) {
const url = `${entity.url}/${entity.parameters?.actor || 'pornstar'}/${slugify(baseActor.name, '')}/`;
const res = await qu.get(url);
if (res.ok) {
return scrapeProfile(res.item, url, entity);
}
return res.status;
}
module.exports = {
fetchLatest,
fetchProfile,
scrapeScene,
};