Re-discover tracks with incomplete metadata in playlist pipeline

The discovery worker skipped already-discovered tracks even when their
matched_data was incomplete (missing track_number, release_date, album
ID). These stale discoveries from before the enrichment fix would
persist forever, causing the automation pipeline to keep producing
tracks with no year, no track numbers, and no cover art.

Now treats discovered tracks as undiscovered if they're missing
track_number AND have no release_date or album ID, so the enriched
discovery pipeline fills in the gaps on the next run.
This commit is contained in:
Broque Thomas 2026-04-10 17:11:42 -07:00
parent 94e0671eb4
commit acb4479313

View file

@ -32432,8 +32432,20 @@ def _run_playlist_discovery_worker(playlists, automation_id=None):
except (json.JSONDecodeError, TypeError):
pass
if existing_extra.get('discovered'):
pl_skipped += 1
total_skipped += 1
# Check if matched_data is complete — old discoveries may be missing
# track_number/release_date due to the Track dataclass stripping them.
# Re-discover these so the enriched pipeline fills in the gaps.
md = existing_extra.get('matched_data', {})
album = md.get('album', {})
has_track_num = md.get('track_number')
has_release = album.get('release_date') if isinstance(album, dict) else None
has_album_id = album.get('id') if isinstance(album, dict) else None
if has_track_num and (has_release or has_album_id):
pl_skipped += 1
total_skipped += 1
else:
# Incomplete discovery — re-discover to get full metadata
undiscovered_tracks.append(track)
else:
undiscovered_tracks.append(track)