Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion lib/faexport/scraper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@
rescue OpenURI::HTTPError => e
$http_errors.increment(labels: { page_type: page_type })
# Detect and handle known errors
if e.io.status[0] == "403" || e.io.status[0] == "503"
if e.io.status[0] == "403" || e.io.status[0] == "503" || e.io.status[0] == "400"
raw = e.io.read
html = Nokogiri::HTML(raw.encode("UTF-8", invalid: :replace, undef: :replace).delete("\000"))

Expand All @@ -1334,6 +1334,18 @@
$slowdown_errors.increment(labels: { page_type: page_type })
raise FASlowdownError.new(url)
end

# Handle user not found errors
if e.io.status[0] == "400"
head = html.xpath("//head//title").first
if head.content == "System Error"
error_msg = html.at_css("table.maintable td.alt1 font").content
# Handle user profile not found, and user not found on journal listing
if error_msg.include?("This user cannot be found") || error_msg.include?("User not found!")
raise FANoUserError.new(url)
end
end
end
end
# Retry some types of error
if e.io.status[0] == "502" || e.io.status[0] == "520"
Expand Down Expand Up @@ -1428,6 +1440,9 @@
if maintable_content.include?("has voluntarily disabled access to their account and all of its contents.")
raise FAAccountDisabledError.new(url)
end
if maintable_content.include?("Access has been disabled to the account and contents of user")
raise FAAccountDisabledError.new(url)
end

# Handle user not existing (this version of the error is raised by watchers lists and galleries)
if maintable_content.include?("Provided username not found in the database.") ||
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/check_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
RSpec::Matchers.define :be_valid_date_and_match_iso do |iso_string|
match do |date_string|
expect(date_string).not_to be_blank
expect(date_string).to match(/[A-Z][a-z]{2} [0-9]+([a-z]{2})?, [0-9]{4},? [0-9]{2}:[0-9]{2}( ?[AP]M)?/)
expect(date_string).to match(/[A-Z][a-z]{2,} [0-9]+([a-z]{2})?, [0-9]{4},? [0-9]{2}:[0-9]{2}(:[0-9]{2})?( ?[AP]M)?/)
expect(iso_string).not_to be_blank
expect(iso_string).to eql(Time.parse("#{date_string} UTC").iso8601)
end
Expand Down
Loading