Added support for redd.it PNG.

This commit is contained in:
ThePendulum 2018-05-01 02:56:56 +02:00
parent acc7032c4c
commit 5b27099028
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 dateFns = require('date-fns');
const extensions = {
'image/jpeg': '.jpg',
'image/gif': '.gif',
'video/mp4': '.mp4',
'video/webm': '.webm'
};
const extensions = require('./extensions.json');
function interpolate(pattern, user, post, item) {
const dateFormat = config.library.dateFormat || 'YYYYMMDD';

View File

@ -2,8 +2,15 @@
const util = require('util');
const config = require('config');
const path = require('path');
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) {
return Promise.resolve({
album: null,
@ -12,7 +19,7 @@ function redditImage(post) {
url: post.url,
title: post.title,
datetime: post.datetime,
type: 'image/jpeg',
type: reverseLookup(path.extname(post.url)),
original: post
}]
});