From ee869e584230f0906d9c769bea031fc34369db78 Mon Sep 17 00:00:00 2001 From: Matthew Grove Date: Fri, 17 May 2024 00:24:49 +0100 Subject: [PATCH] More efficient function usage --- api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api.py b/api.py index 754da58..890c79e 100644 --- a/api.py +++ b/api.py @@ -1,6 +1,6 @@ from requests import get, post from gc import collect -from time import mktime, localtime +from time import mktime, time from env import HASS_URL, TOKEN def getReq(endpoint) -> dict: @@ -55,7 +55,7 @@ def getMediaPlayerData(entity_id: str) -> dict: if ("media_position_updated_at" in (dict)(response["attributes"])): dts = response["attributes"]["media_position_updated_at"] t = mktime((int(dts[0:4]), int(dts[5:7]), int(dts[8:10]), int(dts[11:13]) + int(dts[27:29]), int(dts[14:16]) + int(dts[30:31]), int(dts[17:19]), 0, 0)) - p += mktime(localtime()) - t + p += time() - t return { "playing": response["state"] in ["on", "playing", "buffering"], "shuffle": response["attributes"]["shuffle"] if e and "shuffle" in response["attributes"] else False,