@@ -33,6 +33,8 @@ def __init__(
3333 port : int = 8989 ,
3434 request_timeout : int = 8 ,
3535 session : aiohttp .client .ClientSession = None ,
36+ tls : bool = False ,
37+ verify_ssl : bool = True ,
3638 user_agent : str = None ,
3739 ) -> None :
3840 """Initialize connection with receiver."""
@@ -44,6 +46,8 @@ def __init__(
4446 self .host = host
4547 self .port = port
4648 self .request_timeout = request_timeout
49+ self .tls = tls
50+ self .verify_ssl = verify_ssl
4751 self .user_agent = user_agent
4852
4953 if user_agent is None :
@@ -60,7 +64,7 @@ async def _request(
6064 params : Optional [Mapping [str , str ]] = None ,
6165 ) -> Any :
6266 """Handle a request to API."""
63- scheme = "http"
67+ scheme = "https" if self . tls else " http"
6468
6569 url = URL .build (
6670 scheme = scheme , host = self .host , port = self .port , path = self .base_path
@@ -79,7 +83,12 @@ async def _request(
7983 try :
8084 with async_timeout .timeout (self .request_timeout ):
8185 response = await self ._session .request (
82- method , url , data = data , params = params , headers = headers ,
86+ method ,
87+ url ,
88+ data = data ,
89+ params = params ,
90+ headers = headers ,
91+ ssl = self .verify_ssl ,
8392 )
8493 except asyncio .TimeoutError as exception :
8594 raise SonarrConnectionError (
@@ -144,7 +153,7 @@ async def update(self, full_update: bool = False) -> Application:
144153 self ._application .update_from_dict ({"diskspace" : diskspace })
145154 return self ._application
146155
147- async def calendar (self , start : int = None , end : int = None ) -> List [Episode ]:
156+ async def calendar (self , start : str = None , end : str = None ) -> List [Episode ]:
148157 """Get upcoming episodes.
149158
150159 If start/end are not supplied, episodes airing
0 commit comments