Added groundwork for Eroshare support. Removed gfycat API requirement, using JSON output.
This commit is contained in:
41
methods/eroshare.js
Normal file
41
methods/eroshare.js
Normal file
@@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
|
||||
const util = require('util');
|
||||
const config = require('config');
|
||||
const fetch = require('node-fetch');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
function eroshare(post) {
|
||||
return fetch(`https://web.archive.org/web/20170630040157im_/https://eroshare.com/${post.host.id}`).then(res => {
|
||||
if(res.ok) {
|
||||
return res.text()
|
||||
}
|
||||
|
||||
return Promise.reject(`Unable to recover Eroshare video '${post.host.id}' :(`);
|
||||
}).then(res => {
|
||||
const $ = cheerio.load(res);
|
||||
|
||||
$('video').forEach(video => {
|
||||
console.log(video);
|
||||
});
|
||||
|
||||
/*
|
||||
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 => {
|
||||
console.log('\x1b[33m%s\x1b[0m', error);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = eroshare;
|
||||
@@ -5,11 +5,7 @@ const config = require('config');
|
||||
const fetch = require('node-fetch');
|
||||
|
||||
function gfycat(post) {
|
||||
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 fetch(`https://gfycat.com/cajax/get/${post.host.id}`).then(res => res.json()).then(res => {
|
||||
return {
|
||||
album: null,
|
||||
items: [{
|
||||
|
||||
@@ -5,11 +5,13 @@ const reddit = require('./reddit.js');
|
||||
const imgurImage = require('./imgurImage.js');
|
||||
const imgurAlbum = require('./imgurAlbum.js');
|
||||
const gfycat = require('./gfycat.js');
|
||||
const eroshare = require('./eroshare.js');
|
||||
|
||||
module.exports = {
|
||||
self: self,
|
||||
reddit: reddit,
|
||||
imgurImage: imgurImage,
|
||||
imgurAlbum: imgurAlbum,
|
||||
gfycat: gfycat
|
||||
gfycat: gfycat,
|
||||
eroshare: eroshare
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user