Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mod for IPTV autotimers #178

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 77 additions & 4 deletions autotimer/src/AutoTimer.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ def __init__(self):
True # Enabled
)

self.haveCachedServiceList = False
self.cachedServiceList = []

# Configuration
def readXml(self):
# Abort if no config found
Expand Down Expand Up @@ -305,7 +308,7 @@ def JobStart(self):
def parseTimer(self, timer, epgcache, serviceHandler, recordHandler, checkEvtLimit, evtLimit, timers, conflicting, similars, skipped, existing, timerdict, moviedict, simulateOnly=False):
new = 0
modified = 0

# Precompute timer destination dir
dest = timer.destination or config.usage.default_path.value

Expand Down Expand Up @@ -406,12 +409,12 @@ def parseTimer(self, timer, epgcache, serviceHandler, recordHandler, checkEvtLim
for idx, ( serviceref, eit, name, begin, duration, shortdesc, extdesc ) in enumerate( epgmatches ):

eserviceref = eServiceReference(serviceref)
evt = epgcache.lookupEventId(eserviceref, eit)
evt = epgcache.lookupEventId(eserviceref, eit)
if not evt:
msg="[AutoTimer] Could not create Event!"
print(msg)
skipped.append((name, begin, begin, str(serviceref), timer.name, msg))
continue
continue
# Try to determine real service (we always choose the last one)
n = evt.getNumOfLinkageServices()
if n > 0:
Expand Down Expand Up @@ -455,7 +458,21 @@ def parseTimer(self, timer, epgcache, serviceHandler, recordHandler, checkEvtLim

# Check timer conditions
# NOTE: similar matches do not care about the day/time they are on, so ignore them
if timer.checkServices(serviceref) \

chkServices = timer.checkServices(serviceref)

if str(timer).find("http") != -1:
#print("[AutoTimerIPTVMod] Found http in timer!")
# now replace serviceref with http one
for service in timer.services:
if str(service).find(serviceref) != -1:
#print("[AutoTimerIPTVMod] Service matched (" + serviceref + ") (" + str(service) + ")")
chkServices = False
serviceref = str(service)
#else:
#print("[AutoTimerIPTVMod] Service not matched (" + serviceref + ") (" + str(service) + ")")

if chkServices \
or timer.checkDuration(duration) \
or (not similarTimer and (\
timer.checkTimespan(timestamp) \
Expand All @@ -466,6 +483,14 @@ def parseTimer(self, timer, epgcache, serviceHandler, recordHandler, checkEvtLim
skipped.append((name, begin, end, serviceref, timer.name, msg))
continue

if str(timer).find("http") != -1:
#print("[AutoTimerIPTVMod] Geting full service name")
#try to get full service from bouquet, incl name at end
fullserviceref = self.getFullServiceRef(serviceref, serviceHandler)
if fullserviceref != "":
print("[AutoTimerIPTVMod] full service found (" + serviceref + ") (" + fullserviceref + ")")
serviceref = fullserviceref

if timer.hasOffset():
# Apply custom Offset
begin, end = timer.applyOffset(begin, end)
Expand Down Expand Up @@ -817,3 +842,51 @@ def checkDoubleTimers(self, timer, name1, name2, starttime1, starttime2, endtime
foundstart = starttime1 == starttime2
foundend = endtime1 == endtime2
return foundTitle and foundstart and foundend

def getFullServiceRef(self, serviceref, serviceHandler):
if not self.haveCachedServiceList:
print("[AutoTimerIPTVMod] Getting full service list")
# Get all bouquets
bouquetlist = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get all bouquets is much easier:

serviceHandler = eServiceCenter.getInstance()
services = serviceHandler.list(eServiceReference('1:134:1:0:0:0:0:0:0:0:FROM BOUQUET "bouquets.tv" ORDER BY bouquet'))
bouquets = services and services.getContent("SN", True)

refstr = '1:134:1:0:0:0:0:0:0:0:FROM BOUQUET \"bouquets.tv\" ORDER BY bouquet'
bouquetroot = eServiceReference(refstr)
mask = eServiceReference.isDirectory
if config.usage.multibouquet.value:
bouquets = serviceHandler.list(bouquetroot)
if bouquets:
while True:
s = bouquets.getNext()
if not s.valid():
break
if s.flags & mask:
info = serviceHandler.info(s)
if info:
bouquetlist.append((info.getName(s), s))
else:
info = serviceHandler.info(bouquetroot)
if info:
bouquetlist.append((info.getName(bouquetroot), bouquetroot))

# Get all services
mask = (eServiceReference.isMarker | eServiceReference.isDirectory)
for name, bouquet in bouquetlist:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get all services from bouquet can be like this.

servicelist = ServiceList(eServiceReference(bRef))
slist = servicelist.getServicesAsList()
for sitem in slist:
sref = sitem[0]

if not bouquet.valid(): #check end of list
break
if bouquet.flags & eServiceReference.isDirectory:
services = serviceHandler.list(bouquet)
if not services is None:
while True:
service = services.getNext()
if not service.valid(): #check end of list
break
if not (service.flags & mask):
if service.toString().find("http") != -1: #only save http streams
self.cachedServiceList.append( service.toString() )
self.haveCachedServiceList = True
else:
print("[AutoTimerIPTVMod] Using cached full service list")

for service in self.cachedServiceList:
if service.find(serviceref) != -1:
return service
return ""