check that reddit_video_preview.fallback_url exists (fixes #255)

This commit is contained in:
teddit 2021-10-30 19:26:27 +02:00
parent a9f13741bb
commit c34c32cc35

View File

@ -92,12 +92,20 @@ module.exports = function() {
obj.has_media = true obj.has_media = true
if(!gif_to_mp4) { if(!gif_to_mp4) {
if(post.preview) { if(post.preview) {
obj.media = { if(post.preview.reddit_video_preview) {
source: await downloadAndSave(post.preview.reddit_video_preview.fallback_url), if(post.preview.reddit_video_preview.fallback_url) {
height: post.preview.reddit_video_preview.height, obj.media = {
width: post.preview.reddit_video_preview.width, source: await downloadAndSave(post.preview.reddit_video_preview.fallback_url),
duration: post.preview.reddit_video_preview.duration, height: post.preview.reddit_video_preview.height,
is_gif: true width: post.preview.reddit_video_preview.width,
duration: post.preview.reddit_video_preview.duration,
is_gif: true
}
} else {
obj.has_media = false
}
} else {
obj.has_media = false
} }
} else { } else {
obj.has_media = false obj.has_media = false