Refactored Cherry Pimps to use unprint, added series as channels.
This commit is contained in:
@@ -60,13 +60,19 @@ function scrapeScene({ query }, { url }) {
|
||||
return release;
|
||||
}
|
||||
|
||||
function scrapeProfile({ query }) {
|
||||
function scrapeProfile({ query }, searchAvatar) {
|
||||
const profile = {};
|
||||
|
||||
profile.nationality = query.content('//h3[contains(text(), "Nationality:")]/span') || null;
|
||||
profile.age = query.number('//h3[contains(text(), "Age:")]/span');
|
||||
|
||||
profile.avatar = query.img();
|
||||
const pageAvatar = query.img();
|
||||
|
||||
profile.avatar = searchAvatar || pageAvatar;
|
||||
|
||||
if (searchAvatar) {
|
||||
profile.photos = [pageAvatar];
|
||||
}
|
||||
|
||||
return profile;
|
||||
}
|
||||
@@ -94,18 +100,20 @@ async function fetchUpcoming(channel) {
|
||||
}
|
||||
|
||||
async function fetchProfile({ name: actorName }, entity) {
|
||||
// don't skip search, avatar not available on actor page
|
||||
const searchUrl = `${entity.url}/models?name=${actorName}&sort=popularity`;
|
||||
const searchRes = await unprint.get(searchUrl);
|
||||
|
||||
if (searchRes.ok) {
|
||||
const actorEl = searchRes.context.query.all('.pagination-items .model a').find((resultEl) => unprint.query.attribute(resultEl, null, 'title') === actorName);
|
||||
const actorUrl = unprint.query.url(actorEl, null);
|
||||
const avatar = unprint.query.img(actorEl, '.card-img');
|
||||
|
||||
if (actorUrl) {
|
||||
const res = await unprint.get(actorUrl, { select: '.model-detail-card' });
|
||||
|
||||
if (res.ok) {
|
||||
return scrapeProfile(res.context, actorName, entity);
|
||||
return scrapeProfile(res.context, avatar, entity);
|
||||
}
|
||||
|
||||
return res.status;
|
||||
|
||||
Reference in New Issue
Block a user