Added support for RedGifs and Reddit albums. Improved command line logger. Added rate limiters for reddit and host URLs.

This commit is contained in:
2024-09-11 05:16:58 +02:00
parent bb06fe9763
commit de50d609f3
33 changed files with 586 additions and 256 deletions

View File

@@ -6,6 +6,7 @@ const yaml = require('js-yaml');
const interpolate = require('../interpolate');
// const textToStream = require('./textToStream');
const save = require('./save');
const logger = require('../logger')(__filename);
async function writeToIndex(posts, profilePaths, user, args) {
const filepath = interpolate(config.library.index.file, null, null, null, null, user, false);
@@ -44,8 +45,14 @@ async function writeToIndex(posts, profilePaths, user, args) {
return false;
}
// return save(filepath, textToStream(yaml.safeDump(data)));
return save(filepath, Buffer.from(yaml.safeDump(data), 'utf8'));
try {
const yamlIndex = yaml.safeDump(data);
return save(filepath, Buffer.from(yamlIndex, 'utf8'));
} catch (error) {
logger.error(`Could not save index for ${user.username}: ${error.message}`);
return null;
}
}
module.exports = writeToIndex;