Malachite is a tool to import your Last.fm and Spotify listening history to the AT Protocol network using the
fm.teal.alpha.feed.play lexicon.
malachite
scrobbles
importer
atproto
music
1import { AtpAgent as Agent } from '@atproto/api';
2
3/**
4 * Type alias for the ATProto Agent, used for clarity in the project.
5 */
6export type AtpAgent = Agent;
7
8export interface LastFmCsvRecord {
9 uts: string;
10 utc_time: string;
11 artist: string;
12 artist_mbid?: string;
13 album: string;
14 album_mbid?: string;
15 track: string;
16 track_mbid?: string;
17}
18
19export interface PlayRecordArtist {
20 artistName: string;
21 artistMbId?: string;
22}
23
24export interface PlayRecord {
25 $type: string;
26 trackName: string;
27 artists: PlayRecordArtist[];
28 playedTime: string;
29 submissionClientAgent: string;
30 musicServiceBaseDomain: string;
31 releaseName?: string;
32 releaseMbId?: string;
33 recordingMbId?: string;
34 originUrl: string;
35}
36
37export interface CommandLineArgs {
38 // Help
39 help?: boolean;
40
41 // Authentication
42 handle?: string;
43 password?: string;
44
45 // Input
46 input?: string;
47 'spotify-input'?: string;
48
49 // Mode
50 mode?: string;
51
52 // Batch configuration
53 'batch-size'?: string;
54 'batch-delay'?: string;
55
56 // Import options
57 reverse?: boolean;
58 yes?: boolean;
59 'dry-run'?: boolean;
60 aggressive?: boolean;
61 fresh?: boolean;
62 'clear-cache'?: boolean;
63 'clear-all-caches'?: boolean;
64 'clear-credentials'?: boolean;
65
66 // Output
67 verbose?: boolean;
68 quiet?: boolean;
69 dev?: boolean;
70
71 // Legacy flags (for backwards compatibility)
72 file?: string;
73 'spotify-file'?: string;
74 identifier?: string;
75 'reverse-chronological'?: boolean;
76 sync?: boolean;
77 spotify?: boolean;
78 combined?: boolean;
79 'remove-duplicates'?: boolean;
80}
81
82export interface PublishResult {
83 successCount: number;
84 errorCount: number;
85 cancelled: boolean;
86}
87
88export interface Config {
89 MIN_RECORDS_FOR_SCALING: number;
90 BASE_BATCH_SIZE: number;
91 MAX_BATCH_SIZE: number;
92 SCALING_FACTOR: number;
93 DEFAULT_BATCH_DELAY: number;
94
95 DEFAULT_BATCH_SIZE: number; // from rate limiter
96 MIN_BATCH_DELAY: number; // from rate limiter
97 RECORDS_PER_DAY_LIMIT: number;
98 SAFETY_MARGIN: number;
99 AGGRESSIVE_SAFETY_MARGIN: number;
100
101 SLINGSHOT_RESOLVER: string;
102
103 RECORD_TYPE: string;
104}