Files
website/scripts/music-poll.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

19 lines
878 B
TypeScript

// One Spotify poll (now playing + recently played), for the optional host timer in
// deploy/music-collector. The app normally does this itself every minute (see
// src/lib/server/music/poller.ts); the lease in music.spotify_auth stops double polling.
// MUSIC_DB_URL=... SPOTIFY_CLIENT_ID=... SPOTIFY_CLIENT_SECRET=... bun scripts/music-poll.ts
import { pollSpotify } from '../src/lib/music/collector.server';
import { musicDb } from './music-db';
const clientId = process.env.SPOTIFY_CLIENT_ID;
const clientSecret = process.env.SPOTIFY_CLIENT_SECRET;
if (!clientId || !clientSecret) throw new Error('Set SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET');
const sql = musicDb();
try {
const result = await pollSpotify(sql, { clientId, clientSecret });
console.log(JSON.stringify(result));
if (result.status === 'error') process.exitCode = 1;
} finally {
await sql.end();
}