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:
16
scripts/music-db.ts
Normal file
16
scripts/music-db.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
// 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;
|
||||
}
|
||||
Reference in New Issue
Block a user