Fix batch_complete firing with 0 downloads and album ID int cast error
- Only emit batch_complete automation event when successful_downloads > 0 - Remove int() cast on album_id in _fix_incomplete_album — Plex/Jellyfin use hash/text IDs that SQLite stores as-is in INTEGER columns - Use string comparison for album_id equality check
This commit is contained in:
parent
1b95c05041
commit
c53583716a
2 changed files with 26 additions and 24 deletions
|
|
@ -1331,7 +1331,7 @@ class RepairWorker:
|
|||
return {'success': False, 'error': 'Missing album_id or missing_tracks in finding details'}
|
||||
|
||||
# Phase 1: Gather context from existing album tracks
|
||||
existing_tracks = self.db.get_tracks_by_album(int(album_id))
|
||||
existing_tracks = self.db.get_tracks_by_album(album_id)
|
||||
if not existing_tracks:
|
||||
return {'success': False, 'error': 'No existing tracks found for this album — cannot determine album folder or quality'}
|
||||
|
||||
|
|
@ -1392,7 +1392,7 @@ class RepairWorker:
|
|||
for cand in candidates:
|
||||
if cand.id in existing_track_ids:
|
||||
continue
|
||||
if cand.album_id == int(album_id):
|
||||
if str(cand.album_id) == str(album_id):
|
||||
continue
|
||||
|
||||
# Fuzzy title match
|
||||
|
|
|
|||
|
|
@ -21592,17 +21592,18 @@ def _on_download_completed(batch_id, task_id, success=True):
|
|||
successful_downloads = finished_count - failed_count
|
||||
add_activity_item("✅", "Download Batch Complete", f"'{playlist_name}' - {successful_downloads} tracks downloaded", "Now")
|
||||
|
||||
# Emit batch_complete event for automation engine
|
||||
try:
|
||||
if automation_engine:
|
||||
automation_engine.emit('batch_complete', {
|
||||
'playlist_name': playlist_name,
|
||||
'total_tracks': str(len(queue)),
|
||||
'completed_tracks': str(successful_downloads),
|
||||
'failed_tracks': str(failed_count),
|
||||
})
|
||||
except Exception:
|
||||
pass
|
||||
# Emit batch_complete event for automation engine (only if something downloaded)
|
||||
if successful_downloads > 0:
|
||||
try:
|
||||
if automation_engine:
|
||||
automation_engine.emit('batch_complete', {
|
||||
'playlist_name': playlist_name,
|
||||
'total_tracks': str(len(queue)),
|
||||
'completed_tracks': str(successful_downloads),
|
||||
'failed_tracks': str(failed_count),
|
||||
})
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Update YouTube playlist phase to 'download_complete' if this is a YouTube playlist
|
||||
playlist_id = batch.get('playlist_id')
|
||||
|
|
@ -24361,17 +24362,18 @@ def _check_batch_completion_v2(batch_id):
|
|||
successful_downloads = finished_count - failed_count
|
||||
add_activity_item("✅", "Download Batch Complete", f"'{playlist_name}' - {successful_downloads} tracks downloaded", "Now")
|
||||
|
||||
# Emit batch_complete event for automation engine
|
||||
try:
|
||||
if automation_engine:
|
||||
automation_engine.emit('batch_complete', {
|
||||
'playlist_name': playlist_name,
|
||||
'total_tracks': str(len(queue)),
|
||||
'completed_tracks': str(successful_downloads),
|
||||
'failed_tracks': str(failed_count),
|
||||
})
|
||||
except Exception:
|
||||
pass
|
||||
# Emit batch_complete event for automation engine (only if something downloaded)
|
||||
if successful_downloads > 0:
|
||||
try:
|
||||
if automation_engine:
|
||||
automation_engine.emit('batch_complete', {
|
||||
'playlist_name': playlist_name,
|
||||
'total_tracks': str(len(queue)),
|
||||
'completed_tracks': str(successful_downloads),
|
||||
'failed_tracks': str(failed_count),
|
||||
})
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
print(f"✅ [Completion Check V2] Batch {batch_id} already marked complete - skipping duplicate processing")
|
||||
return True # Already complete
|
||||
|
|
|
|||
Loading…
Reference in a new issue