Improved and documented actor profile scraping.

This commit is contained in:
DebaucheryLibrarian
2020-08-12 20:51:08 +02:00
parent 5cabeed19d
commit 7413d7db25
5 changed files with 64 additions and 32 deletions

View File

@@ -2,6 +2,22 @@
const config = require('config');
const yargs = require('yargs');
const moment = require('moment');
function interpretAfter(after) {
if (/\d{2,4}-\d{2}-\d{2,4}/.test(after)) {
// using date
return moment
.utc(after, ['YYYY-MM-DD', 'DD-MM-YYYY'])
.toDate();
}
// using time distance (e.g. "1 month")
return moment
.utc()
.subtract(...after.split(' '))
.toDate();
}
const { argv } = yargs
.command('npm start')
@@ -30,16 +46,25 @@ const { argv } = yargs
type: 'array',
alias: 'actor',
})
.option('actors-update', {
describe: 'Rescrape actors last updated before this period',
type: 'string',
})
.option('actors-file', {
describe: 'Scrape actors names from file',
type: 'string',
})
.option('actor-scenes', {
.option('actors-scenes', {
describe: 'Fetch all scenes for an actor',
type: 'boolean',
alias: 'with-scenes',
alias: 'actor-scenes',
default: false,
})
.option('actors-sources', {
describe: 'Use these scrapers for actor data',
type: 'array',
alias: 'actor-source',
})
.option('movie-scenes', {
describe: 'Fetch all scenes for a movie',
type: 'boolean',
@@ -70,11 +95,6 @@ const { argv } = yargs
describe: 'Scrape movie info from URL',
type: 'array',
})
.option('sources', {
describe: 'Use these scrapers for actor data',
type: 'array',
alias: 'source',
})
.option('deep', {
describe: 'Fetch details for all releases',
type: 'boolean',
@@ -204,6 +224,8 @@ const { argv } = yargs
describe: 'Update search documents for all releases.',
type: 'boolean',
default: false,
});
})
.coerce('after', interpretAfter)
.coerce('actors-update', interpretAfter);
module.exports = argv;