Building user posts object after fetching user to ensure user fetched posts and directly fetched posts are added to the same user key. Refactor to make better use of functions. Moved profile detail saving call to content fetch. No longer attempting and failing to save profile details for deleted users (directory would not exist).

This commit is contained in:
2024-09-11 05:16:56 +02:00
parent 5eb2eb651a
commit 952392e0d9
11 changed files with 199 additions and 157 deletions
+35 -31
View File
@@ -3,34 +3,38 @@
const config = require('config');
const yargs = require('yargs');
module.exports = yargs.command('npm start -- --user <username>').option('users', {
alias: 'user',
describe: 'Reddit usernames to fetch posts from',
type: 'array'
}).option('posts', {
alias: 'post',
describe: 'Reddit post IDs to fetch',
type: 'array'
}).option('limit', {
describe: 'Maximum amount of posts to fetch per supplied user (!), after filtering out ignored, cross- and reposts',
type: 'number',
default: config.fetch.limit
}).option('sort', {
describe: 'Property to sort posts by',
choices: ['new', 'top', 'hot', 'controversial'],
default: config.fetch.sort
}).option('ignore', {
describe: 'Ignore posts with any of these properties',
type: 'array',
choices: ['pinned', 'stickied', 'hidden', 'spoiler', 'over_18']
}).option('include', {
describe: 'Include only these sources',
type: 'array'
}).option('exclude', {
describe: 'Do not include these sources',
type: 'array'
}).option('archives', {
describe: 'Search archives for deleted posts',
type: 'boolean',
default: config.fetch.archives.search
}).argv;
function getArgs() {
return yargs.command('npm start -- --user <username>').option('users', {
alias: 'user',
describe: 'Reddit usernames to fetch posts from',
type: 'array',
}).option('posts', {
alias: 'post',
describe: 'Reddit post IDs to fetch',
type: 'array',
}).option('limit', {
describe: 'Maximum amount of posts to fetch per supplied user (!), after filtering out ignored, cross- and reposts',
type: 'number',
default: config.fetch.limit,
}).option('sort', {
describe: 'Property to sort posts by',
choices: ['new', 'top', 'hot', 'controversial'],
default: config.fetch.sort,
}).option('ignore', {
describe: 'Ignore posts with any of these properties',
type: 'array',
choices: ['pinned', 'stickied', 'hidden', 'spoiler', 'over_18'],
}).option('include', {
describe: 'Include only these sources',
type: 'array',
}).option('exclude', {
describe: 'Do not include these sources',
type: 'array',
}).option('archives', {
describe: 'Search archives for deleted posts',
type: 'boolean',
default: config.fetch.archives.search,
}).argv;
}
module.exports = getArgs;