1
0
mirror of https://github.com/fHDHR/fHDHR_NextPVR.git synced 2025-12-06 17:56:57 -05:00

Add EPG debug

This commit is contained in:
deathbybandaid 2020-10-27 11:03:29 -04:00
parent 104806cd90
commit dbce0b6745
3 changed files with 21 additions and 4 deletions

View File

@ -14,7 +14,7 @@ class fHDHR_Device():
self.epg = epg.EPG(settings, self.channels) self.epg = epg.EPG(settings, self.channels)
self.tuners = Tuners(settings) self.tuners = Tuners(settings, self.epg)
self.watch = WatchStream(settings, self.channels, self.tuners) self.watch = WatchStream(settings, self.channels, self.tuners)

View File

@ -1,6 +1,7 @@
import os import os
import json import json
import time import time
import datetime
from collections import OrderedDict from collections import OrderedDict
from multiprocessing import Process from multiprocessing import Process
@ -31,6 +32,19 @@ class EPG():
self.epgscan = Process(target=self.epgServerProcess) self.epgscan = Process(target=self.epgServerProcess)
self.epgscan.start() self.epgscan.start()
def whats_on_now(self, channel):
epgdict = self.get_epg()
listings = epgdict[channel]["listing"]
for listing in listings:
nowtime = datetime.datetime.utcnow()
start_time = datetime.datetime.strptime(listing["time_start"], '%Y%m%d%H%M%S +0000')
end_time = datetime.datetime.strptime(listing["time_end"], '%Y%m%d%H%M%S +0000')
if start_time <= nowtime <= end_time:
epgitem = epgdict[channel].copy()
epgitem["listing"] = [listing]
return epgitem
return None
def get_epg(self): def get_epg(self):
epgdict = None epgdict = None
if os.path.isfile(self.epg_cache_file): if os.path.isfile(self.epg_cache_file):

View File

@ -6,8 +6,9 @@ from fHDHR.tools import humanized_time
class Tuner(): class Tuner():
def __init__(self, inum): def __init__(self, inum, epg):
self.number = inum self.number = inum
self.epg = epg
self.tuner_lock = threading.Lock() self.tuner_lock = threading.Lock()
self.set_off_status() self.set_off_status()
@ -37,6 +38,7 @@ class Tuner():
humanized_time( humanized_time(
int((datetime.datetime.utcnow() - current_status["time_start"]).total_seconds()))) int((datetime.datetime.utcnow() - current_status["time_start"]).total_seconds())))
current_status["time_start"] = str(current_status["time_start"]) current_status["time_start"] = str(current_status["time_start"])
current_status["epg"] = self.epg.whats_on_now(current_status["accessed"].split("v")[-1])
return current_status return current_status
def set_off_status(self): def set_off_status(self):
@ -45,12 +47,13 @@ class Tuner():
class Tuners(): class Tuners():
def __init__(self, settings): def __init__(self, settings, epg):
self.config = settings self.config = settings
self.epg = epg
self.max_tuners = int(self.config.dict["fhdhr"]["tuner_count"]) self.max_tuners = int(self.config.dict["fhdhr"]["tuner_count"])
for i in range(1, self.max_tuners + 1): for i in range(1, self.max_tuners + 1):
exec("%s = %s" % ("self.tuner_" + str(i), "Tuner(i)")) exec("%s = %s" % ("self.tuner_" + str(i), "Tuner(i, epg)"))
def tuner_grab(self, stream_args, tunernum=None): def tuner_grab(self, stream_args, tunernum=None):
tunerselected = None tunerselected = None