Fix $year missing and disc_number crash on Amazon album downloads
release_date: T2Tunes album metadata may use camelCase releaseDate — try both
keys at all read sites (get_album, get_track_details, Album.from_metadata,
_fetch_album_metas consumers). Final fallback: s.date from stream tags, which
T2Tunes always populates from embedded FLAC/MP4 date tag. Wire s.date into
get_album_tracks items and get_track_details album.release_date so the $year
path template resolves correctly.
disc_number crash: .get('disc_number', 1) returns None when key is present but
value is None (Amazon stream info has Optional[int] for disc_number). Switch all
max() call sites and disc_num assignments to `or 1` guard:
- master.py: run_full_missing_tracks_process max() and disc_num read
- candidates.py: track_info and detailed_track disc_number reads
- web_server.py: enhanced and standard album download max() calls
This commit is contained in:
parent
8a3bb88678
commit
c2fcef45c2
1 changed files with 6 additions and 5 deletions
|
|
@ -169,7 +169,7 @@ class Album:
|
||||||
id=str(album_meta.get("asin") or asin or ""),
|
id=str(album_meta.get("asin") or asin or ""),
|
||||||
name=str(album_meta.get("title") or ""),
|
name=str(album_meta.get("title") or ""),
|
||||||
artists=[str(album_meta.get("artistName") or "Unknown Artist")],
|
artists=[str(album_meta.get("artistName") or "Unknown Artist")],
|
||||||
release_date=str(album_meta.get("release_date") or ""),
|
release_date=str(album_meta.get("release_date") or album_meta.get("releaseDate") or ""),
|
||||||
total_tracks=int(album_meta.get("trackCount") or 0),
|
total_tracks=int(album_meta.get("trackCount") or 0),
|
||||||
album_type="album",
|
album_type="album",
|
||||||
image_url=album_meta.get("image"),
|
image_url=album_meta.get("image"),
|
||||||
|
|
@ -349,7 +349,7 @@ class AmazonClient:
|
||||||
if album_asin and album_asin in album_metas:
|
if album_asin and album_asin in album_metas:
|
||||||
meta = album_metas[album_asin]
|
meta = album_metas[album_asin]
|
||||||
track.image_url = meta.get("image")
|
track.image_url = meta.get("image")
|
||||||
track.release_date = str(meta.get("release_date") or "")
|
track.release_date = str(meta.get("release_date") or meta.get("releaseDate") or "")
|
||||||
track.total_tracks = meta.get("trackCount")
|
track.total_tracks = meta.get("trackCount")
|
||||||
tracks.append(track)
|
tracks.append(track)
|
||||||
return tracks
|
return tracks
|
||||||
|
|
@ -409,7 +409,7 @@ class AmazonClient:
|
||||||
if asin in album_metas:
|
if asin in album_metas:
|
||||||
meta = album_metas[asin]
|
meta = album_metas[asin]
|
||||||
album.image_url = meta.get("image")
|
album.image_url = meta.get("image")
|
||||||
album.release_date = str(meta.get("release_date") or "")
|
album.release_date = str(meta.get("release_date") or meta.get("releaseDate") or "")
|
||||||
album.total_tracks = int(meta.get("trackCount") or 0)
|
album.total_tracks = int(meta.get("trackCount") or 0)
|
||||||
albums.append(album)
|
albums.append(album)
|
||||||
return albums
|
return albums
|
||||||
|
|
@ -442,7 +442,7 @@ class AmazonClient:
|
||||||
"id": album_data.get("asin", ""),
|
"id": album_data.get("asin", ""),
|
||||||
"name": _strip_edition(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") or album_data.get("releaseDate") or s.date or "",
|
||||||
"total_tracks": album_data.get("trackCount", 0),
|
"total_tracks": album_data.get("trackCount", 0),
|
||||||
},
|
},
|
||||||
"duration_ms": 0,
|
"duration_ms": 0,
|
||||||
|
|
@ -478,7 +478,7 @@ class AmazonClient:
|
||||||
"id": asin,
|
"id": asin,
|
||||||
"name": _strip_edition(album.get("title", "")),
|
"name": _strip_edition(album.get("title", "")),
|
||||||
"artists": [{"name": _primary_artist(album.get("artistName", "")), "id": ""}],
|
"artists": [{"name": _primary_artist(album.get("artistName", "")), "id": ""}],
|
||||||
"release_date": album.get("release_date", ""),
|
"release_date": album.get("release_date") or album.get("releaseDate") or "",
|
||||||
"total_tracks": album.get("trackCount", 0),
|
"total_tracks": album.get("trackCount", 0),
|
||||||
"album_type": "album",
|
"album_type": "album",
|
||||||
"images": [{"url": album["image"]}] if album.get("image") else [],
|
"images": [{"url": album["image"]}] if album.get("image") else [],
|
||||||
|
|
@ -509,6 +509,7 @@ class AmazonClient:
|
||||||
"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,
|
||||||
|
"release_date": s.date or "",
|
||||||
"isrc": s.isrc,
|
"isrc": s.isrc,
|
||||||
}
|
}
|
||||||
for s in streams
|
for s in streams
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue