Added support for redd.it PNG.
This commit is contained in:
parent
acc7032c4c
commit
5b27099028
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"image/jpeg": ".jpg",
|
||||||
|
"image/png": ".png",
|
||||||
|
"image/gif": ".gif",
|
||||||
|
"video/mp4": ".mp4",
|
||||||
|
"video/webm": ".webm"
|
||||||
|
}
|
|
@ -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';
|
||||||
|
|
|
@ -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
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue