Skip to content

Commit

Permalink
添加cookie提高获取头像成功率
Browse files Browse the repository at this point in the history
  • Loading branch information
xfgryujk committed Oct 9, 2022
1 parent 062e7ed commit 1f89d0d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ async def _get_room_info(room_id):
'Origin': 'https://live.bilibili.com',
'Referer': f'https://live.bilibili.com/{room_id}'
},
cookies=utils.request.BILIBILI_COMMON_COOKIES,
params={
'room_id': room_id
}
Expand Down
1 change: 1 addition & 0 deletions services/avatar.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ async def _do_get_avatar_url_from_web(user_id):
'Origin': 'https://space.bilibili.com',
'Referer': f'https://space.bilibili.com/{user_id}/'
},
cookies=utils.request.BILIBILI_COMMON_COOKIES,
params={
'mid': user_id,
'token': '',
Expand Down
4 changes: 4 additions & 0 deletions utils/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)'
' Chrome/105.0.0.0 Safari/537.36'
}
BILIBILI_COMMON_COOKIES = {
'b_lsid': '639B17D4_9876590D28',
'_uuid': '883B5256-A359-E4A3-7159-123456794937E96237infoc'
}

http_session = aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=10))

0 comments on commit 1f89d0d

Please sign in to comment.