1.0.0+kodimov.11: Movistar's channel numbers with more than one IPTV Simple instance
- Kodi only lets "use channel numbers from backend" be read or changed while it applies: one PVR instance loaded, or several and "always" on. With a second instance (Radios de Vigo, a leftover empty one) it refused the setting the TV guide setup made, and numbered the channels 1, 2, 3... - The service now checks it every 30 minutes and after the setup: if the setting is hidden it turns "always" on, and it turns the setting on once (marker file numbers-set). It never turns anything off, and turning it off by hand afterwards is respected. Existing setups are put right this way. - KodiMov+ and Radios de Vigo take turns to restart IPTV Simple, through the pvr.iptvsimple.restarting property of Kodi's home window. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
e72e3d4902
commit
b3bc561c35
5 files changed
+88
-9
No files matched your search
@@ -494,13 +494,81 @@ def reload_iptv_guide(pvr_dir, addon_id):
|
||||
restart_iptv_simple()
|
||||
|
||||
|
||||
# IPTV Simple is shared with other add-ons (Radios de Vigo keeps its own
|
||||
# instance for the Radio section). Restarting it restarts every instance, so
|
||||
# the add-ons take turns: whoever restarts it says so in this property of
|
||||
# Kodi's home window (the time it started), and the others wait.
|
||||
IPTV_RESTART_PROPERTY = 'pvr.iptvsimple.restarting'
|
||||
|
||||
|
||||
def restart_iptv_simple():
|
||||
"""Restarts IPTV Simple so it loads its instance settings again."""
|
||||
import xbmc
|
||||
for enabled in (False, True):
|
||||
xbmc.executeJSONRPC(json.dumps({'jsonrpc': '2.0', 'id': 1, 'method': 'Addons.SetAddonEnabled',
|
||||
'params': {'addonid': 'pvr.iptvsimple', 'enabled': enabled}}))
|
||||
xbmc.sleep(3000)
|
||||
import xbmcgui
|
||||
window = xbmcgui.Window(10000)
|
||||
for _ in range(40): # another add-on is restarting it: wait (a turn older than 20 s is stale)
|
||||
try:
|
||||
busy = 0 <= time.time() - float(window.getProperty(IPTV_RESTART_PROPERTY) or 0) < 20
|
||||
except ValueError:
|
||||
busy = False
|
||||
if not busy: break
|
||||
xbmc.sleep(1000)
|
||||
window.setProperty(IPTV_RESTART_PROPERTY, str(time.time()))
|
||||
try:
|
||||
for enabled in (False, True):
|
||||
xbmc.executeJSONRPC(json.dumps({'jsonrpc': '2.0', 'id': 1, 'method': 'Addons.SetAddonEnabled',
|
||||
'params': {'addonid': 'pvr.iptvsimple', 'enabled': enabled}}))
|
||||
xbmc.sleep(3000)
|
||||
finally:
|
||||
window.clearProperty(IPTV_RESTART_PROPERTY)
|
||||
|
||||
|
||||
def has_iptv_instance(pvr_dir, addon_id):
|
||||
"""True if an IPTV Simple instance reads this add-on's channel list."""
|
||||
import glob
|
||||
for filename in glob.glob(os.path.join(pvr_dir, 'instance-settings-*.xml')):
|
||||
try:
|
||||
with io.open(filename, 'r', encoding='utf-8') as f:
|
||||
if 'plugin.video.{}/channels.m3u8'.format(addon_id) in f.read(): return True
|
||||
except (IOError, OSError):
|
||||
pass
|
||||
return False
|
||||
|
||||
|
||||
def ensure_channel_numbers(marker):
|
||||
"""Makes Kodi show the channel numbers of the list (Movistar's dial
|
||||
numbers) instead of 1, 2, 3...
|
||||
|
||||
Kodi only lets "use channel numbers from backend" be read or changed while
|
||||
it applies: with exactly one PVR instance loaded, or with several and the
|
||||
"always" setting on. Radios de Vigo adds an instance of IPTV Simple and
|
||||
some boxes carry a leftover empty one, so the setting can stop applying
|
||||
after it was turned on. This is called now and then and puts it right:
|
||||
- hidden: turns "always" on, which brings the stored value back;
|
||||
- off and never turned on by this add-on (no marker file): turns it on;
|
||||
- off after this add-on turned it on once: the user's choice, left alone.
|
||||
It never turns anything off, so it can't undo what Radios de Vigo needs.
|
||||
Returns True when Kodi is using the numbers of the list."""
|
||||
import xbmc
|
||||
def rpc(method, **params):
|
||||
try:
|
||||
return json.loads(xbmc.executeJSONRPC(json.dumps({'jsonrpc': '2.0', 'id': 1, 'method': method, 'params': params})))
|
||||
except ValueError:
|
||||
return {}
|
||||
def numbers():
|
||||
return (rpc('Settings.GetSettingValue', setting='pvrmanager.usebackendchannelnumbers').get('result') or {}).get('value')
|
||||
value = numbers()
|
||||
if value is None:
|
||||
rpc('Settings.SetSettingValue', setting='pvrmanager.usebackendchannelnumbersalways', value=True)
|
||||
value = numbers()
|
||||
if value is None: return False # IPTV Simple isn't loaded right now: try later
|
||||
if value is False and not os.path.exists(marker):
|
||||
rpc('Settings.SetSettingValue', setting='pvrmanager.usebackendchannelnumbers', value=True)
|
||||
value = numbers()
|
||||
if value is True and not os.path.exists(marker):
|
||||
write_if_changed(marker, '1')
|
||||
LOG('ensure_channel_numbers: on')
|
||||
return value is True
|
||||
|
||||
|
||||
def extra_channels_xmltv(session):
|
||||
|
||||
Reference in new issue
Block a user