forked from DebaucheryLibrarian/traxxx
57 lines
1.4 KiB
JavaScript
57 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
const argv = require('./argv');
|
|
const knex = require('./knex');
|
|
const initServer = require('./web/server');
|
|
|
|
const scrapeSites = require('./scrape-sites');
|
|
const { scrapeScenes, scrapeMovies, deepFetchReleases } = require('./scrape-releases');
|
|
const { storeReleases, updateReleasesSearch } = require('./releases');
|
|
const { scrapeActors, scrapeBasicActors } = require('./actors');
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
require('longjohn'); // eslint-disable-line global-require
|
|
}
|
|
|
|
async function init() {
|
|
if (argv.scene) {
|
|
await scrapeScenes(argv.scene);
|
|
}
|
|
|
|
if (argv.movie) {
|
|
await scrapeMovies(argv.movie);
|
|
}
|
|
|
|
if (argv.scrape || argv.networks || argv.sites) {
|
|
await scrapeSites();
|
|
}
|
|
|
|
if (argv.actors && argv.actors.length > 0) {
|
|
const actors = await scrapeActors();
|
|
|
|
if (argv.withReleases) {
|
|
const baseReleases = actors.map(actor => actor?.releases || []).flat();
|
|
const releases = await deepFetchReleases(baseReleases, null, 'scene');
|
|
|
|
await storeReleases(releases);
|
|
}
|
|
}
|
|
|
|
if (argv.actors && argv.actors.length === 0) {
|
|
await scrapeBasicActors();
|
|
}
|
|
|
|
if (argv.updateSearch) {
|
|
await updateReleasesSearch();
|
|
}
|
|
|
|
if (argv.server) {
|
|
await initServer();
|
|
return;
|
|
}
|
|
|
|
knex.destroy();
|
|
}
|
|
|
|
module.exports = init;
|