Skip to content

Commit

Permalink
fix: live check_connectivity behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
imkero authored and acgnhiki committed Jun 21, 2024
1 parent 772eb5e commit 1206d6e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/blrec/bili/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,13 @@ def is_living(self) -> bool:

async def check_connectivity(self) -> bool:
try:
await self._session.head('https://live.bilibili.com/', timeout=3)
except (aiohttp.ClientConnectionError, asyncio.TimeoutError):
return False
else:
await self._session.head('https://live.bilibili.com/', timeout=3, headers={
'User-Agent': self._user_agent,
})
return True
except Exception as e:
self._logger.warning(f'Check connectivity failed: {repr(e)}')
return False

async def update_info(self, raise_exception: bool = False) -> bool:
return all(
Expand Down

0 comments on commit 1206d6e

Please sign in to comment.