Add a similar mechanism for episodes downloads.
If it can't fetch it after a couple of retry (5 by default, can be changed on the command line) it will just ignore it and go to the next episode.
This commit is contained in:
parent
7d6f762f59
commit
67735fb52a
1
src/interface/ISeriesEpisode.d.ts
vendored
1
src/interface/ISeriesEpisode.d.ts
vendored
@ -2,4 +2,5 @@ interface ISeriesEpisode {
|
|||||||
address: string;
|
address: string;
|
||||||
episode: string;
|
episode: string;
|
||||||
volume: number;
|
volume: number;
|
||||||
|
retry: number;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,27 +56,45 @@ export default function(config: IConfig, address: string, done: (err: Error) =>
|
|||||||
{
|
{
|
||||||
if (errD)
|
if (errD)
|
||||||
{
|
{
|
||||||
return done(errD);
|
if (page.episodes[i].retry <= 0)
|
||||||
}
|
|
||||||
|
|
||||||
if ((ignored === false) || (ignored === undefined))
|
|
||||||
{
|
|
||||||
const newCache = JSON.stringify(cache, null, ' ');
|
|
||||||
fs.writeFile(persistentPath, newCache, (errW: Error) =>
|
|
||||||
{
|
{
|
||||||
if (errW)
|
console.error(err.stack || err);
|
||||||
|
console.error('Cannot fetch episode "s' + page.episodes[i].volume + 'e' + page.episodes[i].episode +
|
||||||
|
'", please rerun later');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (config.verbose)
|
||||||
{
|
{
|
||||||
return done(errW);
|
console.error(errD.stack || errD);
|
||||||
}
|
}
|
||||||
|
console.warn('Retrying to fetch episode "s' + page.episodes[i].volume + 'e' + page.episodes[i].episode +
|
||||||
i += 1;
|
'" - Retry ' + page.episodes[i].retry + ' / ' + config.retry);
|
||||||
next();
|
page.episodes[i].retry -= 1;
|
||||||
});
|
}
|
||||||
|
next();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
i += 1;
|
if ((ignored === false) || (ignored === undefined))
|
||||||
next();
|
{
|
||||||
|
const newCache = JSON.stringify(cache, null, ' ');
|
||||||
|
fs.writeFile(persistentPath, newCache, (errW: Error) =>
|
||||||
|
{
|
||||||
|
if (errW)
|
||||||
|
{
|
||||||
|
return done(errW);
|
||||||
|
}
|
||||||
|
|
||||||
|
i += 1;
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i += 1;
|
||||||
|
next();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
@ -152,6 +170,7 @@ function page(config: IConfig, address: string, done: (err: Error, result?: ISer
|
|||||||
address: address.substr(1),
|
address: address.substr(1),
|
||||||
episode: '',
|
episode: '',
|
||||||
volume: 0,
|
volume: 0,
|
||||||
|
retry: config.retry,
|
||||||
});
|
});
|
||||||
done(null, {episodes: episodes.reverse(), series: ''});
|
done(null, {episodes: episodes.reverse(), series: ''});
|
||||||
}
|
}
|
||||||
@ -191,6 +210,7 @@ function page(config: IConfig, address: string, done: (err: Error, result?: ISer
|
|||||||
address: url,
|
address: url,
|
||||||
episode: episode[1],
|
episode: episode[1],
|
||||||
volume: volume ? parseInt(volume[0], 10) : 1,
|
volume: volume ? parseInt(volume[0], 10) : 1,
|
||||||
|
retry: config.retry,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
if (episodeCount === 0)
|
if (episodeCount === 0)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user