1.0.0+kodimov.14: guide reload no longer skipped while the remote is in use; remove empty instances
- .190 on 2026-11-13: the box came on with an old epg.xml, Kodi stored it (no current programmes for 124 channels) and doesn't ask again for up to an hour. KodiMov+ wrote a new guide two minutes later, but the reload waited for 30 s without a key press and gave up after 10 minutes, while the guide was being browsed. It now waits for a 10 s pause, for as long as Kodi runs. - Instances with no channel list (the "Migrated Add-on Config" Kodi makes when IPTV Simple is installed again) are removed once KodiMov+'s own instance exists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7873b50203
commit
b62bf07a2b
4 files changed
+43
-15
No files matched your search
+37
-11
@@ -493,7 +493,7 @@ def reload_iptv_guide(pvr_dir, addon_id):
|
||||
nothing if something is playing."""
|
||||
import xbmc
|
||||
monitor = xbmc.Monitor()
|
||||
if not wait_until_idle(timeout=600): return
|
||||
if not wait_until_idle(): return
|
||||
if not set_iptv_refresh(pvr_dir, addon_id, 1): return
|
||||
try:
|
||||
restart_iptv_simple()
|
||||
@@ -504,15 +504,18 @@ def reload_iptv_guide(pvr_dir, addon_id):
|
||||
restart_iptv_simple()
|
||||
|
||||
|
||||
def is_idle(seconds=30):
|
||||
"""Nothing playing and nobody pressed a key for a while. Restarting IPTV
|
||||
Simple stops live TV, and a channel opened while it restarts fails."""
|
||||
def is_idle(seconds=10):
|
||||
"""Nothing playing and nobody pressed a key for a few seconds. Restarting
|
||||
IPTV Simple stops live TV, and a channel opened while it restarts fails.
|
||||
Short on purpose: the reload is most needed right when someone is
|
||||
browsing a TV guide with missing programmes."""
|
||||
import xbmc
|
||||
return not xbmc.Player().isPlaying() and xbmc.getGlobalIdleTime() >= seconds
|
||||
|
||||
|
||||
def wait_until_idle(timeout=None):
|
||||
"""Waits until is_idle(). False if Kodi is closing or the timeout ran out."""
|
||||
"""Waits until is_idle(), by default for as long as Kodi runs. False if
|
||||
Kodi is closing or the timeout ran out."""
|
||||
import xbmc
|
||||
monitor = xbmc.Monitor()
|
||||
end = time.time() + timeout if timeout else None
|
||||
@@ -592,20 +595,43 @@ def has_iptv_instance(pvr_dir, addon_id):
|
||||
return bool(iptv_instance_files(pvr_dir, addon_id))
|
||||
|
||||
|
||||
def remove_duplicate_instances(pvr_dir, addon_id):
|
||||
def _empty_instance_files(pvr_dir):
|
||||
"""Instances with no channel list at all, like the "Migrated Add-on Config"
|
||||
Kodi creates when IPTV Simple is installed again. They show nothing and
|
||||
count as a second PVR instance (see ensure_channel_numbers)."""
|
||||
import glob
|
||||
import re
|
||||
def value(content, setting):
|
||||
match = re.search(r'<setting id="{}"[^>]*?(?:/>|>([^<]*)</setting>)'.format(setting), content)
|
||||
return ((match and match.group(1)) or '').strip()
|
||||
res = []
|
||||
for filename in glob.glob(os.path.join(pvr_dir, 'instance-settings-*.xml')):
|
||||
try:
|
||||
with io.open(filename, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
except (IOError, OSError):
|
||||
continue
|
||||
if not value(content, 'm3uPath') and not value(content, 'm3uUrl'): res.append(filename)
|
||||
return res
|
||||
|
||||
|
||||
def remove_extra_instances(pvr_dir, addon_id):
|
||||
"""Two instances reading the same channel list put every channel twice in
|
||||
the TV guide. That happened when the TV guide setup (instance 91) was run
|
||||
on a box already set up with another instance. Keeps one and deletes the
|
||||
others. Returns True if a file was deleted (IPTV Simple must be restarted
|
||||
to drop it)."""
|
||||
others, and deletes empty instances (no channel list) once this add-on's
|
||||
is there. Returns True if a file was deleted (IPTV Simple must be
|
||||
restarted to drop it)."""
|
||||
ours = iptv_instance_files(pvr_dir, addon_id)
|
||||
if not ours: return False
|
||||
removed = False
|
||||
for filename in iptv_instance_files(pvr_dir, addon_id)[1:]:
|
||||
for filename in ours[1:] + _empty_instance_files(pvr_dir):
|
||||
try:
|
||||
os.remove(filename)
|
||||
LOG('remove_duplicate_instances: removed {}'.format(filename))
|
||||
LOG('remove_extra_instances: removed {}'.format(filename))
|
||||
removed = True
|
||||
except OSError as e:
|
||||
LOG('remove_duplicate_instances: {}: {}'.format(filename, e))
|
||||
LOG('remove_extra_instances: {}: {}'.format(filename, e))
|
||||
return removed
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user