Migrated remaining scrapers from qu/http to unprint, likely fixing TeamSkeet and PinkyXXX (verification needed).
This commit is contained in:
+30
-27
@@ -1,6 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const { get, geta, ctxa } = require('../utils/q');
|
||||
const unprint = require('unprint');
|
||||
|
||||
// paths are relative, read raw attributes instead of resolved URLs
|
||||
const raw = { forceGetAttribute: true };
|
||||
|
||||
function extractActors(actorString) {
|
||||
return actorString
|
||||
@@ -20,48 +23,48 @@ function matchActors(actorString, models) {
|
||||
}
|
||||
|
||||
function scrapeLatest(scenes, site, models) {
|
||||
return scenes.map(({ qu }) => {
|
||||
return scenes.map(({ query }) => {
|
||||
const release = {};
|
||||
|
||||
const pathname = qu.url('a.itemimg').slice(1);
|
||||
const pathname = query.attribute('a.itemimg', 'href', raw).slice(1);
|
||||
[release.entryId] = pathname.split('/').slice(-1);
|
||||
release.url = `${site.url}${pathname}`;
|
||||
|
||||
release.title = qu.q('.itemimg img', 'alt') || qu.q('h4 a', true);
|
||||
release.description = qu.q('.mas_longdescription', true);
|
||||
release.date = qu.date('.movie_info2', 'MM/DD/YY', /\d{2}\/\d{2}\/\d{2}/);
|
||||
release.title = query.attribute('.itemimg img', 'alt') || query.content('h4 a');
|
||||
release.description = query.content('.mas_longdescription');
|
||||
release.date = query.date('.movie_info2', 'MM/DD/YY', { match: /\d{2}\/\d{2}\/\d{2}/ });
|
||||
|
||||
const actorString = qu.q('.mas_description', true);
|
||||
const actorString = query.content('.mas_description');
|
||||
const actors = matchActors(actorString, models);
|
||||
|
||||
if (actors.length > 0) release.actors = actors;
|
||||
else release.actors = extractActors(actorString);
|
||||
|
||||
const posterPath = qu.img('.itemimg img');
|
||||
const posterPath = query.attribute('.itemimg img', 'src', raw);
|
||||
release.poster = `${site.url}/${posterPath}`;
|
||||
|
||||
return release;
|
||||
});
|
||||
}
|
||||
|
||||
function scrapeScene({ html, qu }, url, site, include, models) {
|
||||
function scrapeScene({ html, query }, url, site, include, models) {
|
||||
const release = { url };
|
||||
|
||||
[release.entryId] = url.split('/').slice(-1);
|
||||
release.title = qu.q('.mas_title', true);
|
||||
release.description = qu.q('.mas_longdescription', true);
|
||||
release.date = qu.date('.mas_description', 'MMMM DD, YYYY', /\w+ \d{1,2}, \d{4}/);
|
||||
release.title = query.content('.mas_title');
|
||||
release.description = query.content('.mas_longdescription');
|
||||
release.date = query.date('.mas_description', 'MMMM DD, YYYY', { match: /\w+ \d{1,2}, \d{4}/ });
|
||||
|
||||
if (models) {
|
||||
const actorString = qu.q('.mas_description', true).replace(/\w+ \d{1,2}, \d{4}/, '');
|
||||
const actorString = query.content('.mas_description').replace(/\w+ \d{1,2}, \d{4}/, '');
|
||||
const actors = matchActors(actorString, models);
|
||||
if (actors.length > 0) release.actors = actors;
|
||||
else release.actors = extractActors(actorString);
|
||||
}
|
||||
|
||||
release.tags = qu.all('.tags a', true);
|
||||
release.tags = query.contents('.tags a');
|
||||
|
||||
release.photos = qu.imgs('.stills img').map((photoPath) => `${site.url}/${photoPath}`);
|
||||
release.photos = query.attributes('.stills img', 'src', raw).map((photoPath) => `${site.url}/${photoPath}`);
|
||||
|
||||
const posterIndex = 'splash:';
|
||||
const poster = html.slice(html.indexOf('faceimages/', posterIndex), html.indexOf('.jpg', posterIndex) + 4);
|
||||
@@ -74,20 +77,20 @@ function scrapeScene({ html, qu }, url, site, include, models) {
|
||||
return release;
|
||||
}
|
||||
|
||||
function extractModels({ el }, site) {
|
||||
const models = ctxa(el, '.item');
|
||||
function extractModels({ element }, site) {
|
||||
const models = unprint.initAll(element, '.item');
|
||||
|
||||
return models.map(({ qu }) => {
|
||||
return models.map(({ query }) => {
|
||||
const actor = { gender: 'female' };
|
||||
|
||||
const avatar = qu.q('.itemimg img');
|
||||
const avatar = query.element('.itemimg img');
|
||||
actor.avatar = `${site.url}/${avatar.src}`;
|
||||
actor.name = avatar.alt
|
||||
.split(':').slice(-1)[0]
|
||||
.replace(/xtreme girl|nurse/ig, '')
|
||||
.trim();
|
||||
|
||||
const actorPath = qu.url('.itemimg');
|
||||
const actorPath = query.attribute('.itemimg', 'href', raw);
|
||||
actor.url = `${site.url}${actorPath.slice(1)}`;
|
||||
|
||||
return actor;
|
||||
@@ -96,11 +99,11 @@ function extractModels({ el }, site) {
|
||||
|
||||
async function fetchModels(site, page = 1, accModels = []) {
|
||||
const url = `${site.url}/?models/${page}`;
|
||||
const res = await get(url);
|
||||
const res = await unprint.get(url);
|
||||
|
||||
if (res.ok) {
|
||||
const models = extractModels(res.item, site);
|
||||
const nextPage = res.item.qa('.pagenumbers', true)
|
||||
const models = extractModels(res.context, site);
|
||||
const nextPage = res.context.query.contents('.pagenumbers')
|
||||
.map((pageX) => Number(pageX))
|
||||
.filter(Boolean) // remove << and >>
|
||||
.includes(page + 1);
|
||||
@@ -117,16 +120,16 @@ async function fetchModels(site, page = 1, accModels = []) {
|
||||
|
||||
async function fetchLatest(site, page = 1, include, { beforeFetchLatest }) {
|
||||
const url = `${site.url}/show.php?a=${site.parameters.a}_${page}`;
|
||||
const res = await geta(url, '.item');
|
||||
const res = await unprint.get(url, { selectAll: '.item' });
|
||||
|
||||
return res.ok ? scrapeLatest(res.items, site, beforeFetchLatest) : res.status;
|
||||
return res.ok ? scrapeLatest(res.context, site, beforeFetchLatest) : res.status;
|
||||
}
|
||||
|
||||
async function fetchScene(url, site, release, include, beforeFetchLatest) {
|
||||
const models = beforeFetchLatest || await fetchModels(site);
|
||||
const res = await get(url);
|
||||
const res = await unprint.get(url);
|
||||
|
||||
return res.ok ? scrapeScene(res.item, url, site, models) : res.status;
|
||||
return res.ok ? scrapeScene(res.context, url, site, include, models) : res.status;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user