File tree Expand file tree Collapse file tree
src/europython_discord/program_notifications Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import asyncio
2+ import logging
23import tomllib
34from datetime import date
45from pathlib import Path
56
67import aiofiles
78
9+ logger = logging .getLogger (__name__ )
10+
811
912class LivestreamConnector :
1013 def __init__ (self , livestreams_file : Path ) -> None :
@@ -40,17 +43,22 @@ async def fetch_livestreams(self) -> None:
4043 livestreams_raw = await self ._open_livestreams_file ()
4144 self .livestreams_by_room = await self ._parse_livestreams (livestreams_raw )
4245
43- async def get_livestream_url (self , room : str , date : date ) -> None :
46+ async def get_livestream_url (self , room : str , day : date ) -> str | None :
4447 """
4548 Get the livestream URL for the given room and date.
4649
4750 :param room: The room name.
48- :param date : The date of the livestream.
51+ :param day : The date of the livestream.
4952
5053 :return: The URL of the livestream.
5154 """
5255 if not self .livestreams_by_room :
5356 await self .fetch_livestreams ()
57+
5458 if room not in self .livestreams_by_room :
59+ logger .warning (f"Found no livestream URLs for room { room !r} " )
60+ return None
61+ if day not in self .livestreams_by_room [room ]:
62+ logger .warning (f"Found no livestream URLs for room { room !r} and day { day !r} " )
5563 return None
56- return self .livestreams_by_room [room ][date ]
64+ return self .livestreams_by_room [room ][day ]
You can’t perform that action at this time.
0 commit comments