forked from DebaucheryLibrarian/traxxx
Adding scraper config by scraper slug to current 'includes' parameter.
This commit is contained in:
parent
1869877178
commit
bf9b334b73
|
@ -175,6 +175,11 @@ module.exports = {
|
|||
'pornhub',
|
||||
'freeones',
|
||||
],
|
||||
options: {
|
||||
traxxx: {
|
||||
// source: 'http://nsfw.unknown.name/random',
|
||||
},
|
||||
},
|
||||
proxy: {
|
||||
enable: false,
|
||||
host: '',
|
||||
|
|
|
@ -78,7 +78,7 @@ const boobpedia = require('./boobpedia');
|
|||
const freeones = require('./freeones');
|
||||
// const freeoneslegacy = require('./freeones_legacy');
|
||||
|
||||
module.exports = {
|
||||
const scrapers = {
|
||||
releases: {
|
||||
'21naturals': naturals,
|
||||
'21sextreme': sextreme,
|
||||
|
@ -269,3 +269,9 @@ module.exports = {
|
|||
xempire,
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
// add slug for easy internal reference
|
||||
releases: Object.entries(scrapers.releases).reduce((acc, [slug, scraper]) => ({ ...acc, [slug]: { ...scraper, slug } })),
|
||||
actors: Object.entries(scrapers.actors).reduce((acc, [slug, scraper]) => ({ ...acc, [slug]: { ...scraper, slug } })),
|
||||
};
|
||||
|
|
|
@ -97,7 +97,7 @@ function maleNoun() {
|
|||
return random([
|
||||
'guy',
|
||||
'stud',
|
||||
'man',
|
||||
'lad',
|
||||
'boyfriend',
|
||||
'stranger',
|
||||
'stepbrother',
|
||||
|
@ -227,22 +227,29 @@ function actors(release) {
|
|||
}));
|
||||
}
|
||||
|
||||
async function fetchLatest(entity) {
|
||||
async function fetchLatest(entity, page, options) {
|
||||
return Promise.all(Array.from({ length: 100 }, async (value, index) => {
|
||||
const release = {};
|
||||
|
||||
release.entryId = nanoid();
|
||||
release.date = moment().subtract(Math.floor(Math.random() * index), 'days').toDate();
|
||||
|
||||
const [poster, ...photos] = await knex('media')
|
||||
.select('path')
|
||||
.where('is_sfw', true)
|
||||
.pluck('path')
|
||||
.orderByRaw('random()')
|
||||
.limit(Math.floor(Math.random() * 10) + 1);
|
||||
if (options.source) {
|
||||
// select from configured random image source
|
||||
release.poster = `${options.source}?id=${nanoid()}`; // ensure source is unique
|
||||
release.photos = Array.from({ length: Math.floor(Math.random() * 10) + 1 }, () => `${options.source}?id=${nanoid()}`); // ensure source is unique
|
||||
} else {
|
||||
// select from local SFW database
|
||||
const [poster, ...photos] = await knex('media')
|
||||
.select('path')
|
||||
.where('is_sfw', true)
|
||||
.pluck('path')
|
||||
.orderByRaw('random()')
|
||||
.limit(Math.floor(Math.random() * 10) + 1);
|
||||
|
||||
release.poster = `http://${config.web.host}:${config.web.port}/img/${poster}?id=${nanoid()}`; // ensure source is unique
|
||||
release.photos = photos.map(photo => `http://${config.web.host}:${config.web.port}/img/${photo}?id=${nanoid()}`);
|
||||
release.poster = `http://${config.web.host}:${config.web.port}/img/${poster}?id=${nanoid()}`; // ensure source is unique
|
||||
release.photos = photos.map(photo => `http://${config.web.host}:${config.web.port}/img/${photo}?id=${nanoid()}`);
|
||||
}
|
||||
|
||||
release.tags = await knex('tags')
|
||||
.select('name')
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const config = require('config');
|
||||
const Promise = require('bluebird');
|
||||
const moment = require('moment');
|
||||
|
||||
|
@ -93,9 +94,14 @@ function needNextPage(pageReleases, accReleases, isUpcoming) {
|
|||
|
||||
async function scrapeReleases(scraper, entity, preData, isUpcoming) {
|
||||
async function scrapeReleasesPage(page, accReleases) {
|
||||
const options = {
|
||||
...config.options[scraper.slug],
|
||||
...include,
|
||||
};
|
||||
|
||||
const pageReleases = isUpcoming
|
||||
? await scraper.fetchUpcoming(entity, page, include, preData)
|
||||
: await scraper.fetchLatest(entity, page, include, preData);
|
||||
? await scraper.fetchUpcoming(entity, page, options, preData)
|
||||
: await scraper.fetchLatest(entity, page, options, preData);
|
||||
|
||||
if (!Array.isArray(pageReleases)) {
|
||||
// scraper is unable to fetch the releases and returned a HTTP code or null
|
||||
|
|
Loading…
Reference in New Issue