Fix the downloads to not stop at Interlude 3½

Apparently encoding the request URL is no longer a good idea, and generates a 404. Also, properly bail on 404s, instead of just counting it as the last chapter.
This commit is contained in:
Domenic Denicola 2017-01-02 19:28:25 -05:00
commit 28587c0de2

View file

@ -124,10 +124,12 @@ function retry(times, fn) {
}
function downloadChapter(url) {
// Necessary for https://parahumans.wordpress.com/2011/10/11/interlude-3½-bonus/
const escapedUrl = encodeURI(url);
return retry(3, function () {
return request(escapedUrl).redirects(10);
return retry(3, () => {
return request(url).redirects(10).then(response => {
if (response.status !== 200) {
throw new Error(`Response status for ${url} was ${response.status}`);
}
return response;
});
});
}