Import Instagram archive to a Bluesky account
9
fork

Configure Feed

Select the types of activity you want to include in your feed.

Added geo uri to image alt text

+16 -10
+16 -10
app.ts
··· 66 66 67 67 for (let index = 0; index < sortedPost.length; index++) { 68 68 const post = sortedPost[index]; 69 + let location = { 70 + latitude: 0.0, 71 + longitude: 0.0 72 + }; 69 73 70 74 let postDate: Date | undefined = undefined; 71 75 if (post.creation_timestamp != undefined) ··· 100 104 for (let j = 0; j < post.media.length; j++) { 101 105 const postMedia = post.media[j]; 102 106 const mediaDate = new Date(postMedia.creation_timestamp * 1000); 103 - const mediaText = postMedia.title; 107 + let mediaText = postMedia.title; 104 108 105 109 // if (postMedia.uri == "media/posts/202108/240742101_558570538822653_7921317535156034037_n_17968506598442521.jpg") { 106 110 // console.log("debug"); 107 111 // } 108 112 109 - console.log(` Media ${j} - ${postMedia.uri}`); 110 - console.log(` Created at ${mediaDate.toISOString()}`); 111 - console.log(` Text '${mediaText}'`); 113 + if (j > 3) { 114 + console.warn("Bluesky does not support more than 4 images per post, excess images will be discarded.") 115 + break; 116 + } 112 117 113 118 const fileType = postMedia.uri.substring(postMedia.uri.lastIndexOf(".") + 1) 114 119 let mimeType = ""; ··· 132 137 const mediaFilename = `${process.env.ARCHIVE_FOLDER}/${postMedia.uri}`; 133 138 const imageBuffer = FS.readFileSync(mediaFilename); 134 139 135 - if (j > 3) { 136 - console.warn("Bluesky does not support more than 4 images per post, excess images will be discarded.") 137 - break; 140 + if (postMedia.media_metadata?.photo_metadata?.exif_data?.length > 0) { 141 + location = postMedia.media_metadata?.photo_metadata?.exif_data![0]; 142 + mediaText += `\ngeo:${location.latitude},${location.longitude}`; 138 143 } 144 + 145 + console.log(` Media ${j} - ${postMedia.uri}`); 146 + console.log(` Created at ${mediaDate.toISOString()}`); 147 + console.log(` Text '${mediaText}'`); 139 148 140 149 if (!SIMULATE) { 141 150 const blobRecord = await agent.uploadBlob(imageBuffer, { ··· 185 194 } else { 186 195 importedPosts++; 187 196 } 188 - 189 - // if( importedPosts > 2) 190 - // break; 191 197 } 192 198 } 193 199