YT: abort on 429 error

This commit is contained in:
Rafał Dzięgiel
2021-03-16 10:33:31 +01:00
parent e0a3ef78db
commit 72b55939b4

View File

@@ -237,13 +237,17 @@ var YouTubeClient = GObject.registerClass({
if(statusCode === 200) if(statusCode === 200)
return resolve(result); return resolve(result);
debug(new Error(`response code: ${statusCode}`));
/* Internal Soup codes mean download aborted /* Internal Soup codes mean download aborted
* or some other error that cannot be handled * or some other error that cannot be handled
* and we do not want to retry in such case */ * and we do not want to retry in such case */
if(statusCode < 10) if(statusCode < 10 || statusCode === 429) {
result.isAborted = true; result.isAborted = true;
return resolve(result);
}
return reject(new Error(`response code: ${statusCode}`)); return reject(new Error('could not download data'));
}); });
}); });
} }