Skip to content

Commit

Permalink
[Added] Proper IPTV services handling (#669)
Browse files Browse the repository at this point in the history
* [Added] Proper IPTV services handling

* [Updated] Enable IPTV service adjusting
  • Loading branch information
DimitarCC authored Jun 20, 2024
1 parent bb7100f commit ff52362
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 25 deletions.
5 changes: 3 additions & 2 deletions autotimer/src/AutoTimer.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ def readXml(self, **kwargs):
# Parse Config
try:
configuration = cet_parse(XML_CONFIG).getroot()
except:
except Exception as error:
print("An exception occurred:", error)
try:
if os_path.exists(XML_CONFIG + "_old"):
os_rename(XML_CONFIG + "_old", XML_CONFIG + "_old(1)")
Expand Down Expand Up @@ -365,7 +366,7 @@ def parseTimer(self, timer, epgcache, serviceHandler, recordHandler, checkEvtLim
except UnicodeDecodeError:
pass

self.isIPTV = bool([service for service in timer.services if ":http" in service])
self.isIPTV = bool([service for service in timer.services if "%3a//" in service])

# As well as description, also allow timers on individual IPTV streams
if timer.searchType == "description" or self.isIPTV:
Expand Down
4 changes: 2 additions & 2 deletions autotimer/src/AutoTimerComponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def checkServices(self, check_service):
if pos != -1:
if value[pos - 1] == ':':
pos -= 1
value = value[:pos + 1]
value = value[:pos + 1]

if value == check_service:
return False
Expand Down Expand Up @@ -695,7 +695,7 @@ def getFastServices(self):
if pos != -1:
if value[pos - 1] == ':':
pos -= 1
value = value[:pos + 1]
value = value[:pos + 1]

comp = value.split(':')
append(':'.join(value[3:]))
Expand Down
8 changes: 4 additions & 4 deletions autotimer/src/AutoTimerConfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def parseEntry(element, baseTimer, defaults=False):
if pos != -1:
if value[pos - 1] == ':':
pos -= 1
value = value[:pos + 1]
value = value[:pos + 1]

servicelist.append(value)
baseTimer.services = servicelist
Expand Down Expand Up @@ -376,7 +376,7 @@ def parseConfigOld(configuration, list, uniqueTimerId=0):
if pos != -1:
if value[pos - 1] == ':':
pos -= 1
value = value[:pos + 1]
value = value[:pos + 1]

servicelist.append(value)
else:
Expand Down Expand Up @@ -628,7 +628,7 @@ def buildConfig(defaultTimer, timers, webif=False):
# Services
for serviceref in defaultTimer.services:
ref = ServiceReference(str(serviceref))
extend((' <serviceref>', serviceref, '</serviceref>',
extend((' <serviceref>', serviceref.replace("&", "&amp;"), '</serviceref>',
' <!-- ', stringToXML(removeBad(ref.getServiceName())), ' -->\n',
))

Expand Down Expand Up @@ -785,7 +785,7 @@ def buildConfig(defaultTimer, timers, webif=False):
# Services
for serviceref in timer.services:
ref = ServiceReference(str(serviceref))
extend((' <serviceref>', serviceref, '</serviceref>',
extend((' <serviceref>', serviceref.replace("&", "&amp;"), '</serviceref>',
' <!-- ', stringToXML(removeBad(ref.getServiceName())), ' -->\n',
))

Expand Down
25 changes: 11 additions & 14 deletions autotimer/src/AutoTimerEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def __init__(self, timer, editingDefaults=False):
else:
self.serviceRestriction = False

self.isIPTV = bool([service for service in timer.services if ":http" in service])
self.isIPTV = bool([service for service in timer.services if "%3a//" in service])

self.createSetup(timer)

Expand Down Expand Up @@ -540,9 +540,7 @@ def renameFilterButton(self):
self.reloadList(True)

def renameServiceButton(self):
if self.isIPTV:
self["key_blue"].text = ""
elif self.serviceRestriction:
if self.serviceRestriction:
self["key_blue"].text = _("Edit services")
else:
self["key_blue"].text = _("Add services")
Expand Down Expand Up @@ -763,14 +761,13 @@ def editFilterCallback(self, ret):
self.renameFilterButton()

def editServices(self):
if not self.isIPTV:
self.session.openWithCallback(
self.editServicesCallback,
AutoTimerServiceEditor,
self.serviceRestriction,
self.services,
self.bouquets
)
self.session.openWithCallback(
self.editServicesCallback,
AutoTimerServiceEditor,
self.serviceRestriction,
self.services,
self.bouquets
)

def editServicesCallback(self, ret):
if ret:
Expand Down Expand Up @@ -1542,7 +1539,7 @@ def finishedServiceSelection(self, *args):
if pos != -1:
if sname[pos - 1] == ':':
pos -= 1
sname = sname[:pos + 1]
sname = sname[:pos + 1]

list.append(getConfigListEntry(_("Record on"), NoSave(ConfigSelection(choices=[(sname, ServiceReference(args[0]).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''))]))))
self["config"].setList(list)
Expand Down Expand Up @@ -1708,7 +1705,7 @@ def addAutotimerFromService(session, service=None):
if pos != -1:
if sref[pos - 1] == ':':
pos -= 1
sref = sref[:pos + 1]
sref = sref[:pos + 1]

sref = ServiceReference(sref)
if info:
Expand Down
4 changes: 2 additions & 2 deletions autotimer/src/AutoTimerImporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def accept(self):
if pos != -1:
if value[pos - 1] == ':':
pos -= 1
value = value[:pos + 1]
value = value[:pos + 1]

autotimer.services = [value]
elif item[2] == 4: # AfterEvent
Expand Down Expand Up @@ -343,7 +343,7 @@ def accept(self):
if pos != -1:
if value[pos - 1] == ':':
pos -= 1
value = value[:pos + 1]
value = value[:pos + 1]
autotimer.services = [value]

if autotimer.match == "":
Expand Down
2 changes: 1 addition & 1 deletion autotimer/src/AutoTimerResource.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def getA(name, default=None):
if pos != -1:
if value[pos - 1] == ':':
pos -= 1
value = value[:pos + 1]
value = value[:pos + 1]

if myref.valid():
appendlist.append(value)
Expand Down

0 comments on commit ff52362

Please sign in to comment.