Spotify collector: slow down for the development-mode quota

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 13:07:12 +00:00
co-authored by Claude Opus 5.5
parent 5c02e8a710
commit 045be4a502
2 changed files with 4 additions and 3 deletions
+3 -2
View File
@@ -135,8 +135,9 @@ fn collect(db: &db::Db, args: &[String], db_path: &str) -> Result<()> {
} }
if wants("spotify-api") { if wants("spotify-api") {
// Spotify Web API: artists' release dates (needs /root/.spotify-credentials). // Spotify Web API: artists' release dates (needs /root/.spotify-credentials).
let lim = arg(args, "--limit").and_then(|l| l.parse().ok()).unwrap_or(if backfill { usize::MAX } else { 500 }); // Development-mode apps get a small daily quota (a 24-hour block after ~150 quick requests): go slow.
let r = spotify_api::collect(db, lim, if backfill { 0 } else { 1200 }, &mut log); let lim = arg(args, "--limit").and_then(|l| l.parse().ok()).unwrap_or(if backfill { usize::MAX } else { 60 });
let r = spotify_api::collect(db, lim, if backfill { 0 } else { 60 }, &mut log);
step("spotify releases (web api)", r.map(|n| format!("{n} artists looked up")), &mut log); step("spotify releases (web api)", r.map(|n| format!("{n} artists looked up")), &mut log);
} }
if wants("playlists") { if wants("playlists") {
+1 -1
View File
@@ -108,7 +108,7 @@ fn urlencode(s: &str) -> String {
/// Map DR artists to Spotify artists, then read each one's releases. Returns artists done. /// Map DR artists to Spotify artists, then read each one's releases. Returns artists done.
pub fn collect(db: &Db, limit: usize, refresh: usize, log: &mut Vec<String>) -> Result<usize> { pub fn collect(db: &Db, limit: usize, refresh: usize, log: &mut Vec<String>) -> Result<usize> {
create_tables(db)?; create_tables(db)?;
let mut api = Api::new(120)?; let mut api = Api::new(1000)?;
// Today's pool first (with the DR page's Spotify link where there is one), then archive-only artists. // Today's pool first (with the DR page's Spotify link where there is one), then archive-only artists.
let todo: Vec<(String, String, Option<String>)> = db.conn.prepare( let todo: Vec<(String, String, Option<String>)> = db.conn.prepare(
"SELECT a.artist_id, a.name, l.spotify_artist_id, 0 FROM dr_artists a LEFT JOIN nmf_artist_lookups l ON l.dr_artist_id = a.artist_id "SELECT a.artist_id, a.name, l.spotify_artist_id, 0 FROM dr_artists a LEFT JOIN nmf_artist_lookups l ON l.dr_artist_id = a.artist_id