Added after/before-index alias for after/before-indexed

This commit is contained in:
ThePendulum 2018-07-08 00:18:51 +02:00
parent e7af52bc01
commit aa1c612306
3 changed files with 27 additions and 22 deletions

View File

@ -58,10 +58,12 @@ function getArgs() {
describe: 'Only include posts before this date (YYYY-MM-DD, optionally HH:mm)', describe: 'Only include posts before this date (YYYY-MM-DD, optionally HH:mm)',
}) })
.option('after-indexed', { .option('after-indexed', {
alias: 'after-index',
describe: 'Only include posts after the oldest or the latest entry in the index', describe: 'Only include posts after the oldest or the latest entry in the index',
choices: ['oldest', 'latest'], choices: ['oldest', 'latest'],
}) })
.option('before-indexed', { .option('before-indexed', {
alias: 'before-index',
describe: 'Only include posts before the oldest or the latest entry in the index', describe: 'Only include posts before the oldest or the latest entry in the index',
choices: ['oldest', 'latest'], choices: ['oldest', 'latest'],
}) })

View File

@ -62,7 +62,7 @@ async function fetchSaveContent(user, ep, args) {
const streams = await getStreams(item, post); const streams = await getStreams(item, post);
// no streams, ignore item // no streams, ignore item
if (!streams || streams.length <= 0) { if (!streams || streams.length === 0) {
return accItems; return accItems;
} }

View File

@ -1,32 +1,35 @@
'use strict'; 'use strict';
const util = require('util');
const config = require('config'); const config = require('config');
const Promise = require('bluebird'); const Promise = require('bluebird');
const methods = require('../methods/methods.js'); const methods = require('../methods/methods.js');
const attachContentInfo = users => { const attachContentInfo = users => Promise.reduce(Object.values(users), async (accUsers, user) => ({
return Promise.reduce(Object.values(users), async (accUsers, user) => ({...accUsers, [user.name]: {...user, posts: await Promise.reduce(user.posts, async (accPosts, post) => { ...accUsers,
if(!post.host || !methods[post.host.method]) { [user.name]: {
console.log('\x1b[33m%s\x1b[0m', `Ignoring unsupported content '${post.url}' (${post.permalink})`); ...user,
posts: await Promise.reduce(user.posts, async (accPosts, post) => {
if (!post.host || !methods[post.host.method]) {
console.log('\x1b[33m%s\x1b[0m', `Ignoring unsupported content '${post.url}' (${post.permalink})`);
return accPosts; return accPosts;
}
try {
return [...accPosts, {...post, content: await methods[post.host.method](post)}];
} catch(error) {
console.log('\x1b[31m%s\x1b[0m', `${error} (${post.permalink})`);
if(config.fetch.archives.preview && post.preview) {
console.log(`Found preview images for unavailable source '${post.url}' (${post.permalink})`);
return [...accPosts, {...post, previewFallback: true, content: await methods.redditPreview(post)}];
} }
return accPosts; try {
} return [...accPosts, { ...post, content: await methods[post.host.method](post) }];
}, [])}}), {}); } catch (error) {
}; console.log('\x1b[31m%s\x1b[0m', `${error} (${post.permalink})`);
if (config.fetch.archives.preview && post.preview) {
console.log(`Found preview images for unavailable source '${post.url}' (${post.permalink})`);
return [...accPosts, { ...post, previewFallback: true, content: await methods.redditPreview(post) }];
}
return accPosts;
}
}, []),
},
}), {});
module.exports = attachContentInfo; module.exports = attachContentInfo;