fix #50
This commit is contained in:
parent
6b626a5e14
commit
f5a070e6bd
|
@ -1,4 +1,5 @@
|
|||
module.exports = function() {
|
||||
const config = require('../config')
|
||||
this.processPostMedia = (obj, post, post_media, has_gif, reddit_video, gif_to_mp4) => {
|
||||
return new Promise(resolve => {
|
||||
(async () => {
|
||||
|
@ -123,6 +124,26 @@ module.exports = function() {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* Sometimes post has an image, but all the common keys which are implying
|
||||
* that the post has an iamge, are null or don't exist. Awesome Reddit!
|
||||
*/
|
||||
if(!post_media && !has_gif && !post.gallery_data && post.url != '') {
|
||||
try {
|
||||
let u = new URL(post.url)
|
||||
if(config.valid_media_domains.includes(u.hostname)) {
|
||||
let ext = u.pathname.split('.')[1]
|
||||
if(ext === 'jpg' || ext === 'png') {
|
||||
obj.images = {
|
||||
source: await downloadAndSave(post.url)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(error) {
|
||||
//console.error(Invalid URL supplied when trying to fetch an image', error)
|
||||
}
|
||||
}
|
||||
}
|
||||
resolve(obj)
|
||||
})()
|
||||
|
|
Loading…
Reference in New Issue