From ccfdc16ca8cdcabd2724175ef0a75355aa8bf344 Mon Sep 17 00:00:00 2001 From: Niels Simenon Date: Fri, 27 Apr 2018 23:14:48 +0200 Subject: [PATCH] Added reddit avatar URL detection and avoid option. --- config/default.js | 7 ++++--- src/save/profileDetails.js | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/config/default.js b/config/default.js index 3757a17..e07557d 100644 --- a/config/default.js +++ b/config/default.js @@ -5,13 +5,14 @@ module.exports = { video: '$base$postDate - $itemId - $postTitle$ext', text: '$base$postDate - $postId - $postTitle', album: { - extractSingleItem: true, image: '$base$postDate - $albumId - $postTitle/$itemIndex - $itemId$ext', - video: '$base$postDate - $albumId - $postTitle/$itemIndex - $itemId$ext' + video: '$base$postDate - $albumId - $postTitle/$itemIndex - $itemId$ext', + extractSingleItem: true }, profile: { image: '$base$userCreated - profile$ext', - description: '$base$userCreated - profile ($userVerified$userVerifiedEmail$userGold$profileOver18)' + description: '$base$userCreated - profile ($userVerified$userVerifiedEmail$userGold$profileOver18)', + avoidAvatar: true }, booleans: { extracted: 'extracted-', diff --git a/src/save/profileDetails.js b/src/save/profileDetails.js index f159849..e71ce33 100644 --- a/src/save/profileDetails.js +++ b/src/save/profileDetails.js @@ -1,6 +1,7 @@ 'use strict'; const config = require('config'); +const urlPattern = require('url-pattern'); const interpolate = require('../interpolate.js'); const fetchItem = require('../fetch/item.js'); @@ -11,6 +12,12 @@ function saveProfileDetails(user) { if(config.library.profile.image) { const image = user.profile ? user.profile.image : user.image; + if(config.library.profile.ignoreAvatar && new urlPattern('http(s)\\://(www.)redditstatic.com/avatars/:id(.:ext)(?:query)').match(image)) { + console.log('\x1b[33m%s\x1b[0m', `Ignoring standard avatar profile image for '${user.name}'`); + + return user; + } + const filepath = interpolate(config.library.profile.image, user, null, { // pass profile image as item to interpolate extension variable url: image