2019-03-03 03:18:33 +00:00
|
|
|
'use strict';
|
|
|
|
|
2019-03-18 03:46:53 +00:00
|
|
|
const argv = require('./argv');
|
2019-05-06 00:01:57 +00:00
|
|
|
const initServer = require('./web/server');
|
2019-03-23 21:48:39 +00:00
|
|
|
|
2020-03-14 01:56:28 +00:00
|
|
|
const knex = require('./knex');
|
2020-03-16 03:10:52 +00:00
|
|
|
const fetchUpdates = require('./updates');
|
2020-03-21 01:48:24 +00:00
|
|
|
const { fetchScenes, fetchMovies } = require('./deep');
|
2020-03-29 02:00:46 +00:00
|
|
|
const { storeReleases, updateReleasesSearch } = require('./store-releases');
|
2020-03-28 00:40:02 +00:00
|
|
|
const { scrapeActors } = require('./actors-legacy');
|
2020-03-14 01:56:28 +00:00
|
|
|
|
|
|
|
async function init() {
|
|
|
|
if (argv.server) {
|
|
|
|
await initServer();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-03-19 00:54:25 +00:00
|
|
|
if (argv.updateSearch) {
|
|
|
|
await updateReleasesSearch();
|
2020-03-28 00:40:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (argv.actors) {
|
|
|
|
await scrapeActors(argv.actors);
|
2020-03-19 00:54:25 +00:00
|
|
|
}
|
|
|
|
|
2020-03-21 01:48:24 +00:00
|
|
|
const updateBaseScenes = (argv.scrape || argv.sites || argv.networks) && await fetchUpdates();
|
2020-03-28 00:40:02 +00:00
|
|
|
|
|
|
|
const deepScenes = argv.deep
|
|
|
|
? await fetchScenes([...(argv.scenes || []), ...(updateBaseScenes || [])])
|
|
|
|
: updateBaseScenes;
|
2020-03-16 03:10:52 +00:00
|
|
|
|
2020-03-22 02:50:24 +00:00
|
|
|
const sceneMovies = deepScenes && argv.sceneMovies && deepScenes.map(scene => scene.movie).filter(Boolean);
|
|
|
|
const deepMovies = await fetchMovies([...(argv.movies || []), ...(sceneMovies || [])]);
|
2020-03-16 03:10:52 +00:00
|
|
|
|
2020-03-22 02:50:24 +00:00
|
|
|
if (argv.save) {
|
|
|
|
await storeReleases([
|
|
|
|
...(deepScenes || []),
|
|
|
|
...(deepMovies || []),
|
|
|
|
]);
|
|
|
|
}
|
2020-03-16 03:10:52 +00:00
|
|
|
|
2020-03-14 01:56:28 +00:00
|
|
|
knex.destroy();
|
|
|
|
}
|
|
|
|
|
2019-12-09 04:00:49 +00:00
|
|
|
module.exports = init;
|