Fixed gfycat fetching.
This commit is contained in:
parent
d7916af3d5
commit
c21ca0df0c
|
@ -0,0 +1,32 @@
|
|||
'use strict';
|
||||
|
||||
const util = require('util');
|
||||
const config = require('config');
|
||||
const fetch = require('node-fetch');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const base = 'https://www.erome.com/';
|
||||
|
||||
function erome(post) {
|
||||
return fetch(`${base}a/${post.host.id}`).then(res => {
|
||||
if(res.ok) {
|
||||
return res.text();
|
||||
}
|
||||
|
||||
throw new Error(`Unable to retrieve info for Erome album '${post.host.id}' :(`);
|
||||
}).then(res => {
|
||||
const $ = cheerio.load(res);
|
||||
const videoUrls = $('video').toArray().map(videoEl => {
|
||||
const sourceHd = $(videoEl).find('source[label="HD"]');
|
||||
const sourceSd = $(videoEl).find('source[label="SD"]');
|
||||
|
||||
console.log(sourceHd.attr('src'));
|
||||
|
||||
return sourceHd ? base + sourceHd.attr('src') : base + sourceSd.attr('src');
|
||||
});
|
||||
|
||||
console.log(videoUrls);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = erome;
|
|
@ -3,7 +3,7 @@
|
|||
const fetch = require('node-fetch');
|
||||
|
||||
async function gfycat(post) {
|
||||
const res = await fetch(`https://gfycat.com/cajax/get/${post.host.id}`);
|
||||
const res = await fetch(`https://api.gfycat.com/v1/gfycats/${post.host.id}`);
|
||||
const data = await res.json();
|
||||
|
||||
if (data.error) {
|
||||
|
|
Loading…
Reference in New Issue