Added reddit avatar URL detection and avoid option.

This commit is contained in:
ThePendulum 2018-04-27 23:14:48 +02:00
parent d550b88d57
commit ccfdc16ca8
2 changed files with 11 additions and 3 deletions

View File

@ -5,13 +5,14 @@ module.exports = {
video: '$base$postDate - $itemId - $postTitle$ext', video: '$base$postDate - $itemId - $postTitle$ext',
text: '$base$postDate - $postId - $postTitle', text: '$base$postDate - $postId - $postTitle',
album: { album: {
extractSingleItem: true,
image: '$base$postDate - $albumId - $postTitle/$itemIndex - $itemId$ext', 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: { profile: {
image: '$base$userCreated - profile$ext', image: '$base$userCreated - profile$ext',
description: '$base$userCreated - profile ($userVerified$userVerifiedEmail$userGold$profileOver18)' description: '$base$userCreated - profile ($userVerified$userVerifiedEmail$userGold$profileOver18)',
avoidAvatar: true
}, },
booleans: { booleans: {
extracted: 'extracted-', extracted: 'extracted-',

View File

@ -1,6 +1,7 @@
'use strict'; 'use strict';
const config = require('config'); const config = require('config');
const urlPattern = require('url-pattern');
const interpolate = require('../interpolate.js'); const interpolate = require('../interpolate.js');
const fetchItem = require('../fetch/item.js'); const fetchItem = require('../fetch/item.js');
@ -11,6 +12,12 @@ function saveProfileDetails(user) {
if(config.library.profile.image) { if(config.library.profile.image) {
const image = user.profile ? user.profile.image : user.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, { const filepath = interpolate(config.library.profile.image, user, null, {
// pass profile image as item to interpolate extension variable // pass profile image as item to interpolate extension variable
url: image url: image