From a1e53600e64de63af3457c57f2eed359de4495b3 Mon Sep 17 00:00:00 2001 From: teddit Date: Sat, 5 Dec 2020 20:42:38 +0100 Subject: [PATCH] check post.preview --- inc/processPostMedia.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/inc/processPostMedia.js b/inc/processPostMedia.js index 336da06..b637a7e 100644 --- a/inc/processPostMedia.js +++ b/inc/processPostMedia.js @@ -102,12 +102,16 @@ module.exports = function() { } else { obj.has_media = true if(!gif_to_mp4) { - obj.media = { - source: await downloadAndSave(post.preview.reddit_video_preview.fallback_url), - height: post.preview.reddit_video_preview.height, - width: post.preview.reddit_video_preview.width, - duration: post.preview.reddit_video_preview.duration, - is_gif: true + if(post.preview) { + obj.media = { + source: await downloadAndSave(post.preview.reddit_video_preview.fallback_url), + height: post.preview.reddit_video_preview.height, + width: post.preview.reddit_video_preview.width, + duration: post.preview.reddit_video_preview.duration, + is_gif: true + } + } else { + obj.has_media = false } } else { obj.media = {