Spotify collector: slow down for the development-mode quota
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+3
-2
@@ -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
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user