fix: improve logging for Jellyfin ID updates and error handling

This commit is contained in:
Kamil
2024-12-13 22:40:56 +00:00
parent 3a78e710ae
commit 56d937a21f

View File

@@ -457,6 +457,7 @@ def update_jellyfin_id_for_downloaded_tracks(self):
db.session.commit() db.session.commit()
else: else:
app.logger.warning(f"No matching track found in Jellyfin for {track.name}.") app.logger.warning(f"No matching track found in Jellyfin for {track.name}.")
spotify_track = None spotify_track = None
@@ -466,13 +467,14 @@ def update_jellyfin_id_for_downloaded_tracks(self):
processed_tracks += 1 processed_tracks += 1
progress = (processed_tracks / total_tracks) * 100 progress = (processed_tracks / total_tracks) * 100
self.update_state(state=f'{processed_tracks}/{total_tracks}: {track.name}', meta={'current': processed_tracks, 'total': total_tracks, 'percent': progress}) self.update_state(state=f'{processed_tracks}/{total_tracks}: {track.name}', meta={'current': processed_tracks, 'total': total_tracks, 'percent': progress})
app.logger.info("Finished updating Jellyfin IDs for all tracks.") app.logger.info("Finished updating Jellyfin IDs for all tracks.")
return {'status': 'All tracks updated', 'total': total_tracks, 'processed': processed_tracks} return {'status': 'All tracks updated', 'total': total_tracks, 'processed': processed_tracks}
except Exception as e: except Exception as e:
app.logger.error(f"Error downloading tracks: {str(e)}", exc_info=True) app.logger.error(f"Error updating jellyfin ids: {str(e)}", exc_info=True)
return {'status': 'Error downloading tracks'} return {'status': 'Error updating jellyfin ids '}
finally: finally:
task_manager.release_lock(lock_key) task_manager.release_lock(lock_key)
else: else:
@@ -609,6 +611,7 @@ def find_best_match_from_jellyfin(track: Track):
app.logger.debug(f"\tQuality score for track {result['Name']}: {quality_score} [{result['Path']}]") app.logger.debug(f"\tQuality score for track {result['Name']}: {quality_score} [{result['Path']}]")
best_match = result best_match = result
best_quality_score = quality_score
break break
@@ -645,8 +648,8 @@ def compute_quality_score(result, use_ffprobe=False) -> float:
if result.get('HasLyrics'): if result.get('HasLyrics'):
score += 10 score += 10
runtime_ticks = result.get('RunTimeTicks', 0) #runtime_ticks = result.get('RunTimeTicks', 0)
score += runtime_ticks / 1e6 #score += runtime_ticks / 1e6
if use_ffprobe: if use_ffprobe:
path = result.get('Path') path = result.get('Path')