Improved and documented actor profile scraping.
This commit is contained in:
38
src/argv.js
38
src/argv.js
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user