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