diff --git a/spec/fixtures/ratelimit.html b/spec/fixtures/ratelimit.html new file mode 100644 index 0000000..31f03f3 --- /dev/null +++ b/spec/fixtures/ratelimit.html @@ -0,0 +1,65 @@ + + + + + + Too Many Free PDF Requests + + + + +
+ +
+

Too Many Free PDF Requests

+

Your IP has requested too many free PDFs too quickly.

+

Please wait before you continue downloading, and if possible slow down the rate of your requests.

+
+
+ + + \ No newline at end of file diff --git a/src/fetch.cr b/src/fetch.cr index c713b7c..eece004 100644 --- a/src/fetch.cr +++ b/src/fetch.cr @@ -71,6 +71,9 @@ module Muse::Dl if /Unable to/.match line raise Muse::Dl::Errors::MuseCorruptPDF.new("Error: MUSE is unable to generate PDF for #{url}") end + if /Your IP has requested/.match line + raise Muse::Dl::Errors::DownloadError.new("Error: MUSE Rate-limit reached") + end end end end