index.html | 40 ++++++++++++++++++++++------------------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/index.html b/index.html
index 7c3f78f..eefcd71 100644
--- a/index.html
+++ b/index.html
@@ -177,27 +177,31 @@
})
async.eachSeries(requests, function(item, callback){
+ function tryDownload() {
+ lastFM(item.data)
+ .then(extractTracks)
+ .then(function(tracks){
+ var blb = new Blob([
+ tracks.map(function(d){
+ return row(['artist', 'album', 'name', 'date'], d)
+ })
+ .map(csv).join('\n') + '\n']);
+ data[item.i] = blb;
+ bytes+= blb.size;
+ state.kb = Math.round(bytes/1024);
+ setTimeout(callback, parseInt(state.request_delay || '0', 10), false);
+ })
+ .fail(function(){
+ console.log("FAILED! Trying again...");
+ setTimeout(tryDownload, 1000);
+ })
+ }
+
if(state.cancelled) return callback(false);
+ tryDownload();
+
state.status = "fetching page " + (item.i) + "/" + page_count;
- lastFM(item.data)
- .then(extractTracks)
- .then(function(tracks){
- var blb = new Blob([
- tracks.map(function(d){
- return row(['artist', 'album', 'name', 'date'], d)
- })
- .map(csv).join('\n') + '\n']);
- data[item.i] = blb;
- bytes+= blb.size;
- state.kb = Math.round(bytes/1024);
- })
- .fail(function(){
- state.errors++;
- })
- .always(function(){
- setTimeout(callback, parseInt(state.request_delay || '0', 10), false);
- })
}, function(){
state.status = "finished";
state.complete = true;