database_verifier
¶
Database verification functionality for Music Genre Updater.
This module handles verifying the track database against Music.app and managing incremental run timestamps.
DryRunAction
¶
Bases: TypedDict
Describes a single dry-run action recorded during verification.
DatabaseVerifier
¶
DatabaseVerifier(
ap_client,
console_logger,
error_logger,
db_verify_logger,
*,
analytics,
config,
dry_run=False
)
Manages database verification and incremental run tracking.
Initialize the DatabaseVerifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ap_client
|
AppleScriptClientProtocol
|
AppleScript client for Music.app communication |
required |
console_logger
|
Logger
|
Logger for console output |
required |
error_logger
|
Logger
|
Logger for error messages |
required |
db_verify_logger
|
Logger
|
Logger for verification log file |
required |
analytics
|
Analytics
|
Analytics instance for tracking |
required |
config
|
AppConfig
|
Typed application configuration |
required |
dry_run
|
bool
|
Whether to run in dry-run mode |
False
|
Source code in src/app/features/verify/database_verifier.py
should_auto_verify
async
¶
Check if automatic database verification should run.
Returns True if: - auto_verify_days has passed since last verification - No previous verification exists
Returns:
| Type | Description |
|---|---|
bool
|
True if auto-verify should run, False otherwise |
Source code in src/app/features/verify/database_verifier.py
can_run_incremental
async
¶
Check if enough time has passed since the last incremental run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force_run
|
bool
|
If True, skip the time check |
False
|
Returns:
| Type | Description |
|---|---|
bool
|
True if incremental run should proceed, False otherwise |
Source code in src/app/features/verify/database_verifier.py
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 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | |
update_last_incremental_run
async
¶
Update the timestamp of the last incremental run.
Source code in src/app/features/verify/database_verifier.py
verify_and_clean_track_database
async
¶
Verify the track database against Music.app and remove invalid entries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
force
|
bool
|
Force verification even if recently done |
False
|
apply_test_filter
|
bool
|
Apply test artist filter in dry-run mode |
False
|
Returns:
| Type | Description |
|---|---|
int
|
Number of invalid tracks removed |
Source code in src/app/features/verify/database_verifier.py
get_dry_run_actions
¶
Get the list of dry-run actions recorded.
Returns:
| Type | Description |
|---|---|
list[DryRunAction]
|
List of dry-run action dictionaries |