From 9b0ef4da9133ff203fe86ca7ab42c3734ccd6cb8 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Wed, 11 Sep 2024 05:16:57 +0200 Subject: [PATCH] Added after/before-index alias for after/before-indexed --- src/cli.js | 2 ++ src/fetch/content.js | 2 +- src/fetch/info.js | 45 +++++++++++++++++++++++--------------------- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/cli.js b/src/cli.js index 5fd93f6..3ad8243 100644 --- a/src/cli.js +++ b/src/cli.js @@ -58,10 +58,12 @@ function getArgs() { describe: 'Only include posts before this date (YYYY-MM-DD, optionally HH:mm)', }) .option('after-indexed', { + alias: 'after-index', describe: 'Only include posts after the oldest or the latest entry in the index', choices: ['oldest', 'latest'], }) .option('before-indexed', { + alias: 'before-index', describe: 'Only include posts before the oldest or the latest entry in the index', choices: ['oldest', 'latest'], }) diff --git a/src/fetch/content.js b/src/fetch/content.js index 8c58edf..054299e 100644 --- a/src/fetch/content.js +++ b/src/fetch/content.js @@ -62,7 +62,7 @@ async function fetchSaveContent(user, ep, args) { const streams = await getStreams(item, post); // no streams, ignore item - if (!streams || streams.length <= 0) { + if (!streams || streams.length === 0) { return accItems; } diff --git a/src/fetch/info.js b/src/fetch/info.js index e91e993..c28bbfd 100644 --- a/src/fetch/info.js +++ b/src/fetch/info.js @@ -1,32 +1,35 @@ 'use strict'; -const util = require('util'); const config = require('config'); const Promise = require('bluebird'); const methods = require('../methods/methods.js'); -const attachContentInfo = users => { - return Promise.reduce(Object.values(users), async (accUsers, user) => ({...accUsers, [user.name]: {...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})`); +const attachContentInfo = users => Promise.reduce(Object.values(users), async (accUsers, user) => ({ + ...accUsers, + [user.name]: { + ...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; - } - - 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; } - 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;