From 9ecb07b666dab389bcd12e8bea49a73ce2a71c86 Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Fri, 13 Oct 2023 00:01:55 +0200 Subject: [PATCH] Expose connection url --- speedport/api.py | 5 +++++ speedport/connection.py | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/speedport/api.py b/speedport/api.py index b1195ad..2a8af8c 100644 --- a/speedport/api.py +++ b/speedport/api.py @@ -39,6 +39,7 @@ def __init__( self._host: str = host self._password: str = password self._https: bool = https + self._url = f"https://{host}" if https else f"http://{host}" self._session: aiohttp.ClientSession | None = session async def __aenter__(self): @@ -65,6 +66,10 @@ def api(self) -> Connection: def password(self) -> str: return self._password + @property + def url(self) -> str: + return self._url + async def get_status(self): return await self.api.get("data/Status.json") diff --git a/speedport/connection.py b/speedport/connection.py index 7d34489..d69663b 100644 --- a/speedport/connection.py +++ b/speedport/connection.py @@ -56,13 +56,12 @@ def simplify_response( class Connection: def __init__( self, - host: str = "speedport.ip", - https: bool = False, + host_url: str = "", session: aiohttp.ClientSession | None = None, ): self._login_key = "" self._cookies = {} - self._url = f"https://{host}" if https else f"http://{host}" + self._url = host_url self._session: aiohttp.ClientSession | None = session async def __aenter__(self):