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'}
|
return {'success': False, 'error': 'Missing album_id or missing_tracks in finding details'}
|
||||||
|
|
||||||
# Phase 1: Gather context from existing album tracks
|
# 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:
|
if not existing_tracks:
|
||||||
return {'success': False, 'error': 'No existing tracks found for this album — cannot determine album folder or quality'}
|
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:
|
for cand in candidates:
|
||||||
if cand.id in existing_track_ids:
|
if cand.id in existing_track_ids:
|
||||||
continue
|
continue
|
||||||
if cand.album_id == int(album_id):
|
if str(cand.album_id) == str(album_id):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Fuzzy title match
|
# Fuzzy title match
|
||||||
|
|
|
||||||
|
|
@ -21592,17 +21592,18 @@ def _on_download_completed(batch_id, task_id, success=True):
|
||||||
successful_downloads = finished_count - failed_count
|
successful_downloads = finished_count - failed_count
|
||||||
add_activity_item("✅", "Download Batch Complete", f"'{playlist_name}' - {successful_downloads} tracks downloaded", "Now")
|
add_activity_item("✅", "Download Batch Complete", f"'{playlist_name}' - {successful_downloads} tracks downloaded", "Now")
|
||||||
|
|
||||||
# Emit batch_complete event for automation engine
|
# Emit batch_complete event for automation engine (only if something downloaded)
|
||||||
try:
|
if successful_downloads > 0:
|
||||||
if automation_engine:
|
try:
|
||||||
automation_engine.emit('batch_complete', {
|
if automation_engine:
|
||||||
'playlist_name': playlist_name,
|
automation_engine.emit('batch_complete', {
|
||||||
'total_tracks': str(len(queue)),
|
'playlist_name': playlist_name,
|
||||||
'completed_tracks': str(successful_downloads),
|
'total_tracks': str(len(queue)),
|
||||||
'failed_tracks': str(failed_count),
|
'completed_tracks': str(successful_downloads),
|
||||||
})
|
'failed_tracks': str(failed_count),
|
||||||
except Exception:
|
})
|
||||||
pass
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
# Update YouTube playlist phase to 'download_complete' if this is a YouTube playlist
|
# Update YouTube playlist phase to 'download_complete' if this is a YouTube playlist
|
||||||
playlist_id = batch.get('playlist_id')
|
playlist_id = batch.get('playlist_id')
|
||||||
|
|
@ -24361,17 +24362,18 @@ def _check_batch_completion_v2(batch_id):
|
||||||
successful_downloads = finished_count - failed_count
|
successful_downloads = finished_count - failed_count
|
||||||
add_activity_item("✅", "Download Batch Complete", f"'{playlist_name}' - {successful_downloads} tracks downloaded", "Now")
|
add_activity_item("✅", "Download Batch Complete", f"'{playlist_name}' - {successful_downloads} tracks downloaded", "Now")
|
||||||
|
|
||||||
# Emit batch_complete event for automation engine
|
# Emit batch_complete event for automation engine (only if something downloaded)
|
||||||
try:
|
if successful_downloads > 0:
|
||||||
if automation_engine:
|
try:
|
||||||
automation_engine.emit('batch_complete', {
|
if automation_engine:
|
||||||
'playlist_name': playlist_name,
|
automation_engine.emit('batch_complete', {
|
||||||
'total_tracks': str(len(queue)),
|
'playlist_name': playlist_name,
|
||||||
'completed_tracks': str(successful_downloads),
|
'total_tracks': str(len(queue)),
|
||||||
'failed_tracks': str(failed_count),
|
'completed_tracks': str(successful_downloads),
|
||||||
})
|
'failed_tracks': str(failed_count),
|
||||||
except Exception:
|
})
|
||||||
pass
|
except Exception:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
print(f"✅ [Completion Check V2] Batch {batch_id} already marked complete - skipping duplicate processing")
|
print(f"✅ [Completion Check V2] Batch {batch_id} already marked complete - skipping duplicate processing")
|
||||||
return True # Already complete
|
return True # Already complete
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue