Added vidble direct video (/watch?v=) support.

This commit is contained in:
DebaucheryLibrarian 2024-09-11 05:16:55 +02:00
parent 761f722147
commit 4e0fe3e6bc
3 changed files with 41 additions and 0 deletions

View File

@ -30,6 +30,10 @@ const hosts = [{
method: 'vidbleImage', method: 'vidbleImage',
label: 'vidble', label: 'vidble',
pattern: new urlPattern('http(s)\\://(www.)vidble.com/(show/):id(.:ext)') pattern: new urlPattern('http(s)\\://(www.)vidble.com/(show/):id(.:ext)')
}, {
method: 'vidbleVideo',
label: 'vidble',
pattern: new urlPattern('http(s)\\://(www.)vidble.com/watch?v=:id')
}, { }, {
method: 'vidbleAlbum', method: 'vidbleAlbum',
label: 'vidble', label: 'vidble',

View File

@ -7,6 +7,7 @@ const redditPreview = require('./redditPreview.js');
const imgurImage = require('./imgurImage.js'); const imgurImage = require('./imgurImage.js');
const imgurAlbum = require('./imgurAlbum.js'); const imgurAlbum = require('./imgurAlbum.js');
const vidbleImage = require('./vidbleImage.js'); const vidbleImage = require('./vidbleImage.js');
const vidbleVideo = require('./vidbleVideo.js');
const vidbleAlbum = require('./vidbleAlbum.js'); const vidbleAlbum = require('./vidbleAlbum.js');
const gfycat = require('./gfycat.js'); const gfycat = require('./gfycat.js');
const eroshareAlbum = require('./eroshareAlbum.js'); const eroshareAlbum = require('./eroshareAlbum.js');
@ -20,6 +21,7 @@ module.exports = {
imgurImage, imgurImage,
imgurAlbum, imgurAlbum,
vidbleImage, vidbleImage,
vidbleVideo,
vidbleAlbum, vidbleAlbum,
gfycat, gfycat,
eroshareAlbum, eroshareAlbum,

View File

@ -0,0 +1,35 @@
'use strict';
const util = require('util');
const config = require('config');
const fetch = require('node-fetch');
const cheerio = require('cheerio');
function vidbleVideo(post) {
return fetch(`https://www.vidble.com/watch?v=${post.host.id}`).then(res => {
if(res.status !== 200) {
throw new Error(`Could not fetch info for vidble video '${post.host.id}': '${res.error}'`);
}
return res.text();
}).then(res => {
const $ = cheerio.load(res);
const resource = $('video source');
const source = resource.attr('src');
const type = resource.attr('type');
return {
album: null,
items: [{
id: post.host.id,
url: `https://vidble.com/${source}`,
title: post.title,
datetime: post.datetime,
type: type,
original: post
}]
};
});
};
module.exports = vidbleVideo;