Fixed gfycat fetching.

This commit is contained in:
DebaucheryLibrarian 2024-09-11 05:16:57 +02:00
parent d7916af3d5
commit c21ca0df0c
2 changed files with 33 additions and 1 deletions

32
src/methods/erome.js Normal file
View File

@ -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;

View File

@ -3,7 +3,7 @@
const fetch = require('node-fetch'); const fetch = require('node-fetch');
async function gfycat(post) { 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(); const data = await res.json();
if (data.error) { if (data.error) {