check post.preview

This commit is contained in:
teddit 2020-12-05 20:42:38 +01:00
parent a1bf92471b
commit a1e53600e6

View File

@ -102,6 +102,7 @@ module.exports = function() {
} else {
obj.has_media = true
if(!gif_to_mp4) {
if(post.preview) {
obj.media = {
source: await downloadAndSave(post.preview.reddit_video_preview.fallback_url),
height: post.preview.reddit_video_preview.height,
@ -109,6 +110,9 @@ module.exports = function() {
duration: post.preview.reddit_video_preview.duration,
is_gif: true
}
} else {
obj.has_media = false
}
} else {
obj.media = {
source: await downloadAndSave(gif_to_mp4.url, null, true),