music: self-hosted scrobbler (Spotify poller, Last.fm + streaming-history importers, /trackers/music, homepage listening card)
All checks were successful
Deploy production / deploy (push) Successful in 2m37s
All checks were successful
Deploy production / deploy (push) Successful in 2m37s
- 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
This commit is contained in:
18
scripts/music-poll.ts
Normal file
18
scripts/music-poll.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
// 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();
|
||||
}
|
||||
Reference in New Issue
Block a user