diff --git a/index.html.final b/index.html.final
index 2b7cb05..0317ea4 100644
--- a/index.html.final
+++ b/index.html.final
@@ -2594,17 +2594,40 @@ async function doExtract() {
return;
}
- var blob = await r.blob();
- var url = URL.createObjectURL(blob);
- var a = document.createElement('a');
- a.href = url;
- a.download = 'gather_extract_s' + Math.round(start) + '_d' + Math.round(duration) + '.zip';
- document.body.appendChild(a);
- a.click();
- document.body.removeChild(a);
- URL.revokeObjectURL(url);
+ var taskData = await r.json();
+ if (!taskData.task_id) {
+ setInfo('Extract error: no task_id returned');
+ return;
+ }
+ var taskId = taskData.task_id;
+ setInfo('📥 Processing extract task...');
- setInfo('📥 Downloaded: ' + (blob.size / 1e6).toFixed(1) + ' MB');
+ // Poll until done
+ while (true) {
+ await new Promise(function(resolve) { setTimeout(resolve, 2000); });
+ var sr = await fetch(API + '/tasks/' + taskId);
+ var sd = await sr.json();
+ if (sd.status === 'done') {
+ setInfo('📥 Downloading ZIP...');
+ var dr = await fetch(API + '/tasks/' + taskId + '/download');
+ var blob = await dr.blob();
+ var url = URL.createObjectURL(blob);
+ var a = document.createElement('a');
+ a.href = url;
+ a.download = 'gather_extract_s' + Math.round(start) + '_d' + Math.round(duration) + '.zip';
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
+ URL.revokeObjectURL(url);
+ setInfo('📥 Downloaded: ' + (blob.size / 1e6).toFixed(1) + ' MB');
+ break;
+ } else if (sd.status === 'error') {
+ setInfo('Extract error: ' + (sd.error || 'unknown'));
+ break;
+ } else {
+ setInfo('📥 Processing... ' + (sd.progress || ''));
+ }
+ }
} catch(e) {
setInfo('Extract error: ' + e.message);
}