Import your Last.fm and Spotify listening history to the AT Protocol network using the fm.teal.alpha.feed.play lexicon.
0
fork

Configure Feed

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

fix: use official TID generation system

+11 -12
+11 -12
src/utils/tid.ts
··· 1 1 /** 2 2 * TID (Timestamp Identifier) generation for ATProto 3 3 * Based on: https://atproto.com/specs/record-key#record-key-type-tid 4 + * 5 + * This uses the official ATProto TID implementation from @atproto/common-web 6 + * to ensure compatibility and avoid precision issues with large numbers. 4 7 */ 5 8 6 - const B32_CHARS = '234567abcdefghijklmnopqrstuvwxyz'; 9 + import { TID } from '@atproto/common-web'; 7 10 8 11 /** 9 12 * Generate a TID from a Date object 10 - * TID encodes Unix microseconds in base32 13 + * Uses the official ATProto TID.fromTime method 11 14 */ 12 15 export function generateTID(date: Date): string { 13 16 // Convert to Unix microseconds 14 - // JS only gives us millisecond precision, so we multiply by 1000 15 - const unixMicros = Math.floor(date.getTime() * 1000); 17 + // The ATProto implementation expects microseconds 18 + const unixMicros = date.getTime() * 1000; 16 19 17 - let tid = ''; 18 - for (let i = 0; i < 13; i++) { 19 - // Extract 5 bits at a time (base32) 20 - const shift = 60 - (i * 5); 21 - const index = Math.floor(unixMicros / Math.pow(2, shift)) % 32; 22 - tid += B32_CHARS[index]; 23 - } 20 + // Use a fixed clockid of 0 for deterministic TID generation from timestamps 21 + // This ensures the same playedTime always generates the same TID 22 + const clockid = 0; 24 23 25 - return tid; 24 + return TID.fromTime(unixMicros, clockid).toString(); 26 25 } 27 26 28 27 /**