Added vidble image support.
This commit is contained in:
parent
2c58947548
commit
5165e8612d
|
@ -12,7 +12,7 @@ function redditImage(post) {
|
|||
url: post.url,
|
||||
title: post.title,
|
||||
datetime: post.datetime,
|
||||
type: mime.lookup(post.url),
|
||||
type: mime.lookup(post.url.split('/.')[0]),
|
||||
original: post
|
||||
}]
|
||||
});
|
||||
|
|
|
@ -17,14 +17,12 @@ function redditPreview(post) {
|
|||
original: post
|
||||
} : null,
|
||||
items: post.preview.map(image => {
|
||||
console.log(mime.lookup(image.url));
|
||||
|
||||
return {
|
||||
id: post.host.id || post.id,
|
||||
url: image.url,
|
||||
title: post.title,
|
||||
datetime: post.datetime,
|
||||
type: mime.lookup(image.url),
|
||||
type: mime.lookup(image.url.split('?')[0]),
|
||||
preview: true,
|
||||
original: post
|
||||
};
|
||||
|
|
|
@ -5,21 +5,29 @@ const config = require('config');
|
|||
const path = require('path');
|
||||
const fetch = require('node-fetch');
|
||||
const $ = require('cheerio');
|
||||
const mime = require('mime-types');
|
||||
|
||||
function vidbleImage(post) {
|
||||
return fetch(`https://vidble.com/${post.host.id}`).then(res => res.text()).then(res => {
|
||||
console.log(res, $('img'));
|
||||
|
||||
return fetch(`https://vidble.com/${post.host.id}`).then(res => {
|
||||
if(res.status !== 200) {
|
||||
throw new Error(`Could not fetch info for vidble album '${post.host.id}': '${res.data.error}'`);
|
||||
throw new Error(`Could not fetch info for vidble album '${post.host.id}': '${res.error}'`);
|
||||
}
|
||||
|
||||
const extract = config.library.album.extractSingleItem && res.data.images.length === 1;
|
||||
|
||||
if(extract) {
|
||||
console.log('\x1b[36m%s\x1b[0m', `Extracting single item from album '${post.title}' - ${res.data.link}`);
|
||||
}
|
||||
return res.text();
|
||||
}).then(res => {
|
||||
const resource = $('img', res).attr('src');
|
||||
|
||||
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
|
||||
}]
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue