Skip to content

Commit

Permalink
Fixed conflicts with other unintended games
Browse files Browse the repository at this point in the history
  • Loading branch information
yangchang-n authored Mar 13, 2024
1 parent c36419d commit 0d6d40b
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,27 @@
game_code = '26'

# Game Code
# 1 : Honkai Impact 3rd
# 2 : Genshin Impact
# 6 : Honkai: Star Rail

gh_api_url = 'https://api.github.com'
gh_token = os.environ['GH_TOKEN']
gist_id = os.environ['GIST_ID']

def get_only_data_needed(userInfoInGame, list_to_return) :

list_to_return[-1].append(str(userInfoInGame['level']))
for eachData in userInfoInGame['data'] :
if 'Active' in eachData['name'] :
list_to_return[-1].append(eachData['value'])
elif 'Characters' in eachData['name'] :
list_to_return[-1].append(eachData['value'])
elif 'Achievements' in eachData['name'] :
list_to_return[-1].append(eachData['value'])

return list_to_return

def get_data_from_hoyolab(hoyo_uid, hoyo_token) :

headers = {
Expand All @@ -31,16 +45,10 @@ def get_data_from_hoyolab(hoyo_uid, hoyo_token) :
for eachGame in jsonData['data']['list'] :
if eachGame['game_id'] == 2 :
return_list.append(['Genshin Impact'])
return_list = get_only_data_needed(eachGame, return_list)
elif eachGame['game_id'] == 6 :
return_list.append(['Honkai: Star Rail'])
return_list[-1].append(str(eachGame['level']))
for eachData in eachGame['data'] :
if 'Active' in eachData['name'] :
return_list[-1].append(eachData['value'])
elif 'Characters' in eachData['name'] :
return_list[-1].append(eachData['value'])
elif 'Achievements' in eachData['name'] :
return_list[-1].append(eachData['value'])
return_list = get_only_data_needed(eachGame, return_list)
return return_list
else : return 'Error occured'

Expand Down

0 comments on commit 0d6d40b

Please sign in to comment.