Fix AcoustID quarantine and disc_number crash on Amazon album downloads
AcoustID verification was quarantining every Amazon track because T2Tunes
embeds [Explicit] and [feat. X] in stream tag titles/artists, but AcoustID
returns bare titles — triggering version-mismatch rejection on every track.
- get_track_details: apply _strip_edition to name/album, _primary_artist to
artist; wire s.track_number / s.disc_number instead of hardcoded None
- get_album_tracks: apply _strip_edition to name, _primary_artist to artist
Also fix TypeError crash in album download paths when disc_number is None
(present in dict but explicitly None, so .get('disc_number', 1) returns None):
- master.py run_full_missing_tracks_process: or 1 guard on both max() and disc_num
- candidates.py track_info extraction: or 1 guard on both disc_number reads
- web_server.py enhanced + standard album download max() calls: or 1 guard
This commit is contained in:
parent
51e00d4ebf
commit
8a3bb88678
4 changed files with 13 additions and 13 deletions
|
|
@ -436,11 +436,11 @@ class AmazonClient:
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"id": s.asin,
|
"id": s.asin,
|
||||||
"name": s.title,
|
"name": _strip_edition(s.title),
|
||||||
"artists": [{"name": s.artist, "id": ""}],
|
"artists": [{"name": _primary_artist(s.artist), "id": ""}],
|
||||||
"album": {
|
"album": {
|
||||||
"id": album_data.get("asin", ""),
|
"id": album_data.get("asin", ""),
|
||||||
"name": s.album,
|
"name": _strip_edition(s.album),
|
||||||
"images": [{"url": album_data["image"]}] if album_data.get("image") else [],
|
"images": [{"url": album_data["image"]}] if album_data.get("image") else [],
|
||||||
"release_date": album_data.get("release_date", ""),
|
"release_date": album_data.get("release_date", ""),
|
||||||
"total_tracks": album_data.get("trackCount", 0),
|
"total_tracks": album_data.get("trackCount", 0),
|
||||||
|
|
@ -448,8 +448,8 @@ class AmazonClient:
|
||||||
"duration_ms": 0,
|
"duration_ms": 0,
|
||||||
"popularity": 0,
|
"popularity": 0,
|
||||||
"external_urls": {"amazon": f"https://music.amazon.com/albums/{asin}"},
|
"external_urls": {"amazon": f"https://music.amazon.com/albums/{asin}"},
|
||||||
"track_number": None,
|
"track_number": s.track_number,
|
||||||
"disc_number": None,
|
"disc_number": s.disc_number,
|
||||||
"isrc": s.isrc,
|
"isrc": s.isrc,
|
||||||
"is_album_track": True,
|
"is_album_track": True,
|
||||||
"raw_data": {
|
"raw_data": {
|
||||||
|
|
@ -504,8 +504,8 @@ class AmazonClient:
|
||||||
items = [
|
items = [
|
||||||
{
|
{
|
||||||
"id": s.asin,
|
"id": s.asin,
|
||||||
"name": s.title,
|
"name": _strip_edition(s.title),
|
||||||
"artists": [{"name": s.artist, "id": ""}],
|
"artists": [{"name": _primary_artist(s.artist), "id": ""}],
|
||||||
"duration_ms": 0,
|
"duration_ms": 0,
|
||||||
"track_number": s.track_number,
|
"track_number": s.track_number,
|
||||||
"disc_number": s.disc_number,
|
"disc_number": s.disc_number,
|
||||||
|
|
|
||||||
|
|
@ -235,7 +235,7 @@ def attempt_download_with_candidates(task_id, candidates, track, batch_id=None,
|
||||||
|
|
||||||
# 1. Try track_info (from frontend, has album track data)
|
# 1. Try track_info (from frontend, has album track data)
|
||||||
tn = track_info.get('track_number', 0) if isinstance(track_info, dict) else 0
|
tn = track_info.get('track_number', 0) if isinstance(track_info, dict) else 0
|
||||||
dn = track_info.get('disc_number', 1) if isinstance(track_info, dict) else 1
|
dn = (track_info.get('disc_number') or 1) if isinstance(track_info, dict) else 1
|
||||||
if tn and tn > 0:
|
if tn and tn > 0:
|
||||||
enhanced_payload['track_number'] = tn
|
enhanced_payload['track_number'] = tn
|
||||||
enhanced_payload['disc_number'] = dn
|
enhanced_payload['disc_number'] = dn
|
||||||
|
|
@ -255,7 +255,7 @@ def attempt_download_with_candidates(task_id, candidates, track, batch_id=None,
|
||||||
detailed_track = deps.spotify_client.get_track_details(track.id)
|
detailed_track = deps.spotify_client.get_track_details(track.id)
|
||||||
if detailed_track and detailed_track.get('track_number'):
|
if detailed_track and detailed_track.get('track_number'):
|
||||||
enhanced_payload['track_number'] = detailed_track['track_number']
|
enhanced_payload['track_number'] = detailed_track['track_number']
|
||||||
enhanced_payload['disc_number'] = detailed_track.get('disc_number', 1)
|
enhanced_payload['disc_number'] = detailed_track.get('disc_number') or 1
|
||||||
got_track_number = True
|
got_track_number = True
|
||||||
logger.info(f"[Context] Added track_number from API: {detailed_track['track_number']}, disc_number: {enhanced_payload['disc_number']}")
|
logger.info(f"[Context] Added track_number from API: {detailed_track['track_number']}, disc_number: {enhanced_payload['disc_number']}")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -483,7 +483,7 @@ def run_full_missing_tracks_process(batch_id, playlist_id, tracks_json, deps: Ma
|
||||||
# Use ALL tracks (tracks_json), not just missing ones, to correctly detect multi-disc
|
# Use ALL tracks (tracks_json), not just missing ones, to correctly detect multi-disc
|
||||||
# even when only one disc has missing tracks
|
# even when only one disc has missing tracks
|
||||||
if batch_is_album and batch_album_context:
|
if batch_is_album and batch_album_context:
|
||||||
total_discs = max((t.get('disc_number', 1) for t in tracks_json), default=1)
|
total_discs = max((t.get('disc_number') or 1 for t in tracks_json), default=1)
|
||||||
batch_album_context['total_discs'] = total_discs
|
batch_album_context['total_discs'] = total_discs
|
||||||
if total_discs > 1:
|
if total_discs > 1:
|
||||||
logger.info(f"[Multi-Disc] Detected {total_discs} discs for album '{batch_album_context.get('name')}'")
|
logger.info(f"[Multi-Disc] Detected {total_discs} discs for album '{batch_album_context.get('name')}'")
|
||||||
|
|
@ -507,7 +507,7 @@ def run_full_missing_tracks_process(batch_id, playlist_id, tracks_json, deps: Ma
|
||||||
# Fallback album key: use album name when ID is missing (e.g. mirrored playlist tracks)
|
# Fallback album key: use album name when ID is missing (e.g. mirrored playlist tracks)
|
||||||
if not album_id and isinstance(album_val, dict) and album_val.get('name'):
|
if not album_id and isinstance(album_val, dict) and album_val.get('name'):
|
||||||
album_id = f"_name_{album_val['name'].lower().strip()}"
|
album_id = f"_name_{album_val['name'].lower().strip()}"
|
||||||
disc_num = sp_data.get('disc_number', t.get('disc_number', 1))
|
disc_num = sp_data.get('disc_number') or t.get('disc_number') or 1
|
||||||
if album_id:
|
if album_id:
|
||||||
wishlist_album_disc_counts[album_id] = max(
|
wishlist_album_disc_counts[album_id] = max(
|
||||||
wishlist_album_disc_counts.get(album_id, 1), disc_num
|
wishlist_album_disc_counts.get(album_id, 1), disc_num
|
||||||
|
|
|
||||||
|
|
@ -12013,7 +12013,7 @@ def _start_enhanced_album_download(enhanced_tracks, unmatched_tracks, spotify_ar
|
||||||
logger.info(f"Processing enhanced album download for '{spotify_album['name']}' with {len(enhanced_tracks)} matched tracks")
|
logger.info(f"Processing enhanced album download for '{spotify_album['name']}' with {len(enhanced_tracks)} matched tracks")
|
||||||
|
|
||||||
# Compute total_discs for multi-disc album subfolder support
|
# Compute total_discs for multi-disc album subfolder support
|
||||||
total_discs = max((t['spotify_track'].get('disc_number', 1) for t in enhanced_tracks), default=1)
|
total_discs = max((t['spotify_track'].get('disc_number') or 1 for t in enhanced_tracks), default=1)
|
||||||
spotify_album['total_discs'] = total_discs
|
spotify_album['total_discs'] = total_discs
|
||||||
|
|
||||||
started_count = 0
|
started_count = 0
|
||||||
|
|
@ -12155,7 +12155,7 @@ def _start_album_download_tasks(album_result, spotify_artist, spotify_album):
|
||||||
|
|
||||||
# Compute total_discs for multi-disc album subfolder support
|
# Compute total_discs for multi-disc album subfolder support
|
||||||
if official_spotify_tracks:
|
if official_spotify_tracks:
|
||||||
total_discs = max((t.get('disc_number', 1) for t in official_spotify_tracks), default=1)
|
total_discs = max((t.get('disc_number') or 1 for t in official_spotify_tracks), default=1)
|
||||||
else:
|
else:
|
||||||
total_discs = 1
|
total_discs = 1
|
||||||
spotify_album['total_discs'] = total_discs
|
spotify_album['total_discs'] = total_discs
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue