Handle dates outside Python's range

This commit is contained in:
Bradlee Speice 2024-12-07 14:02:55 -05:00
parent 876ccaf8d2
commit e8d305a5d2

View File

@ -75,7 +75,10 @@ def album_sort_release(
all_albums = list(albums)
def _sort_key(album: SearchAlbum) -> date:
return parse_release_date(album.release_date, album.release_date_precision, fast_forward=fast_forward)
try:
return parse_release_date(album.release_date, album.release_date_precision, fast_forward=fast_forward)
except ValueError:
return date(1970, 1, 1)
for album in sorted(all_albums, key=_sort_key, reverse=descending):
yield album