2019-03-03 03:18:33 +00:00
|
|
|
'use strict';
|
|
|
|
|
2020-03-14 01:56:28 +00:00
|
|
|
// const knex = require('./knex');
|
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');
|
|
|
|
const fetchDeep = require('./deep');
|
|
|
|
const { storeReleases } = require('./store-releases');
|
2020-03-19 00:54:25 +00:00
|
|
|
const { updateReleasesSearch } = require('./releases');
|
2020-03-16 03:10:52 +00:00
|
|
|
// const { storeReleaseActors } = require('./actors');
|
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();
|
|
|
|
knex.destroy();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-03-16 03:10:52 +00:00
|
|
|
const updateBaseReleases = (argv.scrape || argv.sites || argv.networks) && await fetchUpdates();
|
|
|
|
|
|
|
|
const updateDeepReleases = updateBaseReleases && await fetchDeep(updateBaseReleases);
|
|
|
|
const argvDeepReleases = argv.scenes && await fetchDeep(argv.scenes);
|
|
|
|
|
|
|
|
await storeReleases([...(updateDeepReleases || []), ...(argvDeepReleases || [])]);
|
|
|
|
|
|
|
|
// await storeReleaseActors(updateReleases);
|
|
|
|
|
2020-03-14 01:56:28 +00:00
|
|
|
knex.destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2019-11-16 02:33:36 +00:00
|
|
|
const scrapeSites = require('./scrape-sites');
|
2020-03-09 04:06:37 +00:00
|
|
|
const { scrapeScenes, scrapeMovies, deepFetchReleases } = require('./scrape-releases');
|
2020-03-10 22:46:55 +00:00
|
|
|
const { storeReleases, updateReleasesSearch } = require('./releases');
|
2019-11-19 03:36:15 +00:00
|
|
|
const { scrapeActors, scrapeBasicActors } = require('./actors');
|
2019-03-11 03:19:36 +00:00
|
|
|
|
2020-02-20 01:35:23 +00:00
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
|
|
require('longjohn'); // eslint-disable-line global-require
|
|
|
|
}
|
|
|
|
|
2019-03-04 03:19:03 +00:00
|
|
|
async function init() {
|
2019-12-13 02:28:52 +00:00
|
|
|
if (argv.scene) {
|
2020-03-09 04:06:37 +00:00
|
|
|
await scrapeScenes(argv.scene);
|
2020-03-14 01:56:28 +00:00
|
|
|
|
2019-04-10 02:44:36 +00:00
|
|
|
|
2019-12-13 02:28:52 +00:00
|
|
|
if (argv.movie) {
|
2020-03-09 04:06:37 +00:00
|
|
|
await scrapeMovies(argv.movie);
|
2019-12-13 02:28:52 +00:00
|
|
|
}
|
2019-05-06 00:01:57 +00:00
|
|
|
|
2019-11-16 22:37:33 +00:00
|
|
|
if (argv.scrape || argv.networks || argv.sites) {
|
2019-11-16 02:33:36 +00:00
|
|
|
await scrapeSites();
|
2019-03-18 03:46:53 +00:00
|
|
|
}
|
2019-11-16 02:33:36 +00:00
|
|
|
|
2019-11-19 03:36:15 +00:00
|
|
|
if (argv.actors && argv.actors.length > 0) {
|
2020-01-31 00:55:55 +00:00
|
|
|
const actors = await scrapeActors();
|
|
|
|
|
|
|
|
if (argv.withReleases) {
|
2020-03-06 01:49:55 +00:00
|
|
|
const baseReleases = actors.map(actor => actor?.releases || []).flat();
|
2020-03-11 02:01:37 +00:00
|
|
|
const releases = await deepFetchReleases(baseReleases, null);
|
2020-01-31 00:55:55 +00:00
|
|
|
|
2020-03-06 01:49:55 +00:00
|
|
|
await storeReleases(releases);
|
2020-01-31 00:55:55 +00:00
|
|
|
}
|
2019-11-17 02:56:45 +00:00
|
|
|
}
|
|
|
|
|
2020-01-25 03:26:49 +00:00
|
|
|
if (argv.actors && argv.actors.length === 0) {
|
2019-11-19 03:36:15 +00:00
|
|
|
await scrapeBasicActors();
|
2019-12-13 02:28:52 +00:00
|
|
|
}
|
2019-11-19 03:36:15 +00:00
|
|
|
|
2020-03-10 22:46:55 +00:00
|
|
|
if (argv.updateSearch) {
|
|
|
|
await updateReleasesSearch();
|
|
|
|
}
|
|
|
|
|
2019-12-13 02:28:52 +00:00
|
|
|
if (argv.server) {
|
|
|
|
await initServer();
|
2019-11-19 03:36:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-12-13 02:28:52 +00:00
|
|
|
knex.destroy();
|
2019-03-03 03:18:33 +00:00
|
|
|
}
|
2020-03-14 01:56:28 +00:00
|
|
|
*/
|
2019-03-03 03:18:33 +00:00
|
|
|
|
2019-12-09 04:00:49 +00:00
|
|
|
module.exports = init;
|