make sure gallery keys exists

This commit is contained in:
teddit 2021-01-04 20:04:00 +01:00
parent e3cc4ab92e
commit e64cbeff71
1 changed files with 8 additions and 5 deletions

View File

@ -116,11 +116,14 @@ module.exports = function(fetch) {
for(var i = 0; i < post.gallery_data.items.length; i++) { for(var i = 0; i < post.gallery_data.items.length; i++) {
let id = post.gallery_data.items[i].media_id let id = post.gallery_data.items[i].media_id
if(post.media_metadata[id]) { if(post.media_metadata[id]) {
let item = { let item = { source: null, thumbnail: null, large: null }
type: post.media_metadata[id].e, if(post.media_metadata[id].s && post.media_metadata[id].p[0].u) {
source: await downloadAndSave(post.media_metadata[id].s.u), item = {
thumbnail: await downloadAndSave(post.media_metadata[id].p[0].u), type: post.media_metadata[id].e,
large: await downloadAndSave(post.media_metadata[id].p[post.media_metadata[id].p.length - 1].u), source: await downloadAndSave(post.media_metadata[id].s.u),
thumbnail: await downloadAndSave(post.media_metadata[id].p[0].u),
large: await downloadAndSave(post.media_metadata[id].p[post.media_metadata[id].p.length - 1].u),
}
} }
obj.gallery_items.push(item) obj.gallery_items.push(item)
} }