1.5.1
1.5.1
This commit is contained in:
@@ -1078,21 +1078,57 @@ class DW_ALBUM:
|
|||||||
c_song_metadata = {}
|
c_song_metadata = {}
|
||||||
for key, item in self.__song_metadata_items:
|
for key, item in self.__song_metadata_items:
|
||||||
if type(item) is not list:
|
if type(item) is not list:
|
||||||
c_song_metadata[key] = self.__song_metadata[key]
|
c_song_metadata[key] = item # Corrected: use item directly
|
||||||
total_tracks = album.nb_tracks
|
total_tracks = album.nb_tracks
|
||||||
for a in range(total_tracks):
|
for a in range(total_tracks):
|
||||||
for key, item in self.__song_metadata_items:
|
# c_song_metadata starts with album-wide values.
|
||||||
|
# For each track 'a', list-based values for that track 'a' are updated.
|
||||||
|
# A copy is made later for c_preferences.song_metadata.
|
||||||
|
for key, item in self.__song_metadata_items: # item is self.__song_metadata[key]
|
||||||
if type(item) is list:
|
if type(item) is list:
|
||||||
c_song_metadata[key] = self.__song_metadata[key][a]
|
if a < len(item): # Check bounds for 'item' (which is the list)
|
||||||
song_name = c_song_metadata['music']
|
c_song_metadata[key] = item[a] # Access element from 'item'
|
||||||
artist_name = c_song_metadata['artist']
|
else:
|
||||||
album_name = c_song_metadata['album']
|
# Data for this key is missing for track 'a'
|
||||||
|
logger.warning(
|
||||||
|
f"Metadata mismatch in album '{self.__song_metadata.get('album', 'Unknown Album')}'. "
|
||||||
|
f"Key '{key}' has a list of {len(item)} items, "
|
||||||
|
f"but trying to access index {a} for track {a+1}/{total_tracks}. "
|
||||||
|
f"Setting value to None for this track."
|
||||||
|
)
|
||||||
|
c_song_metadata[key] = None # Provide a fallback
|
||||||
|
if key == 'ids':
|
||||||
|
logger.error(
|
||||||
|
f"Critical 'ids' metadata for track {a+1} in album "
|
||||||
|
f"'{self.__song_metadata.get('album', 'Unknown Album')}' "
|
||||||
|
f"is missing due to list length mismatch. This track will likely fail."
|
||||||
|
)
|
||||||
|
|
||||||
|
song_name = c_song_metadata.get('music')
|
||||||
|
artist_name = c_song_metadata.get('artist')
|
||||||
|
album_name = c_song_metadata.get('album')
|
||||||
current_track = a + 1
|
current_track = a + 1
|
||||||
|
|
||||||
c_preferences = deepcopy(self.__preferences)
|
c_preferences = deepcopy(self.__preferences)
|
||||||
c_preferences.song_metadata = c_song_metadata.copy()
|
c_preferences.song_metadata = c_song_metadata.copy() # Use a copy for this track's preferences
|
||||||
c_preferences.ids = c_song_metadata['ids']
|
c_preferences.ids = c_song_metadata.get('ids') # Get the 'ids' for current track 'a'
|
||||||
c_preferences.track_number = current_track # Track number in the album
|
c_preferences.track_number = current_track # Track number in the album
|
||||||
|
|
||||||
|
if c_preferences.ids is None:
|
||||||
|
logger.error(
|
||||||
|
f"Skipping track {current_track} ('{song_name}') from album '{album_name}' "
|
||||||
|
f"because its ID is missing due to inconsistent album metadata (list length mismatch for 'ids' key)."
|
||||||
|
)
|
||||||
|
error_track_metadata = c_song_metadata.copy()
|
||||||
|
error_track = Track(error_track_metadata, None, None, None, None, None)
|
||||||
|
error_track.success = False
|
||||||
|
error_track.error_message = (
|
||||||
|
f"Track ID missing for track {current_track} ('{song_name}') in album "
|
||||||
|
f"'{album_name}' due to metadata list length mismatch."
|
||||||
|
)
|
||||||
|
tracks.append(error_track)
|
||||||
|
continue
|
||||||
|
|
||||||
c_preferences.link = f"https://open.spotify.com/track/{c_preferences.ids}"
|
c_preferences.link = f"https://open.spotify.com/track/{c_preferences.ids}"
|
||||||
|
|
||||||
# Add album_id to song metadata for consistent parent info
|
# Add album_id to song metadata for consistent parent info
|
||||||
@@ -1100,14 +1136,14 @@ class DW_ALBUM:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# Use track-level reporting through EASY_DW
|
# Use track-level reporting through EASY_DW
|
||||||
track = EASY_DW(c_preferences, parent='album').download_try()
|
track = EASY_DW(c_preferences, parent='album').easy_dw()
|
||||||
except TrackNotFound as e_track:
|
except TrackNotFound as e_track:
|
||||||
track = Track(c_song_metadata, None, None, None, None, None)
|
track = Track(c_song_metadata.copy(), None, None, None, None, None) # Use a copy of metadata for this track
|
||||||
track.success = False
|
track.success = False
|
||||||
track.error_message = str(e_track) # Store the error message from TrackNotFound
|
track.error_message = str(e_track) # Store the error message from TrackNotFound
|
||||||
logger.warning(f"Track '{song_name}' by '{artist_name}' from album '{album.album_name}' not found or failed to download. Reason: {track.error_message}")
|
logger.warning(f"Track '{song_name}' by '{artist_name}' from album '{album.album_name}' not found or failed to download. Reason: {track.error_message}")
|
||||||
except Exception as e_generic:
|
except Exception as e_generic:
|
||||||
track = Track(c_song_metadata, None, None, None, None, None)
|
track = Track(c_song_metadata.copy(), None, None, None, None, None) # Use a copy of metadata for this track
|
||||||
track.success = False
|
track.success = False
|
||||||
track.error_message = f"An unexpected error occurred: {str(e_generic)}"
|
track.error_message = f"An unexpected error occurred: {str(e_generic)}"
|
||||||
logger.error(f"Unexpected error downloading track '{song_name}' by '{artist_name}' from album '{album.album_name}'. Reason: {track.error_message}")
|
logger.error(f"Unexpected error downloading track '{song_name}' by '{artist_name}' from album '{album.album_name}'. Reason: {track.error_message}")
|
||||||
|
|||||||
Reference in New Issue
Block a user