feat: add an interval option to avoid triggering rate limit #185
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
在使用下载一些有很多课程的纯 Markdown 时发现在下载几十个之后会触发限流,检查源码发现如果是下载 PDF,每个页面打开后会等待一段时间,因此不太可能会触发限流,但下载 Markdown 的时候没有这个长的间隔,只有一个2秒内的随机间隔。
因此增加了一个 interval 选项,以秒为单位,在每篇文章之间间隔 interval 秒 + 2秒内的 jitter 来避免触发限流限制。默认为0秒秒,兼容以前的状态。实测 interval = 5时,下载120篇左右的文章不会触发限流。