Files
website/scripts/music-db.ts
Stan Runge b757269151
All checks were successful
Deploy production / deploy (push) Successful in 2m37s
music: self-hosted scrobbler (Spotify poller, Last.fm + streaming-history importers, /trackers/music, homepage listening card)
- music schema: artists/albums/tracks (+album art), plays with source + dedupe, now_playing,
  spotify_auth, import_state; plays_deduped view hides Last.fm scrobbles Spotify also has
- in-app Spotify poller (60s, leased) started from hooks init; no new role or env needed
- /api/spotify/connect + callback (owner only), /trackers/music public stats
- scripts: music-poll, music-import-lastfm (resumable), music-import-history
- deploy/music-collector: optional host timer with its own role
2026-10-24 15:57:40 +00:00

17 lines
683 B
TypeScript

// Shared database connection for the music scripts: MUSIC_DB_URL (e.g. the optional
// music_collector role) or DB_URL (the app role, as in the image's prod.env).
import postgres from 'postgres';
export function musicDb() {
const url = process.env.MUSIC_DB_URL || process.env.DB_URL;
if (!url) throw new Error('Set MUSIC_DB_URL or DB_URL');
return postgres(url, { max: 1, prepare: false, connect_timeout: 10, onnotice: () => {} });
}
export const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
export function arg(name: string): string | undefined {
const i = process.argv.indexOf(`--${name}`);
return i >= 0 ? process.argv[i + 1] : undefined;
}