2018-04-16 21:46:39 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const util = require('util');
|
|
|
|
const config = require('config');
|
|
|
|
const fetch = require('node-fetch');
|
|
|
|
|
2018-04-17 22:18:04 +00:00
|
|
|
function gfycat(post) {
|
2018-04-16 21:46:39 +00:00
|
|
|
return fetch(`https://api.gfycat.com/v1/gfycats/${post.host.id}`, {
|
|
|
|
headers: {
|
|
|
|
'Authorization': `Bearer ${config.methods.gfycat.key}`
|
|
|
|
}
|
|
|
|
}).then(res => res.json()).then(res => {
|
|
|
|
return {
|
|
|
|
album: null,
|
|
|
|
items: [{
|
|
|
|
id: res.gfyItem.gfyName,
|
|
|
|
url: res.gfyItem.webmUrl,
|
|
|
|
title: res.gfyItem.title,
|
|
|
|
description: res.gfyItem.description,
|
|
|
|
type: 'video/webm',
|
|
|
|
datetime: res.gfyItem.createDate * 1000,
|
|
|
|
original: res.gfyItem
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
}).catch(error => {
|
2018-04-17 22:18:04 +00:00
|
|
|
console.error(error);
|
2018-04-16 21:46:39 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2018-04-17 22:18:04 +00:00
|
|
|
module.exports = gfycat;
|