Import Instagram archive to a Bluesky account
9
fork

Configure Feed

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

Add VideoEmbedImpl class for consistent video media embedding

- Create VideoEmbedImpl class to provide type-safe video embed creation
- Implement toJSON method for improved logging and serialization
- Update media processing to use VideoEmbedImpl for consistent video embedding
- Add TODO comment to review existing video embed logic
- Enhance media type handling with new implementation

+33 -6
+1
src/app.ts
··· 80 80 videoData.ref = blob.ref.$link; 81 81 } 82 82 83 + // TODO determine if this logic is obsolete now. 83 84 // Create video embed structure 84 85 const videoEmbed = createVideoEmbed(videoData); 85 86
+27
src/bluesky.ts
··· 57 57 type EmbeddedMedia = VideoEmbed | ImageEmbed[] | ImagesEmbed; 58 58 type PostEmbed = VideoEmbedPost | ImagesEmbed; 59 59 60 + export class VideoEmbedImpl implements VideoEmbed { 61 + readonly $type = "app.bsky.embed.video"; 62 + 63 + constructor( 64 + public alt: string, 65 + public buffer: Buffer, 66 + public mimeType: string, 67 + public size?: number, 68 + public video?: { 69 + ref: BlobRef; 70 + mimeType: string; 71 + size: number; 72 + } 73 + ) {} 74 + 75 + toJSON() { 76 + return { 77 + $type: this.$type, 78 + alt: this.alt, 79 + buffer: "[Buffer length=" + this.buffer.length + "]", 80 + mimeType: this.mimeType, 81 + size: this.size, 82 + video: this.video 83 + }; 84 + } 85 + } 86 + 60 87 export class BlueskyClient { 61 88 private readonly agent: AtpAgent; 62 89 private readonly username: string;
+5 -6
src/media.ts
··· 1 - import { ImageEmbed, VideoEmbed, ImageEmbedImpl } from './bluesky'; 1 + import { ImageEmbed, VideoEmbed, ImageEmbedImpl, VideoEmbedImpl } from './bluesky'; 2 2 import { logger } from './logger'; 3 3 import { validateVideo } from './video'; 4 4 import FS from 'fs'; ··· 115 115 116 116 // Add media object for both simulate and real mode 117 117 if (isVideo) { 118 - embeddedMedia = { 119 - $type: 'app.bsky.embed.video', 120 - alt: mediaText, 121 - buffer: mediaBuffer, 118 + embeddedMedia = new VideoEmbedImpl( 119 + mediaText, 120 + mediaBuffer, 122 121 mimeType 123 - } as VideoEmbed; 122 + ); 124 123 } else { 125 124 try{ 126 125 if(Array.isArray(embeddedMedia)) {