this repo has no description
0
fork

Configure Feed

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

feat: add URL normalization to bsky.app format in Bluesky scraper

+22 -4
+22 -4
scrapers/blueskyScraper.js
··· 110 110 } 111 111 112 112 /** 113 + * Normalize any ATProto frontend URL to bsky.app format 114 + * @param {string} url - ATProto URL from any frontend (bsky.app, deer.social, witchsky.app, etc.) 115 + * @returns {string} - Normalized bsky.app URL 116 + */ 117 + normalizeToBskyApp(url) { 118 + try { 119 + const { repo, rkey } = this.parseBlueskyUrl(url); 120 + return `https://bsky.app/profile/${repo}/post/${rkey}`; 121 + } catch (error) { 122 + console.error(`Failed to normalize URL to bsky.app: ${error.message}`); 123 + return url; // Return original URL if normalization fails 124 + } 125 + } 126 + 127 + /** 113 128 * Get user's display name from their handle or DID 114 129 * @param {string} identifier - The user's Bluesky handle or DID 115 130 * @returns {Promise<string>} - User's display name or original identifier if not found ··· 431 446 */ 432 447 async extract(url) { 433 448 try { 449 + // Normalize URL to bsky.app format for consistent output 450 + const normalizedUrl = this.normalizeToBskyApp(url); 451 + 434 452 // 1. Parse the URL to extract repo (handle) and rkey (post ID) 435 453 const { repo, rkey } = this.parseBlueskyUrl(url); 436 454 console.log(`Fetching Bluesky post: ${repo}/${rkey}`); ··· 534 552 return { 535 553 imageUrl: imagePaths[0], // First image as primary 536 554 imageUrls: imagePaths, // All images 537 - sourceUrl: url, 555 + sourceUrl: normalizedUrl, 538 556 title: `Bluesky Image${imagePaths.length > 1 ? 's' : ''} by ${displayName}`, 539 557 siteName: 'Bluesky', 540 558 isVideo: false, ··· 567 585 return { 568 586 imageUrl: imagePaths[0], // First image as primary 569 587 imageUrls: imagePaths, // All images 570 - sourceUrl: url, 588 + sourceUrl: normalizedUrl, 571 589 title: `Bluesky Image${imagePaths.length > 1 ? 's' : ''} by ${displayName}`, 572 590 siteName: 'Bluesky', 573 591 isVideo: false, ··· 620 638 imageUrls: [thumbnailProcessed.localPath], // Single thumbnail 621 639 videoUrl: videoProcessed.localPath, // Cached and transcoded video 622 640 isVideo: true, 623 - sourceUrl: url, 641 + sourceUrl: normalizedUrl, 624 642 title: `Bluesky Video by ${displayName}`, 625 643 siteName: 'Bluesky', 626 644 originalImageUrl: thumbUrl, ··· 665 683 imageUrls: [thumbnailProcessed.localPath], // Single thumbnail 666 684 videoUrl: videoProcessed.localPath, 667 685 isVideo: true, 668 - sourceUrl: url, 686 + sourceUrl: normalizedUrl, 669 687 title: `Bluesky Video by ${displayName}`, 670 688 siteName: 'Bluesky', 671 689 originalImageUrl: thumbUrl,