Added support for redd.it PNG.

This commit is contained in:
DebaucheryLibrarian 2024-09-11 05:16:54 +02:00
parent 304566e5bd
commit 2d050be1a5
3 changed files with 16 additions and 7 deletions

7
src/extensions.json Normal file
View File

@ -0,0 +1,7 @@
{
"image/jpeg": ".jpg",
"image/png": ".png",
"image/gif": ".gif",
"video/mp4": ".mp4",
"video/webm": ".webm"
}

View File

@ -5,12 +5,7 @@ const path = require('path');
const url = require('url'); const url = require('url');
const dateFns = require('date-fns'); const dateFns = require('date-fns');
const extensions = { const extensions = require('./extensions.json');
'image/jpeg': '.jpg',
'image/gif': '.gif',
'video/mp4': '.mp4',
'video/webm': '.webm'
};
function interpolate(pattern, user, post, item) { function interpolate(pattern, user, post, item) {
const dateFormat = config.library.dateFormat || 'YYYYMMDD'; const dateFormat = config.library.dateFormat || 'YYYYMMDD';

View File

@ -2,8 +2,15 @@
const util = require('util'); const util = require('util');
const config = require('config'); const config = require('config');
const path = require('path');
const fetch = require('node-fetch'); const fetch = require('node-fetch');
const extensions = require('../extensions.json');
function reverseLookup(extension) {
return Object.keys(extensions).find(mime => extensions[mime] === extension);
};
function redditImage(post) { function redditImage(post) {
return Promise.resolve({ return Promise.resolve({
album: null, album: null,
@ -12,7 +19,7 @@ function redditImage(post) {
url: post.url, url: post.url,
title: post.title, title: post.title,
datetime: post.datetime, datetime: post.datetime,
type: 'image/jpeg', type: reverseLookup(path.extname(post.url)),
original: post original: post
}] }]
}); });