Skip to content

Commit

Permalink
* add streamrelay flag to epg api's
Browse files Browse the repository at this point in the history
  • Loading branch information
jbleyel committed May 16, 2024
1 parent d0dbcbc commit a2ad0d1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions plugin/controllers/models/epg.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def __init__(self):
self.doref = True
self.currentpicon = ""
self.currentsref = ""
self.streamRelay = []

def search(self, querystring, searchfulldescription=False):
querytype = eEPGCache.PARTIAL_TITLE_SEARCH
Expand Down Expand Up @@ -247,6 +248,7 @@ def getEventDescription(self, sref, eventid, encode=True, default=""):
def convertEvent(self, *event):
encode = self.doencode
alter = self.doalter
streamRelay = self.streamRelay
ev = {}
ev["id"] = event[0]
if event[1]:
Expand All @@ -264,6 +266,9 @@ def convertEvent(self, *event):
ev["now_timestamp"] = event[3]
ev["remaining"] = (event[1] + event[2]) - event[3]
ev["genre"], ev["genreid"] = convertGenre(event[7])
if streamRelay:
ev['streamrelay'] = event[8] in streamRelay

else:
ev["begin_timestamp"] = 0
ev["duration_sec"] = 0
Expand Down
11 changes: 10 additions & 1 deletion plugin/controllers/models/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ def getMultiChannelNowNextEpg(slist, encode=False):
return {"events": events, "result": True}


def getBouquetNowNextEpg(bqref, nowornext, encode=False, showisplayable=False):
def getBouquetNowNextEpg(bqref, nowornext, encode=False, showisplayable=False, showstreamrelay=False):
bqref = unquote(bqref)
services = eServiceCenter.getInstance().list(eServiceReference(bqref))
if not services:
Expand Down Expand Up @@ -899,6 +899,15 @@ def getBouquetNowNextEpg(bqref, nowornext, encode=False, showisplayable=False):
query.append((service, nowornext, -1))

epg = EPG()
streamRelay = []
if showstreamrelay:
try:
with open("/etc/enigma2/whitelist_streamrelay") as fd:
streamRelay = [line.strip() for line in fd.readlines()]
except OSError:
pass
epg.streamRelay = streamRelay

events = epg.getBouquetNowNextEpg(query, encode, alter=True, full=True)

return {"events": events, "isplayable": isPlayable, "result": True}
Expand Down
3 changes: 2 additions & 1 deletion plugin/controllers/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,8 @@ def epgnownext(self, request, nowornext):
return res
bref = getUrlArg(request, "bRef")
showisplayable = getUrlArg(request, "showIsPlayable") is not None
ret = getBouquetNowNextEpg(bref, nowornext, self.isJson, showisplayable)
showstreamrelay = True if getUrlArg(request, "showstreamrelay", "0") in ("1", "true") else False
ret = getBouquetNowNextEpg(bref, nowornext, self.isJson, showisplayable=showisplayable, showstreamrelay=showstreamrelay)
if nowornext == EPG.NOW_NEXT:
info = getCurrentService(self.session)
ret["info"] = info
Expand Down

0 comments on commit a2ad0d1

Please sign in to comment.