1.0.1: get along with KodiMov+
- Channel numbers: 1.0.0 set "use channel numbers from backend" before "always", which Kodi refuses with more than one PVR instance loaded, and wrote its marker anyway. Now it checks every 5 minutes: if the setting is hidden it turns "always" on, and it turns the setting on once (new marker numbers-on, so existing installs get one proper pass). It never turns anything off, and turning it off by hand afterwards is respected. - Takes turns with KodiMov+ 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
798c08d1b8
commit
333b8ef7ad
3 files changed
+76
-14
No files matched your search
@@ -19,9 +19,21 @@ Renascença, …) are left out on purpose.
|
|||||||
IPTV Simple instance (`instance-settings-95.xml`, or the next free number)
|
IPTV Simple instance (`instance-settings-95.xml`, or the next free number)
|
||||||
that reads `resources/radio.m3u` and `resources/logos/` from the add-on
|
that reads `resources/radio.m3u` and `resources/logos/` from the add-on
|
||||||
folder, and restarts IPTV Simple (only when nothing is playing) if the
|
folder, and restarts IPTV Simple (only when nothing is playing) if the
|
||||||
station list changed. On the first run it turns on *Use channel numbers from
|
station list changed.
|
||||||
backend* + *always*, so the frequencies show as channel numbers and KodiMov+
|
|
||||||
keeps Movistar's TV numbers.
|
## Living with KodiMov+
|
||||||
|
|
||||||
|
Both add-ons keep an instance of IPTV Simple, and share two things in Kodi:
|
||||||
|
|
||||||
|
- **Channel numbers.** Kodi only lets *Use channel numbers from backend* be
|
||||||
|
changed while it applies: with one PVR instance loaded, or with several and
|
||||||
|
*always* on. So which add-on came first changed the result. Both add-ons
|
||||||
|
now check it every few minutes: if the setting is hidden they turn *always*
|
||||||
|
on, and they turn the setting itself on once. Neither ever turns anything
|
||||||
|
off, and once it has been on, turning it off by hand is respected.
|
||||||
|
- **Restarting IPTV Simple** restarts every instance. Each add-on does it only
|
||||||
|
when nothing is playing, and they take turns through a property of Kodi's
|
||||||
|
home window (`pvr.iptvsimple.restarting`).
|
||||||
|
|
||||||
## Programme guide
|
## Programme guide
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<addon id="service.radios.vigo"
|
<addon id="service.radios.vigo"
|
||||||
name="Radios de Vigo"
|
name="Radios de Vigo"
|
||||||
version="1.0.0"
|
version="1.0.1"
|
||||||
provider-name="xocko">
|
provider-name="xocko">
|
||||||
<requires>
|
<requires>
|
||||||
<import addon="xbmc.python" version="3.0.0"/>
|
<import addon="xbmc.python" version="3.0.0"/>
|
||||||
@@ -15,7 +15,8 @@
|
|||||||
<description lang="gl_ES">Engade á sección Radio de Kodi as emisoras do dial FM de Vigo (co número de canal na súa frecuencia, incluídas as portuguesas de Valença) e emisoras de noticias de Reino Unido, Estados Unidos e Portugal. Crea a súa propia instancia de IPTV Simple e mantena ao día cando se actualiza o complemento.</description>
|
<description lang="gl_ES">Engade á sección Radio de Kodi as emisoras do dial FM de Vigo (co número de canal na súa frecuencia, incluídas as portuguesas de Valença) e emisoras de noticias de Reino Unido, Estados Unidos e Portugal. Crea a súa propia instancia de IPTV Simple e mantena ao día cando se actualiza o complemento.</description>
|
||||||
<description lang="es_ES">Añade a la sección Radio de Kodi las emisoras del dial FM de Vigo (con el número de canal en su frecuencia, incluidas las portuguesas de Valença) y emisoras de noticias de Reino Unido, Estados Unidos y Portugal. Crea su propia instancia de IPTV Simple y la mantiene al día cuando se actualiza el complemento.</description>
|
<description lang="es_ES">Añade a la sección Radio de Kodi las emisoras del dial FM de Vigo (con el número de canal en su frecuencia, incluidas las portuguesas de Valença) y emisoras de noticias de Reino Unido, Estados Unidos y Portugal. Crea su propia instancia de IPTV Simple y la mantiene al día cuando se actualiza el complemento.</description>
|
||||||
<description lang="en_GB">Adds the stations on Vigo's FM dial (numbered by frequency, including the Portuguese ones from Valença) and news stations from the UK, US and Portugal to Kodi's Radio section. It creates its own IPTV Simple instance and keeps it up to date when the add-on updates.</description>
|
<description lang="en_GB">Adds the stations on Vigo's FM dial (numbered by frequency, including the Portuguese ones from Valença) and news stations from the UK, US and Portugal to Kodi's Radio section. It creates its own IPTV Simple instance and keeps it up to date when the add-on updates.</description>
|
||||||
<news>1.0.0: first version, 38 Vigo stations and 12 news stations, with a programme guide (updated every 6 hours) for BBC Radio 4, World Service, 5 Live, LBC News, Antena 1-3, RNE, Radio 3, Radio 5, Radio Clásica and WBUR.</news>
|
<news>1.0.1: gets along with KodiMov+: the stations keep their own channel numbers (and the TV channels Movistar's) whichever add-on was installed first, and the two add-ons no longer restart IPTV Simple at the same time.
|
||||||
|
1.0.0: first version, 38 Vigo stations and 12 news stations, with a programme guide (updated every 6 hours) for BBC Radio 4, World Service, 5 Live, LBC News, Antena 1-3, RNE, Radio 3, Radio 5, Radio Clásica and WBUR.</news>
|
||||||
<platform>all</platform>
|
<platform>all</platform>
|
||||||
<license>MIT</license>
|
<license>MIT</license>
|
||||||
<source>https://git.anosanube.ovh/xocko/radios-vigo</source>
|
<source>https://git.anosanube.ovh/xocko/radios-vigo</source>
|
||||||
|
|||||||
+58
-9
@@ -18,6 +18,7 @@ import time
|
|||||||
|
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcaddon
|
import xbmcaddon
|
||||||
|
import xbmcgui
|
||||||
import xbmcvfs
|
import xbmcvfs
|
||||||
|
|
||||||
from resources.lib import epg
|
from resources.lib import epg
|
||||||
@@ -29,6 +30,12 @@ PROFILE = 'special://profile/addon_data/{}/'.format(ADDON_ID)
|
|||||||
FIRST_INSTANCE = 95 # KodiMov+ uses 91 (VAIO) and 93 (.49)
|
FIRST_INSTANCE = 95 # KodiMov+ uses 91 (VAIO) and 93 (.49)
|
||||||
GUIDE_EVERY = 6 * 3600
|
GUIDE_EVERY = 6 * 3600
|
||||||
GUIDE_RETRY = 30 * 60
|
GUIDE_RETRY = 30 * 60
|
||||||
|
NUMBERS_EVERY = 5 * 60
|
||||||
|
# IPTV Simple is shared with KodiMov+ (its instance is the TV 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 other waits. KodiMov+ uses the same name.
|
||||||
|
IPTV_RESTART_PROPERTY = 'pvr.iptvsimple.restarting'
|
||||||
|
|
||||||
SETTINGS = '''<settings version="2">
|
SETTINGS = '''<settings version="2">
|
||||||
<setting id="kodi_addon_instance_name">Radios de Vigo</setting>
|
<setting id="kodi_addon_instance_name">Radios de Vigo</setting>
|
||||||
@@ -92,9 +99,53 @@ def instance_file(pvr_dir):
|
|||||||
|
|
||||||
|
|
||||||
def restart_iptv_simple():
|
def restart_iptv_simple():
|
||||||
|
window = xbmcgui.Window(10000)
|
||||||
|
for _ in range(40): # KodiMov+ 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):
|
for enabled in (False, True):
|
||||||
rpc('Addons.SetAddonEnabled', addonid='pvr.iptvsimple', enabled=enabled)
|
rpc('Addons.SetAddonEnabled', addonid='pvr.iptvsimple', enabled=enabled)
|
||||||
xbmc.sleep(3000)
|
xbmc.sleep(3000)
|
||||||
|
finally:
|
||||||
|
window.clearProperty(IPTV_RESTART_PROPERTY)
|
||||||
|
|
||||||
|
|
||||||
|
def ensure_channel_numbers(marker):
|
||||||
|
"""Makes Kodi show the stations' own numbers (the Vigo ones are their FM
|
||||||
|
frequency) 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. This add-on's instance usually sits next to
|
||||||
|
KodiMov+'s, and which one came first changes what Kodi accepts, so this
|
||||||
|
runs 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 KodiMov+ needs for
|
||||||
|
Movistar's TV numbers. Returns True when Kodi is using the numbers."""
|
||||||
|
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(marker, '')
|
||||||
|
log('turned on backend channel numbers')
|
||||||
|
return value is True
|
||||||
|
|
||||||
|
|
||||||
def update_guide(profile, m3u):
|
def update_guide(profile, m3u):
|
||||||
@@ -132,15 +183,10 @@ def main():
|
|||||||
write(path, SETTINGS)
|
write(path, SETTINGS)
|
||||||
log('wrote ' + path)
|
log('wrote ' + path)
|
||||||
|
|
||||||
numbers_set = os.path.join(profile, 'numbers-set')
|
# "numbers-on", not the "numbers-set" of 1.0.0: that one was written even
|
||||||
if not os.path.exists(numbers_set):
|
# when Kodi had refused the setting
|
||||||
# Show the stations' own numbers (Vigo ones are their FM frequency).
|
numbers_on = os.path.join(profile, 'numbers-on')
|
||||||
# With more than one IPTV Simple instance Kodi ignores them unless
|
next_numbers = time.time() + 30 # IPTV Simple has to be loaded first
|
||||||
# "always" is on too; that also keeps KodiMov+'s TV numbers.
|
|
||||||
for setting in ('pvrmanager.usebackendchannelnumbers', 'pvrmanager.usebackendchannelnumbersalways'):
|
|
||||||
rpc('Settings.SetSettingValue', setting=setting, value=True)
|
|
||||||
write(numbers_set, '')
|
|
||||||
log('turned on backend channel numbers')
|
|
||||||
|
|
||||||
# The guide is fetched in the background so Kodi can always stop this service quickly
|
# The guide is fetched in the background so Kodi can always stop this service quickly
|
||||||
guide_ok = [True]
|
guide_ok = [True]
|
||||||
@@ -171,6 +217,9 @@ def main():
|
|||||||
restart_iptv_simple()
|
restart_iptv_simple()
|
||||||
write(os.path.join(profile, 'state'), state)
|
write(os.path.join(profile, 'state'), state)
|
||||||
restart_pending = False
|
restart_pending = False
|
||||||
|
if time.time() >= next_numbers:
|
||||||
|
next_numbers = time.time() + NUMBERS_EVERY
|
||||||
|
ensure_channel_numbers(numbers_on)
|
||||||
if not job.is_alive():
|
if not job.is_alive():
|
||||||
if not guide_ok[0]:
|
if not guide_ok[0]:
|
||||||
next_guide = min(next_guide, time.time() + GUIDE_RETRY)
|
next_guide = min(next_guide, time.time() + GUIDE_RETRY)
|
||||||
|
|||||||
Reference in new issue
Block a user