check post.preview

This commit is contained in:
teddit 2020-12-05 20:42:38 +01:00
parent a1bf92471b
commit a1e53600e6
1 changed files with 10 additions and 6 deletions

View File

@ -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 = {