batch_fetcher
¶
Batch track fetching module.
This module handles fetching tracks from Music.app in batches to avoid timeouts when processing large libraries.
BatchTrackFetcher
¶
BatchTrackFetcher(
ap_client,
cache_service,
console_logger,
error_logger,
config,
*,
track_validator,
artist_processor,
snapshot_loader,
snapshot_persister,
can_use_snapshot,
dry_run=False,
analytics=None
)
Fetches tracks from Music.app in batches.
This class handles: - Batch-based track fetching to avoid AppleScript timeouts - Parse failure tracking and recovery - Caching and snapshot persistence of fetched tracks
Initialize the batch track fetcher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ap_client
|
AppleScriptClientProtocol
|
AppleScript client for Music.app communication |
required |
cache_service
|
CacheServiceProtocol
|
Cache service for storing fetched tracks |
required |
console_logger
|
Logger
|
Logger for info/debug messages |
required |
error_logger
|
Logger
|
Logger for error messages |
required |
config
|
AppConfig
|
Typed application configuration |
required |
track_validator
|
Callable[[list[TrackDict]], list[TrackDict]]
|
Callback to validate tracks for security |
required |
artist_processor
|
Callable[[list[TrackDict]], Awaitable[None]]
|
Async callback to process artist renames |
required |
snapshot_loader
|
Callable[[], Awaitable[list[TrackDict] | None]]
|
Async callback to load tracks from snapshot |
required |
snapshot_persister
|
Callable[[list[TrackDict], list[str] | None], Awaitable[None]]
|
Async callback to persist tracks to snapshot |
required |
can_use_snapshot
|
Callable[[str | None], bool]
|
Callback to check if snapshot can be used |
required |
dry_run
|
bool
|
Whether running in dry-run mode |
False
|
analytics
|
AnalyticsProtocol | None
|
Optional analytics instance for batch mode logging |
None
|
Source code in src/core/tracks/batch_fetcher.py
fetch_all_tracks
async
¶
Fetch all tracks from Music.app in batches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch_size
|
int
|
Number of tracks to fetch per batch |
500
|
skip_snapshot_check
|
bool
|
Skip snapshot validation (used when already validated upstream) |
False
|
Returns:
| Type | Description |
|---|---|
list[TrackDict]
|
List of all track dictionaries |