Fix status_code logic bug

This commit is contained in:
Paul Pfeister 2024-04-11 17:28:39 -04:00
parent da3c90fce8
commit 060088f7a1
2 changed files with 11 additions and 13 deletions

View file

@ -1280,7 +1280,7 @@
"username_claimed": "blue"
},
"Minecraft": {
"errorCode": [204, 404, 405],
"errorCode": 204,
"errorType": "status_code",
"url": "https://api.mojang.com/users/profiles/minecraft/{}",
"urlMain": "https://minecraft.net/",
@ -1763,7 +1763,7 @@
"username_claimed": "blue"
},
"Slides": {
"errorCode": [204, 404],
"errorCode": 204,
"errorType": "status_code",
"url": "https://slides.com/{}",
"urlMain": "https://slides.com/",

View file

@ -406,19 +406,17 @@ def sherlock(
else:
query_status = QueryStatus.AVAILABLE
elif error_type == "status_code":
query_status = QueryStatus.AVAILABLE
error_codes = net_info.get("errorCode")
query_status = QueryStatus.CLAIMED
if error_codes: # (if set in data.json)
# Type consistency, allowing for both singlets and lists in manifest
if isinstance(error_codes, int):
if error_codes != r.status_code:
query_status = QueryStatus.CLAIMED
else:
if r.status_code not in error_codes:
query_status = QueryStatus.CLAIMED
# Checks if the status code of the response is 2XX
elif not r.status_code >= 300 or r.status_code < 200:
query_status = QueryStatus.CLAIMED
error_codes = [error_codes]
if r.status_code in error_codes:
query_status = QueryStatus.AVAILABLE
elif r.status_code >= 300 or r.status_code < 200:
query_status = QueryStatus.AVAILABLE
elif error_type == "response_url":
# For this detection method, we have turned off the redirect.
# So, there is no need to check the response URL: it will always