mirror of
https://github.com/Ahrimdon/detailed-cod-tracker.git
synced 2024-11-03 16:46:44 -05:00
Cleanup cod_api additions
This commit is contained in:
parent
3bdbefd124
commit
06dde8f550
@ -547,30 +547,28 @@ class API:
|
|||||||
class __USER(_Common):
|
class __USER(_Common):
|
||||||
def info(self):
|
def info(self):
|
||||||
if self.loggedIn:
|
if self.loggedIn:
|
||||||
# Assuming 'user_info.json' is the file you've downloaded with the information.
|
# Assuming 'user_info.json' is the file you've downloaded with the information
|
||||||
file_path = 'userInfo.json'
|
file_path = 'userInfo.json'
|
||||||
# Load the JSON content from the local file.
|
# Load the JSON content from the local file
|
||||||
with open(file_path, 'r') as file:
|
with open(file_path, 'r') as file:
|
||||||
rawData = json.load(file)
|
rawData = json.load(file)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
userInfo = rawData['userInfo'] # Accessing the nested 'userInfo' dictionary.
|
userInfo = rawData['userInfo'] # Accessing the nested 'userInfo' dictionary
|
||||||
identities = rawData.get('identities', []) # Accessing the 'identities' if it exists or default to empty list.
|
identities = rawData.get('identities', []) # Accessing the 'identities' if it exists or default to empty list
|
||||||
|
|
||||||
data = {'userName': userInfo['userName'], 'identities': []} # Getting 'userName' from the nested dictionary.
|
data = {'userName': userInfo['userName'], 'identities': []} # Getting 'userName' from the nested dictionary
|
||||||
for i in identities: # Loop through each identity in the 'identities' list.
|
for i in identities: # Loop through each identity in the 'identities' list
|
||||||
data['identities'].append({
|
data['identities'].append({
|
||||||
'platform': i['provider'],
|
'platform': i['provider'],
|
||||||
'gamertag': i['username'],
|
'gamertag': i['username'],
|
||||||
'accountID': i['accountID'] # Assuming 'accountID' exists; otherwise, you might need a default value.
|
'accountID': i['accountID'] # Assuming 'accountID' exists; otherwise, you might need a default value
|
||||||
})
|
})
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
# Handle the case where the expected key is not found in the dictionary.
|
# Handle the case where the expected key is not found in the dictionary
|
||||||
print(f"Error: A required field is missing in the data. Details: {str(e)}")
|
print(f"Error: A required field is missing in the data. Details: {str(e)}")
|
||||||
# Re-raise the exception or handle it as required for your application's logic.
|
# Re-raise the exception or handle it as required
|
||||||
raise
|
raise
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user