2024-09-11 03:16:55 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const util = require('util');
|
|
|
|
const config = require('config');
|
|
|
|
const path = require('path');
|
|
|
|
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
|
|
|
|
|
|
|
function vidbleImage(post) {
|
2024-09-11 03:16:55 +00:00
|
|
|
return fetch(`https://vidble.com/${post.host.id}`).then(res => {
|
2024-09-11 03:16:55 +00:00
|
|
|
if(res.status !== 200) {
|
2024-09-11 03:16:55 +00:00
|
|
|
throw new Error(`Could not fetch info for vidble album '${post.host.id}': '${res.error}'`);
|
2024-09-11 03:16:55 +00:00
|
|
|
}
|
|
|
|
|
2024-09-11 03:16:55 +00:00
|
|
|
return res.text();
|
|
|
|
}).then(res => {
|
|
|
|
const resource = $('img', res).attr('src');
|
2024-09-11 03:16:55 +00:00
|
|
|
|
2024-09-11 03:16:55 +00:00
|
|
|
return {
|
|
|
|
album: null,
|
|
|
|
items: [{
|
|
|
|
id: post.host.id,
|
|
|
|
url: `https://vidble.com/${resource}`,
|
|
|
|
title: post.title,
|
|
|
|
datetime: post.datetime,
|
|
|
|
type: mime.lookup(resource),
|
|
|
|
original: post
|
|
|
|
}]
|
|
|
|
};
|
2024-09-11 03:16:55 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = vidbleImage;
|