fix(env): restore multi-key rotation for SCRAPECREATORS_API_KEY
Originally added in #268 to spread load across free-tier accounts when
SCRAPECREATORS_API_KEY is set to a comma-separated list. The 7-line block
was inadvertently dropped during the v3.0.6 consolidation (d14814a) even
though the changelog still advertised the feature. Re-apply the same
random.choice rotation in get_config() so user-facing behavior matches
the documented contract. Closes #287.
Co-authored-by: Eric Oberhofer <eric@oberhofer.io>
This commit is contained in:
@@ -352,6 +352,15 @@ def get_config() -> dict[str, Any]:
|
|||||||
if legacy:
|
if legacy:
|
||||||
config['SCRAPECREATORS_API_KEY'] = legacy
|
config['SCRAPECREATORS_API_KEY'] = legacy
|
||||||
|
|
||||||
|
# Multi-key rotation: comma-separated SCRAPECREATORS_API_KEY round-robins
|
||||||
|
# via random.choice per run. Originally added in #268, accidentally dropped
|
||||||
|
# in v3.0.6, restored here.
|
||||||
|
sc_key_raw = config.get('SCRAPECREATORS_API_KEY') or ''
|
||||||
|
if ',' in sc_key_raw:
|
||||||
|
import random
|
||||||
|
sc_keys = [k.strip() for k in sc_key_raw.split(',') if k.strip()]
|
||||||
|
config['SCRAPECREATORS_API_KEY'] = random.choice(sc_keys) if sc_keys else ''
|
||||||
|
|
||||||
# Track which config source was used (highest-priority file source wins
|
# Track which config source was used (highest-priority file source wins
|
||||||
# the label; keychain is only reported when nothing else is configured).
|
# the label; keychain is only reported when nothing else is configured).
|
||||||
if project_env_path:
|
if project_env_path:
|
||||||
|
|||||||
Reference in New Issue
Block a user