2018-04-15 02:51:02 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const note = require('note-log');
|
|
|
|
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 => {
|
|
|
|
note(error);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = imgurAlbum;
|