Route import through automation engine and show per-track progress
- Remove direct request_scan() calls from album and singles import — emit batch_complete through automation engine instead, matching the same chain as download batches (scan → DB update) - Show current track name in import queue status display instead of just processed/total count
This commit is contained in:
parent
68b4aace68
commit
4786dc21ec
2 changed files with 44 additions and 35 deletions
|
|
@ -47498,24 +47498,26 @@ def import_album_process():
|
|||
errors.append(err_msg)
|
||||
logger.error(f"Import processing error: {err_msg}")
|
||||
|
||||
# Trigger library scan
|
||||
if web_scan_manager and processed > 0:
|
||||
threading.Thread(
|
||||
target=lambda: web_scan_manager.request_scan("Import album processed"),
|
||||
daemon=True
|
||||
).start()
|
||||
|
||||
add_activity_item("📥", "Album Imported", f"{album_name} by {artist_name} ({processed}/{len(matches)} tracks)", "Now")
|
||||
|
||||
try:
|
||||
if automation_engine:
|
||||
automation_engine.emit('import_completed', {
|
||||
'track_count': str(processed),
|
||||
'album_name': album_name or '',
|
||||
'artist': artist_name or '',
|
||||
})
|
||||
except Exception:
|
||||
pass
|
||||
# Emit events through automation engine — same chain as download batches
|
||||
# batch_complete → auto-scan → library_scan_completed → auto-update DB
|
||||
if processed > 0:
|
||||
try:
|
||||
if automation_engine:
|
||||
automation_engine.emit('import_completed', {
|
||||
'track_count': str(processed),
|
||||
'album_name': album_name or '',
|
||||
'artist': artist_name or '',
|
||||
})
|
||||
automation_engine.emit('batch_complete', {
|
||||
'playlist_name': f"Import: {album_name}" if album_name else 'Import',
|
||||
'total_tracks': str(len(matches)),
|
||||
'completed_tracks': str(processed),
|
||||
'failed_tracks': str(len(errors)),
|
||||
})
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Rebuild suggestions cache since staging contents changed
|
||||
if processed > 0:
|
||||
|
|
@ -47756,24 +47758,26 @@ def import_singles_process():
|
|||
errors.append(err_msg)
|
||||
logger.error(f"Import single processing error: {err_msg}")
|
||||
|
||||
# Trigger library scan
|
||||
if web_scan_manager and processed > 0:
|
||||
threading.Thread(
|
||||
target=lambda: web_scan_manager.request_scan("Import singles processed"),
|
||||
daemon=True
|
||||
).start()
|
||||
|
||||
add_activity_item("📥", "Singles Imported", f"{processed}/{len(files)} tracks processed", "Now")
|
||||
|
||||
try:
|
||||
if automation_engine:
|
||||
automation_engine.emit('import_completed', {
|
||||
'track_count': str(processed),
|
||||
'album_name': '',
|
||||
'artist': 'Various',
|
||||
})
|
||||
except Exception:
|
||||
pass
|
||||
# Emit events through automation engine — same chain as download batches
|
||||
# batch_complete → auto-scan → library_scan_completed → auto-update DB
|
||||
if processed > 0:
|
||||
try:
|
||||
if automation_engine:
|
||||
automation_engine.emit('import_completed', {
|
||||
'track_count': str(processed),
|
||||
'album_name': '',
|
||||
'artist': 'Various',
|
||||
})
|
||||
automation_engine.emit('batch_complete', {
|
||||
'playlist_name': 'Import: Singles',
|
||||
'total_tracks': str(len(files)),
|
||||
'completed_tracks': str(processed),
|
||||
'failed_tracks': str(len(errors)),
|
||||
})
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Rebuild suggestions cache since staging contents changed
|
||||
if processed > 0:
|
||||
|
|
|
|||
|
|
@ -60255,6 +60255,14 @@ function _importQueueAdd(job) {
|
|||
|
||||
async function _importQueueRunJob(entry, job) {
|
||||
for (let i = 0; i < job.items.length; i++) {
|
||||
const itemName = job.type === 'album'
|
||||
? (job.items[i].spotify_track?.name || `Track ${i + 1}`)
|
||||
: (job.items[i].title || job.items[i].filename || `File ${i + 1}`);
|
||||
|
||||
// Update status with current track info
|
||||
entry.sublabel = `Processing ${i + 1}/${job.items.length}: ${itemName}`;
|
||||
_importQueueRender();
|
||||
|
||||
try {
|
||||
let resp;
|
||||
if (job.type === 'album') {
|
||||
|
|
@ -60279,9 +60287,6 @@ async function _importQueueRunJob(entry, job) {
|
|||
if (data.success) entry.processed += (data.processed || 0);
|
||||
if (data.errors && data.errors.length > 0) entry.errors.push(...data.errors);
|
||||
} catch (err) {
|
||||
const itemName = job.type === 'album'
|
||||
? (job.items[i].spotify_track?.name || `Track ${i + 1}`)
|
||||
: (job.items[i].title || job.items[i].filename || `File ${i + 1}`);
|
||||
entry.errors.push(`${itemName}: ${err.message}`);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue