game_info.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:shrec 作者: hamishivi 项目源码 文件源码
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 ??"
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号