mirror of
https://github.com/xfgryujk/blivechat.git
synced 2025-01-13 13:50:10 +08:00
修复获取头像请求被屏蔽的问题
也修改了其他请求的User-Agent,防止将来被屏蔽
This commit is contained in:
parent
1075b458aa
commit
2c0dd6e1c9
@ -306,7 +306,14 @@ class RoomInfoHandler(api.base.ApiHandler): # noqa
|
||||
async def _get_room_info(room_id):
|
||||
try:
|
||||
async with utils.request.http_session.get(
|
||||
blivedm_client.ROOM_INIT_URL, params={'room_id': room_id}
|
||||
blivedm_client.ROOM_INIT_URL,
|
||||
headers={
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)'
|
||||
' Chrome/102.0.0.0 Safari/537.36'
|
||||
},
|
||||
params={
|
||||
'room_id': room_id
|
||||
}
|
||||
) as res:
|
||||
if res.status != 200:
|
||||
logger.warning('room=%d _get_room_info failed: %d %s', room_id,
|
||||
|
2
blivedm
2
blivedm
@ -1 +1 @@
|
||||
Subproject commit d8f7f6b7828069cb6c1fd13f756cfd891f0b1a46
|
||||
Subproject commit 2cca7354b1e4e1376d66a4d442480d56e7d5e22f
|
@ -148,7 +148,14 @@ async def _get_avatar_url_from_web_coroutine(user_id, future):
|
||||
async def _do_get_avatar_url_from_web(user_id):
|
||||
try:
|
||||
async with utils.request.http_session.get(
|
||||
'https://api.bilibili.com/x/space/acc/info', params={'mid': user_id}
|
||||
'https://api.bilibili.com/x/space/acc/info',
|
||||
headers={
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)'
|
||||
' Chrome/102.0.0.0 Safari/537.36'
|
||||
},
|
||||
params={
|
||||
'mid': user_id
|
||||
}
|
||||
) as r:
|
||||
if r.status != 200:
|
||||
logger.warning('Failed to fetch avatar: status=%d %s uid=%d', r.status, r.reason, user_id)
|
||||
|
@ -424,6 +424,10 @@ class BilibiliTranslateFree(FlowControlTranslateProvider):
|
||||
try:
|
||||
async with utils.request.http_session.get(
|
||||
'https://api.live.bilibili.com/av/v1/SuperChat/messageTranslate',
|
||||
headers={
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)'
|
||||
' Chrome/102.0.0.0 Safari/537.36'
|
||||
},
|
||||
params={
|
||||
'room_id': '21396545',
|
||||
'ruid': '407106379',
|
||||
|
Loading…
Reference in New Issue
Block a user