添加错误处理

pull/3/head
John Smith 5 years ago
parent da242fc853
commit 846e830f9c

@ -1 +1 @@
Subproject commit 39fb86a9b20f8d94501dd2e25f16a1c573b1e33f
Subproject commit 2f705b86ce02e4c8c93ca6d066964747160fd617

@ -31,6 +31,9 @@ async def get_avatar_url(user_id):
return _avatar_url_cache[user_id]
async with _http_session.get('https://api.bilibili.com/x/space/acc/info',
params={'mid': user_id}) as r:
if r.status != 200: # 可能会被B站ban
logger.error('获取头像失败status=%d %s uid=%d', r.status, r.reason, user_id)
return 'https://static.hdslb.com/images/member/noface.gif'
data = await r.json()
url = data['data']['face']
if not url.endswith('noface.gif'):

Loading…
Cancel
Save