traxxx/src/app.js

95 lines
2.4 KiB
JavaScript
Raw Normal View History

'use strict';
// const knex = require('./knex');
const argv = require('./argv');
const initServer = require('./web/server');
const knex = require('./knex');
const fetchUpdates = require('./updates');
const { fetchScenes, fetchMovies } = require('./deep');
const { storeReleases } = require('./store-releases');
const { updateReleasesSearch } = require('./releases');
// const { storeReleaseActors } = require('./actors');
async function init() {
if (argv.server) {
await initServer();
return;
}
if (argv.updateSearch) {
await updateReleasesSearch();
knex.destroy();
return;
}
const updateBaseScenes = (argv.scrape || argv.sites || argv.networks) && await fetchUpdates();
const deepScenes = await fetchScenes([...(argv.scenes || []), ...(updateBaseScenes || [])]);
console.log(deepScenes.map(scene => scene.movie));
const argvDeepMovies = argv.movies && await fetchMovies(argv.movies);
await storeReleases([
...(deepScenes || []),
...(argvDeepMovies || []),
]);
// await storeReleaseActors(updateReleases);
knex.destroy();
}
/*
const scrapeSites = require('./scrape-sites');
2020-03-09 04:06:37 +00:00
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) {
2020-03-09 04:06:37 +00:00
await scrapeScenes(argv.scene);
if (argv.movie) {
2020-03-09 04:06:37 +00:00
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);
await storeReleases(releases);
}
2019-11-17 02:56:45 +00:00
}
if (argv.actors && argv.actors.length === 0) {
await scrapeBasicActors();
}
if (argv.updateSearch) {
await updateReleasesSearch();
}
if (argv.server) {
await initServer();
return;
}
knex.destroy();
}
*/
2019-12-09 04:00:49 +00:00
module.exports = init;