1
0
mirror of https://github.com/fHDHR/fHDHR_NextPVR.git synced 2025-12-06 09:36:59 -05:00

Add Play Duration to debug

This commit is contained in:
deathbybandaid 2020-10-27 10:19:11 -04:00
parent 1e98e30c9d
commit 104806cd90
2 changed files with 44 additions and 7 deletions

View File

@ -1,6 +1,8 @@
import threading
import datetime
from fHDHR.exceptions import TunerError
from fHDHR.tools import humanized_time
class Tuner():
@ -20,6 +22,7 @@ class Tuner():
"method": stream_args["method"],
"accessed": stream_args["accessed"],
"proxied_url": stream_args["channelUri"],
"time_start": datetime.datetime.utcnow(),
}
def close(self):
@ -28,15 +31,16 @@ class Tuner():
self.tuner_lock.release()
def get_status(self):
return self.status
current_status = self.status.copy()
if current_status["status"] == "Active":
current_status["Play Time"] = str(
humanized_time(
int((datetime.datetime.utcnow() - current_status["time_start"]).total_seconds())))
current_status["time_start"] = str(current_status["time_start"])
return current_status
def set_off_status(self):
self.status = {
"status": "Inactive",
"method": None,
"accessed": None,
"proxied_url": None,
}
self.status = {"status": "Inactive"}
class Tuners():

View File

@ -76,6 +76,39 @@ def hours_between_datetime(first_time, later_time):
return (timebetween.total_seconds() / 60 / 60)
def humanized_time(countdownseconds):
time = float(countdownseconds)
if time == 0:
return "just now"
year = time // (365 * 24 * 3600)
time = time % (365 * 24 * 3600)
day = time // (24 * 3600)
time = time % (24 * 3600)
time = time % (24 * 3600)
hour = time // 3600
time %= 3600
minute = time // 60
time %= 60
second = time
displaymsg = None
timearray = ['year', 'day', 'hour', 'minute', 'second']
for x in timearray:
currenttimevar = eval(x)
if currenttimevar >= 1:
timetype = x
if currenttimevar > 1:
timetype = str(x+"s")
if displaymsg:
displaymsg = str(displaymsg + " " + str(int(currenttimevar)) + " " + timetype)
else:
displaymsg = str(str(int(currenttimevar)) + " " + timetype)
if not displaymsg:
return "just now"
return displaymsg
# just for ignoring a pep error
year, day, hour, minute, second
class WebReq():
def __init__(self):
self.session = requests.Session()