mirror of
https://github.com/fHDHR/fHDHR_NextPVR.git
synced 2025-12-06 14:36:59 -05:00
Add Play Duration to debug
This commit is contained in:
parent
1e98e30c9d
commit
104806cd90
@ -1,6 +1,8 @@
|
|||||||
import threading
|
import threading
|
||||||
|
import datetime
|
||||||
|
|
||||||
from fHDHR.exceptions import TunerError
|
from fHDHR.exceptions import TunerError
|
||||||
|
from fHDHR.tools import humanized_time
|
||||||
|
|
||||||
|
|
||||||
class Tuner():
|
class Tuner():
|
||||||
@ -20,6 +22,7 @@ class Tuner():
|
|||||||
"method": stream_args["method"],
|
"method": stream_args["method"],
|
||||||
"accessed": stream_args["accessed"],
|
"accessed": stream_args["accessed"],
|
||||||
"proxied_url": stream_args["channelUri"],
|
"proxied_url": stream_args["channelUri"],
|
||||||
|
"time_start": datetime.datetime.utcnow(),
|
||||||
}
|
}
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
@ -28,15 +31,16 @@ class Tuner():
|
|||||||
self.tuner_lock.release()
|
self.tuner_lock.release()
|
||||||
|
|
||||||
def get_status(self):
|
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):
|
def set_off_status(self):
|
||||||
self.status = {
|
self.status = {"status": "Inactive"}
|
||||||
"status": "Inactive",
|
|
||||||
"method": None,
|
|
||||||
"accessed": None,
|
|
||||||
"proxied_url": None,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class Tuners():
|
class Tuners():
|
||||||
|
|||||||
@ -76,6 +76,39 @@ def hours_between_datetime(first_time, later_time):
|
|||||||
return (timebetween.total_seconds() / 60 / 60)
|
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():
|
class WebReq():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.session = requests.Session()
|
self.session = requests.Session()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user