def get_game_description(game_name, steam_description):
'''
gets description of game from IGDB, otherwise uses steam description if
possible.
'''
url = f'{app.config["IGDB_API_URL"]}/games/?fields=*&limit=1&search={game_name}'
headers = {
'Accept': 'application/json',
'user-key': app.config['IGDB_API_KEY']
}
res = cache.get(url, headers=headers).json()[0]
# check if we actually found something
if 'summary' in res.keys():
return shorten_description(res['summary'])
# otherwise use steam description
elif len(steam_description) > 0:
return shorten_description(steam_description)
# if no steam description, just tell the user
else:
return "Sorry, we couldn't find a description for this game ??"
评论列表
文章目录