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:
parent
876be19c8b
commit
28587c0de2
1 changed files with 7 additions and 5 deletions
|
|
@ -124,10 +124,12 @@ function retry(times, fn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadChapter(url) {
|
function downloadChapter(url) {
|
||||||
// Necessary for https://parahumans.wordpress.com/2011/10/11/interlude-3½-bonus/
|
return retry(3, () => {
|
||||||
const escapedUrl = encodeURI(url);
|
return request(url).redirects(10).then(response => {
|
||||||
|
if (response.status !== 200) {
|
||||||
return retry(3, function () {
|
throw new Error(`Response status for ${url} was ${response.status}`);
|
||||||
return request(escapedUrl).redirects(10);
|
}
|
||||||
|
return response;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue