2018-04-15 02:51:02 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const util = require('util');
|
|
|
|
const config = require('config');
|
|
|
|
const fetch = require('node-fetch');
|
|
|
|
|
|
|
|
function imgurAlbum(post) {
|
|
|
|
return fetch(`https://api.imgur.com/3/album/${post.host.id}`, {
|
|
|
|
headers: {
|
|
|
|
'Authorization': `Client-ID ${config.methods.imgur.clientId}`
|
|
|
|
}
|
|
|
|
}).then(res => res.json()).then(res => {
|
|
|
|
return {
|
|
|
|
album: {
|
|
|
|
id: res.data.id,
|
|
|
|
url: res.data.link,
|
|
|
|
title: res.data.title,
|
|
|
|
description: res.data.description,
|
2018-04-16 21:46:39 +00:00
|
|
|
datetime: res.data.datetime * 1000,
|
2018-04-15 02:51:02 +00:00
|
|
|
original: res.data
|
|
|
|
},
|
|
|
|
items: res.data.images.map(item => ({
|
|
|
|
id: item.id,
|
|
|
|
url: item.link,
|
|
|
|
title: item.title,
|
|
|
|
description: item.description,
|
2018-04-16 21:46:39 +00:00
|
|
|
datetime: item.datetime * 1000,
|
2018-04-15 02:51:02 +00:00
|
|
|
type: item.type,
|
|
|
|
original: item
|
|
|
|
}))
|
|
|
|
};
|
|
|
|
}).catch(error => {
|
2018-04-17 22:18:04 +00:00
|
|
|
console.error(error);
|
2018-04-15 02:51:02 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = imgurAlbum;
|