2024-09-11 03:16:53 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const util = require('util');
|
|
|
|
const config = require('config');
|
|
|
|
const fetch = require('node-fetch');
|
|
|
|
|
|
|
|
function imgurImage(post) {
|
|
|
|
return fetch(`https://api.imgur.com/3/image/${post.host.id}`, {
|
|
|
|
headers: {
|
|
|
|
'Authorization': `Client-ID ${config.methods.imgur.clientId}`
|
|
|
|
}
|
|
|
|
}).then(res => res.json()).then(res => {
|
|
|
|
return {
|
|
|
|
album: null,
|
|
|
|
items: [{
|
|
|
|
id: res.data.id,
|
2024-09-11 03:16:53 +00:00
|
|
|
url: res.data.animated ? res.data.mp4 : res.data.link,
|
2024-09-11 03:16:53 +00:00
|
|
|
title: res.data.title,
|
|
|
|
description: res.data.description,
|
2024-09-11 03:16:53 +00:00
|
|
|
type: res.data.animated ? 'video/mp4' : res.data.type,
|
|
|
|
datetime: new Date(res.data.datetime * 1000),
|
2024-09-11 03:16:53 +00:00
|
|
|
original: res.data
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
}).catch(error => {
|
2024-09-11 03:16:53 +00:00
|
|
|
console.error(error);
|
2024-09-11 03:16:53 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = imgurImage;
|