1.0.0+kodimov.13: updates don't stop live TV; IPTV Simple restarts only when idle

- After an add-on update the new service found port 57031 still held by the
  old proxy for a moment and moved to a random port; the stream playing kept
  asking 57031 for its manifest and died a minute later (.49, 2026-11-13).
  The proxy now waits up to 10 s for the port, and SO_REUSEADDR /
  allow_reuse_address are set before binding (upstream set them after, so
  they did nothing).
- IPTV Simple is restarted only when nothing plays and no key was pressed
  for 30 s: on .49 a channel opened during a restart failed with an error.
- After start or update, changed instance files (duplicate removed, refresh
  timer) are picked up by the guide reload instead of a restart of their
  own; the service restarts IPTV Simple itself only if that reload didn't
  happen within 10 minutes. 3 restarts after kodimov.12 -> 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
XoséandClaude Opus 5.5 committed 2026-11-13 15:16:30 +01:00
1 parent 69a37ff064
commit 7873b50203
6 files changed
+63 -15

No files matched your search

+11 -4
View File
@@ -29,7 +29,8 @@ if __name__ == '__main__':
# programme guide a minute after Kodi starts and then every 6 hours; a
# refresh that failed is tried again half an hour later. Opening the add-on
# also renews the 10-day Movistar login.
next_check = time.time() + 60
started = time.time()
next_check = started + 60
max_age = 0 # always refresh once after Kodi starts
new_api_retries = 6
try:
@@ -39,12 +40,17 @@ if __name__ == '__main__':
except RuntimeError: # IPTV Simple not installed or disabled
pvr_dir = None
restart_iptv = False
player = xbmc.Player()
# A changed instance file needs IPTV Simple restarted. The guide reload
# after start (below) restarts it anyway, so that one is left to do it;
# this is only the fallback, 10 minutes later, if it didn't happen.
restart_after = started + 10 * 60
monitor = xbmc.Monitor()
while not monitor.abortRequested():
if monitor.waitForAbort(1):
break
if restart_iptv and not player.isPlaying(): # restarting stops live TV
if restart_iptv and kodimov.last_iptv_restart() > started:
restart_iptv = False
if restart_iptv and time.time() >= restart_after and kodimov.is_idle():
restart_iptv = False
kodimov.restart_iptv_simple()
if time.time() >= next_check:
@@ -57,13 +63,14 @@ if __name__ == '__main__':
age_limit, max_age = max_age, 6 * 3600 - 120
# After Kodi starts (or this add-on updates) also get the new guide into Kodi now
reload_guide = '&reload_guide=1' if age_limit == 0 else ''
if restart_iptv: reload_guide = '&reload_guide=force' # also for the changed instance files
# The new servers failed (they at times refuse everything for minutes):
# the list lacks LALIGA, DAZN LALIGA, Liga de Campeones. Try again in
# half an hour, a few times, instead of in 6 hours.
if new_api_retries and kodimov.new_api_failed(profile_dir):
new_api_retries -= 1
age_limit = 0
reload_guide = '&reload_guide=1'
reload_guide = reload_guide or '&reload_guide=1'
if addon.getSettingBool('auto_export_epg'): # channels + programme guide
if file_age(os.path.join(profile_dir, 'epg.xml')) > age_limit:
exporting = True