46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
const argv = require('./argv');
|
|
const initServer = require('./web/server');
|
|
|
|
const knex = require('./knex');
|
|
const fetchUpdates = require('./updates');
|
|
const { fetchScenes, fetchMovies } = require('./deep');
|
|
const { storeReleases, updateReleasesSearch } = require('./store-releases');
|
|
const { scrapeActors } = require('./actors-legacy');
|
|
|
|
async function init() {
|
|
if (argv.server) {
|
|
await initServer();
|
|
return;
|
|
}
|
|
|
|
if (argv.updateSearch) {
|
|
await updateReleasesSearch();
|
|
}
|
|
|
|
if (argv.actors) {
|
|
await scrapeActors(argv.actors);
|
|
}
|
|
|
|
const updateBaseScenes = (argv.scrape || argv.sites || argv.networks) && await fetchUpdates();
|
|
|
|
const deepScenes = argv.deep
|
|
? await fetchScenes([...(argv.scenes || []), ...(updateBaseScenes || [])])
|
|
: updateBaseScenes;
|
|
|
|
const sceneMovies = deepScenes && argv.sceneMovies && deepScenes.map(scene => scene.movie).filter(Boolean);
|
|
const deepMovies = await fetchMovies([...(argv.movies || []), ...(sceneMovies || [])]);
|
|
|
|
if (argv.save) {
|
|
await storeReleases([
|
|
...(deepScenes || []),
|
|
...(deepMovies || []),
|
|
]);
|
|
}
|
|
|
|
knex.destroy();
|
|
}
|
|
|
|
module.exports = init;
|