Problem
146 tracks not on Tidal + 16 non-lossless files = 162 tracks that need better sources. The library should be 100% lossless at the highest quality possible.
Solution: Source Cascade
A plugin-based system that tries multiple sources in quality-priority order:
Priority Order:
- Tidal (current, up to 24-bit/192kHz FLAC)
- Qobuz (true lossless, no MQA, up to 24-bit/192kHz)
- Beatport (FLAC/AIFF, DJ-focused extended mixes)
- Bandcamp (FLAC, indie/underground)
- Amazon Music HD / Deezer HiFi / Apple Music (additional lossless sources)
Architecture
Source Provider Plugin System
class SourceProvider:
name: str
requires_subscription: bool
max_quality: tuple[int, int] # (bit_depth, sample_rate)
async def search(isrc, artist, title, duration_ms) -> list[SourceMatch]
async def download(match, dest_dir) -> str
async def check_auth() -> AuthStatus
Quality Hierarchy
- Any lossless > any lossy (always upgrade MP3/AAC to FLAC)
- 24-bit > 16-bit at same sample rate
- Higher sample rate > lower at same bit depth
- FLAC preferred over ALAC
- DJ preference: extended mix > radio edit when both available
Pipeline Integration
- Matching: After Tidal fails, cascade through enabled sources
- Downloading: Download from whichever source matched
- New "awaiting_purchase" stage: For Beatport/Bandcamp (search automated, purchase manual)
- Auto-upgrade task: Daily scan for non-lossless files that now have lossless versions available
Database
source_providers table: auth status, priority, config per source
source_matches table: all matches found across all sources per track
upgrade_candidates table: tracks eligible for quality upgrade
UI
- Settings: drag-to-reorder source priority, per-source auth, quality preferences
- Missing Tracks: cascade status column, purchase links with price/quality
- Dashboard: Quality Audit card (non-lossless count, upgrade-available count)
- Track detail: available quality from each source, "Upgrade" button
Verification
- ISRC match (confidence 1.0) preferred
- Metadata match with existing _artists_match/_titles_match (0.80-0.95)
- Post-download acoustic fingerprint via AcoustID
- Never overwrite existing metadata (cue points, tags, play counts)
Auto-Upgrade Flow
- Daily scan: find tracks with verify_is_genuine_lossless=0 or 16-bit when 24-bit available
- Source Cascade search for better version
- Download → verify → backup old file → replace → update Lexicon
- Never destructive: old file backed up as .bak
Implementation Phases
- Foundation: Source Provider abstraction, extract Tidal into TidalProvider
- Qobuz: Highest-impact second source (large catalog, true lossless)
- Quality Upgrade Engine: Auto-replace lossy files
- Purchase Sources: Beatport + Bandcamp search with manual purchase flow
- Additional Sources: Amazon, Deezer, Apple Music
Consolidates
Problem
146 tracks not on Tidal + 16 non-lossless files = 162 tracks that need better sources. The library should be 100% lossless at the highest quality possible.
Solution: Source Cascade
A plugin-based system that tries multiple sources in quality-priority order:
Priority Order:
Architecture
Source Provider Plugin System
Quality Hierarchy
Pipeline Integration
Database
source_providerstable: auth status, priority, config per sourcesource_matchestable: all matches found across all sources per trackupgrade_candidatestable: tracks eligible for quality upgradeUI
Verification
Auto-Upgrade Flow
Implementation Phases
Consolidates