Compare commits
2 Commits
f7fd5fb542
...
133846378b
Author | SHA1 | Date |
---|---|---|
|
133846378b | |
|
2e923f2dcb |
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "ripunzel",
|
"name": "ripunzel",
|
||||||
"version": "1.27.0",
|
"version": "1.27.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ripunzel",
|
"name": "ripunzel",
|
||||||
"version": "1.27.0",
|
"version": "1.27.1",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"array.prototype.flatten": "^1.2.1",
|
"array.prototype.flatten": "^1.2.1",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "ripunzel",
|
"name": "ripunzel",
|
||||||
"version": "1.27.0",
|
"version": "1.27.1",
|
||||||
"description": "Web content archiving tool, with versatile filename patterns and extensive options for reddit user profiles.",
|
"description": "Web content archiving tool, with versatile filename patterns and extensive options for reddit user profiles.",
|
||||||
"main": "app.js",
|
"main": "app.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function curateComments(comments) {
|
function curateComments(comments) {
|
||||||
return comments.map(comment => ({
|
return comments.map((comment) => ({
|
||||||
id: comment.id,
|
id: comment.id,
|
||||||
url: `https://reddit.com${comment.permalink}`,
|
url: `https://reddit.com${comment.permalink}`,
|
||||||
author: comment.author.name,
|
author: comment.author.name,
|
||||||
|
@ -31,7 +31,7 @@ async function getFullPost(postId, reddit) {
|
||||||
.fetch();
|
.fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function self(host, originalPost, reddit) {
|
async function self(host, originalPost, { reddit }) {
|
||||||
const post = await getFullPost(originalPost.id, reddit) || originalPost;
|
const post = await getFullPost(originalPost.id, reddit) || originalPost;
|
||||||
const curatedComments = curateComments(post.comments);
|
const curatedComments = curateComments(post.comments);
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,12 @@ async function writeBufferToFile(target, buffer, item) {
|
||||||
|
|
||||||
async function save(requestedFilepath, bufferOrBuffers, item) {
|
async function save(requestedFilepath, bufferOrBuffers, item) {
|
||||||
const pathElements = getPathElements(requestedFilepath);
|
const pathElements = getPathElements(requestedFilepath);
|
||||||
const buffers = [].concat(bufferOrBuffers); // allow for single stream argument
|
const buffers = [].concat(bufferOrBuffers).filter(Boolean); // allow for single stream argument
|
||||||
|
|
||||||
|
if (buffers.length === 0) {
|
||||||
|
logger.warn(`Received undefined buffer (${item.url})`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
await fs.ensureDir(pathElements.dir);
|
await fs.ensureDir(pathElements.dir);
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,9 @@ async function getIndex(user) {
|
||||||
try {
|
try {
|
||||||
const indexFile = await fs.readFile(indexFilePath, 'utf8');
|
const indexFile = await fs.readFile(indexFilePath, 'utf8');
|
||||||
|
|
||||||
return yaml.safeLoad(indexFile);
|
return yaml.safeLoad(indexFile, { json: true }); // allow duplicate keys
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.info(`No index file found for '${user.name}' at '${indexFilePath}'`);
|
logger.info(`No index file found for '${user.name}' at '${indexFilePath}': ${error.message}`);
|
||||||
|
|
||||||
return { profile: { image: null, description: null }, posts: [] };
|
return { profile: { image: null, description: null }, posts: [] };
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue