2024-09-11 03:16:57 +00:00
|
|
|
'use strict';
|
2024-09-11 03:16:55 +00:00
|
|
|
|
|
|
|
const fetch = require('node-fetch');
|
|
|
|
const $ = require('cheerio');
|
2024-09-11 03:16:55 +00:00
|
|
|
const mime = require('mime-types');
|
2024-09-11 03:16:55 +00:00
|
|
|
|
2024-09-11 03:16:57 +00:00
|
|
|
async function vidbleImage(host, post) {
|
|
|
|
const res = await fetch(`https://vidble.com/${host.id}`);
|
2024-09-11 03:16:55 +00:00
|
|
|
|
2024-09-11 03:16:57 +00:00
|
|
|
if (res.status !== 200) {
|
|
|
|
throw new Error(`Could not fetch info for vidble album '${host.id}': '${res.error}'`);
|
|
|
|
}
|
2024-09-11 03:16:55 +00:00
|
|
|
|
2024-09-11 03:16:57 +00:00
|
|
|
const html = await res.text();
|
|
|
|
const resource = $('img', html).attr('src');
|
|
|
|
|
|
|
|
return {
|
|
|
|
album: null,
|
|
|
|
items: [{
|
|
|
|
id: host.id,
|
|
|
|
url: `https://vidble.com/${resource}`,
|
|
|
|
title: post ? post.title : null,
|
|
|
|
datetime: post ? post.datetime : null,
|
|
|
|
type: mime.lookup(resource),
|
|
|
|
original: post || null,
|
|
|
|
}],
|
|
|
|
};
|
|
|
|
}
|
2024-09-11 03:16:55 +00:00
|
|
|
|
|
|
|
module.exports = vidbleImage;
|