Skip to content

Commit

Permalink
Merge pull request sherlock-project#1263 from MoMMde/master
Browse files Browse the repository at this point in the history
Improving status code & added Mojang/Minecraft
  • Loading branch information
sdushantha committed Mar 10, 2022
2 parents 294e1e6 + ab4de46 commit 2ab7ca6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions sherlock/resources/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,14 @@
"username_claimed": "blue",
"username_unclaimed": "noonewouldeverusethis7"
},
"Minecraft": {
"errorType": "status_code",
"errorCode": 204,
"url": "https://api.mojang.com/users/profiles/minecraft/{}",
"urlMain": "https://minecraft.net/",
"username_claimed": "blue",
"username_unclaimed": "noonewouldeverusethis7"
},
"MyAnimeList": {
"errorType": "status_code",
"url": "https://myanimelist.net/profile/{}",
Expand Down
10 changes: 9 additions & 1 deletion sherlock/sherlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ def sherlock(username, site_data, query_notify,

# Get the expected error type
error_type = net_info["errorType"]
error_code = net_info.get("errorCode")

# Retrieve future and ensure it has finished
future = net_info["request_future"]
Expand Down Expand Up @@ -395,8 +396,15 @@ def sherlock(username, site_data, query_notify,
QueryStatus.AVAILABLE,
query_time=response_time)
elif error_type == "status_code":
# Checks if the Status Code is equal to the optional "errorCode" given in 'data.json'
if error_code == r.status_code:
result = QueryResult(username,
social_network,
url,
QueryStatus.AVAILABLE,
query_time=response_time)
# Checks if the status code of the response is 2XX
if not r.status_code >= 300 or r.status_code < 200:
elif not r.status_code >= 300 or r.status_code < 200:
result = QueryResult(username,
social_network,
url,
Expand Down

0 comments on commit 2ab7ca6

Please sign in to comment.