refactor: Make rate limiting configurable and move session validation to Tidal class
- Add api_rate_limit_batch_size and api_rate_limit_delay_sec to Settings (cfg.py) - Move validate_session() and is_authentication_error() to Tidal class (config.py) - Update _load_albums_with_rate_limiting() to use config values instead of hardcoded 20/3 - Update _handle_album_load_error() to use Tidal.is_authentication_error() - Remove _validate_session() from gui.py (now uses Tidal.validate_session()) - Addresses maintainer feedback: configurable tweaking variables and proper separation of concerns
This commit is contained in:
@@ -59,6 +59,9 @@ class Settings:
|
||||
filename_delimiter_artist: str = ", "
|
||||
filename_delimiter_album_artist: str = ", "
|
||||
metadata_target_upc: MetadataTargetUPC = MetadataTargetUPC.UPC
|
||||
# Rate limiting for API calls (tweaking variables)
|
||||
api_rate_limit_batch_size: int = 20 # Number of albums to process before applying rate limit delay
|
||||
api_rate_limit_delay_sec: float = 3.0 # Delay in seconds between batches to avoid rate limiting
|
||||
|
||||
|
||||
@dataclass_json
|
||||
@@ -127,6 +130,8 @@ class HelpSettings:
|
||||
metadata_target_upc: str = (
|
||||
"Select the target metadata tag ('UPC', 'BARCODE', 'EAN') where to write the UPC information to. Default: 'UPC'."
|
||||
)
|
||||
api_rate_limit_batch_size: str = "Number of albums to process before applying rate limit delay (tweaking variable)."
|
||||
api_rate_limit_delay_sec: str = "Delay in seconds between batches to avoid API rate limiting (tweaking variable)."
|
||||
|
||||
|
||||
@dataclass_json
|
||||
|
||||
Reference in New Issue
Block a user