Refactored post fetching. Cleaner code that will now fetch archived posts even if the user no longer exists on reddit. Expanded gfycat URL detection.
This commit is contained in:
@@ -9,7 +9,7 @@ const textToStream = require('./textToStream.js');
|
||||
const save = require('./save.js');
|
||||
|
||||
function saveProfileDetails(user) {
|
||||
if(config.library.profile.image) {
|
||||
if(config.library.profile.image && !user.fallback) {
|
||||
const image = user.profile ? user.profile.image : user.image;
|
||||
|
||||
if(config.library.profile.avoidAvatar && new urlPattern('http(s)\\://(www.)redditstatic.com/avatars/:id(.:ext)(?:query)').match(image)) {
|
||||
@@ -20,13 +20,13 @@ function saveProfileDetails(user) {
|
||||
url: image
|
||||
});
|
||||
|
||||
fetchItem(image).then(stream => save(filepath, stream)).catch(error => {
|
||||
fetchItem(image, 0, {permalink: `https://reddit.com/user/${user.name}`}).then(stream => save(filepath, stream)).catch(error => {
|
||||
console.log('\x1b[33m%s\x1b[0m', `Could not save profile image for '${user.name}': ${error}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if(config.library.profile.description) {
|
||||
if(config.library.profile.description && !user.fallback) {
|
||||
if(user.profile && user.profile.description) {
|
||||
const filepath = interpolate(config.library.profile.description, user);
|
||||
const stream = textToStream(user.profile.description);
|
||||
|
||||
Reference in New Issue
Block a user