year_retriever
¶
Year retrieval functionality for Music Genre Updater.
This module provides a facade for album year retrieval and updates. The actual logic is delegated to specialized components: - YearDeterminator: Core year determination logic - YearBatchProcessor: Batch processing with concurrency control - YearConsistencyChecker: Year consistency analysis - YearFallbackHandler: Fallback logic for uncertain updates
YearRetriever
¶
YearRetriever(
track_processor,
cache_service,
external_api,
pending_verification,
retry_handler,
console_logger,
error_logger,
analytics,
config,
dry_run=False,
)
Facade for album year retrieval and updates.
This class coordinates the year retrieval subsystem, delegating actual work to specialized components while maintaining backward compatibility with existing code.
Initialize the YearRetriever.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
track_processor
|
TrackProcessor
|
Track processor for updating tracks |
required |
cache_service
|
CacheServiceProtocol
|
Cache service for storing years |
required |
external_api
|
ExternalApiServiceProtocol
|
External API service for fetching years |
required |
pending_verification
|
PendingVerificationServiceProtocol
|
Service for managing pending verifications |
required |
retry_handler
|
DatabaseRetryHandler
|
Retry handler for transient error recovery |
required |
console_logger
|
Logger
|
Logger for console output |
required |
error_logger
|
Logger
|
Logger for error messages |
required |
analytics
|
AnalyticsProtocol
|
Service for performance tracking |
required |
config
|
AppConfig
|
Typed application configuration |
required |
dry_run
|
bool
|
Whether to run in dry-run mode |
False
|
Source code in src/core/tracks/year_retriever.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
process_album_years
async
¶
Process and update album years for given tracks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tracks
|
list[TrackDict]
|
Tracks to process |
required |
force
|
bool
|
Force update even if year exists (bypasses cache/skip checks) |
False
|
fresh
|
bool
|
Fresh mode - invalidate cache before processing, implies force |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
True if successful, False otherwise |
Source code in src/core/tracks/year_retriever.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
get_album_years_with_logs
async
¶
Get album year updates with change logs.
This is the public API for pipeline integration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tracks
|
list[TrackDict]
|
Tracks to process |
required |
force
|
bool
|
If True, bypass skip checks and re-query API for all albums |
False
|
Returns:
| Type | Description |
|---|---|
tuple[list[TrackDict], list[ChangeLogEntry]]
|
Tuple of (updated_tracks, change_logs) |
Source code in src/core/tracks/year_retriever.py
update_years_from_discogs
async
¶
Update years specifically from Discogs API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tracks
|
list[TrackDict]
|
Tracks to process |
required |
force
|
bool
|
If True, bypass skip checks and re-query API for all albums |
False
|
Returns:
| Type | Description |
|---|---|
tuple[list[TrackDict], list[ChangeLogEntry]]
|
Tuple of (updated_tracks, change_logs) |
Source code in src/core/tracks/year_retriever.py
get_dry_run_actions
¶
get_last_updated_tracks
¶
set_last_updated_tracks
¶
Set the list of last updated tracks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tracks
|
list[TrackDict]
|
List of updated tracks |
required |
update_album_tracks_bulk_async
async
¶
Update year for multiple tracks. Delegates to YearBatchProcessor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tracks
|
list[TrackDict]
|
List of tracks to update. |
required |
year
|
str
|
Year value to set. |
required |
artist
|
str
|
Artist name for contextual logging. |
required |
album
|
str
|
Album name for contextual logging. |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, int]
|
Tuple of (successful_count, failed_count). |