forked from DebaucheryLibrarian/traxxx
Added actor flush, renamed inconsistent actor flush to actor delete.
This commit is contained in:
parent
dbfbd1f04d
commit
80b8fe3654
|
@ -8,6 +8,7 @@ const blake2 = require('blake2');
|
||||||
const DOMPurify = require('dompurify');
|
const DOMPurify = require('dompurify');
|
||||||
const { JSDOM } = require('jsdom');
|
const { JSDOM } = require('jsdom');
|
||||||
const omit = require('object.omit');
|
const omit = require('object.omit');
|
||||||
|
const inquirer = require('inquirer');
|
||||||
|
|
||||||
const { window } = new JSDOM('');
|
const { window } = new JSDOM('');
|
||||||
const domPurify = DOMPurify(window);
|
const domPurify = DOMPurify(window);
|
||||||
|
@ -973,7 +974,7 @@ async function flushProfiles(actorIdsOrNames) {
|
||||||
logger.info(`Removed ${deleteCount} profiles`);
|
logger.info(`Removed ${deleteCount} profiles`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function flushActors(actorIdsOrNames) {
|
async function deleteActors(actorIdsOrNames) {
|
||||||
const actors = await knex('actors')
|
const actors = await knex('actors')
|
||||||
.whereIn('id', actorIdsOrNames.filter(idOrName => typeof idOrName === 'number'))
|
.whereIn('id', actorIdsOrNames.filter(idOrName => typeof idOrName === 'number'))
|
||||||
.orWhere((builder) => {
|
.orWhere((builder) => {
|
||||||
|
@ -1002,8 +1003,31 @@ async function flushActors(actorIdsOrNames) {
|
||||||
logger.info(`Removed ${deletedActorsCount} actors with ${deletedScenesCount} scenes`);
|
logger.info(`Removed ${deletedActorsCount} actors with ${deletedScenesCount} scenes`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function flushActors() {
|
||||||
|
const actorIds = await knex('actors').select('id').pluck('id');
|
||||||
|
|
||||||
|
const confirmed = await inquirer.prompt([{
|
||||||
|
type: 'confirm',
|
||||||
|
name: 'flushActors',
|
||||||
|
message: `You are about to remove ${actorIds.length} actors. Are you sure?`,
|
||||||
|
default: false,
|
||||||
|
}]);
|
||||||
|
|
||||||
|
if (!confirmed.flushActors) {
|
||||||
|
logger.warn('Confirmation rejected, not flushing actors');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleteCount = await deleteActors(actorIds);
|
||||||
|
|
||||||
|
await flushOrphanedMedia();
|
||||||
|
|
||||||
|
logger.info(`Removed ${deleteCount}/${actorIds.length} actors`);
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
associateActors,
|
associateActors,
|
||||||
|
deleteActors,
|
||||||
fetchActor,
|
fetchActor,
|
||||||
flushActors,
|
flushActors,
|
||||||
flushProfiles,
|
flushProfiles,
|
||||||
|
|
|
@ -9,7 +9,7 @@ const knex = require('./knex');
|
||||||
const fetchUpdates = require('./updates');
|
const fetchUpdates = require('./updates');
|
||||||
const { fetchScenes, fetchMovies } = require('./deep');
|
const { fetchScenes, fetchMovies } = require('./deep');
|
||||||
const { storeScenes, storeMovies, updateReleasesSearch, associateMovieScenes } = require('./store-releases');
|
const { storeScenes, storeMovies, updateReleasesSearch, associateMovieScenes } = require('./store-releases');
|
||||||
const { scrapeActors, flushActors, flushProfiles, interpolateProfiles } = require('./actors');
|
const { scrapeActors, deleteActors, flushActors, flushProfiles, interpolateProfiles } = require('./actors');
|
||||||
const { flushEntities } = require('./entities');
|
const { flushEntities } = require('./entities');
|
||||||
const { deleteScenes, deleteMovies, flushScenes, flushMovies, flushBatches } = require('./releases');
|
const { deleteScenes, deleteMovies, flushScenes, flushMovies, flushBatches } = require('./releases');
|
||||||
const { flushOrphanedMedia } = require('./media');
|
const { flushOrphanedMedia } = require('./media');
|
||||||
|
@ -53,6 +53,10 @@ async function init() {
|
||||||
await flushMovies();
|
await flushMovies();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argv.deleteActors) {
|
||||||
|
await deleteActors(argv.deleteActors);
|
||||||
|
}
|
||||||
|
|
||||||
if (argv.deleteScenes) {
|
if (argv.deleteScenes) {
|
||||||
await deleteScenes(argv.deleteScenes);
|
await deleteScenes(argv.deleteScenes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,7 +269,7 @@ const { argv } = yargs
|
||||||
alias: 'flush-network',
|
alias: 'flush-network',
|
||||||
})
|
})
|
||||||
.option('flush-actors', {
|
.option('flush-actors', {
|
||||||
describe: 'Delete actors with profiles and scenes.',
|
describe: 'Flush all actors and their scenes.',
|
||||||
type: 'array',
|
type: 'array',
|
||||||
alias: 'flush-actor',
|
alias: 'flush-actor',
|
||||||
})
|
})
|
||||||
|
@ -291,6 +291,11 @@ const { argv } = yargs
|
||||||
describe: 'Remove all movies.',
|
describe: 'Remove all movies.',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
})
|
})
|
||||||
|
.option('delete-actors', {
|
||||||
|
describe: 'Remove actors by ID.',
|
||||||
|
type: 'array',
|
||||||
|
alias: ['delete-actor', 'remove-actors', 'remove-actor'],
|
||||||
|
})
|
||||||
.option('delete-scenes', {
|
.option('delete-scenes', {
|
||||||
describe: 'Remove scenes by ID.',
|
describe: 'Remove scenes by ID.',
|
||||||
type: 'array',
|
type: 'array',
|
||||||
|
|
Loading…
Reference in New Issue