1.0.0+kodimov.8: guide refresh doesn't fail at random; retry after 30 min

datetime.strptime sometimes fails in Kodi's embedded Python ('NoneType'
object is not callable), which aborted the whole guide export. Build the
XMLTV times without it.

The service now checks every 30 minutes and refreshes when the files are
over 6 hours old, so a failed refresh is retried soon. write_if_changed
touches an unchanged file so its time means "last refreshed".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
XoséandClaude Opus 5.5 committed 2026-11-10 08:36:21 +01:00
1 parent 9faaa482fc
commit 5df60a1fb8
4 files changed
+27 -31

No files matched your search

+3 -1
View File
@@ -200,7 +200,9 @@ def extra_channels_m3u8():
def write_if_changed(filename, content):
try:
with io.open(filename, 'r', encoding='utf-8', newline='') as f:
if f.read() == content: return False
if f.read() == content:
os.utime(filename, None) # the service reads the time as "last refreshed"
return False
except (IOError, OSError):
pass
tmp = filename + '.tmp'
+3 -2
View File
@@ -1533,8 +1533,9 @@ class Movistar(object):
if only_subscribed and not ch['subscribed']: continue
for e in epg[ch['id']]:
#LOG('* e:{}'.format(e))
start = datetime.strptime(e['start'], "%Y-%m-%dT%H:%M:%SZ").strftime("%Y%m%d%H%M%S +0000")
stop = datetime.strptime(e['stop'], "%Y-%m-%dT%H:%M:%SZ").strftime("%Y%m%d%H%M%S +0000")
# 2026-11-10T08:00:00Z -> 20261110080000 +0000, without strptime: inside
# Kodi it fails at random ("'NoneType' object is not callable")
start, stop = [re.sub(r'\D', '', e[k]) + ' +0000' for k in ('start', 'stop')]
url = e.get('stream', None)
if url:
url = url.replace('&', '&amp;')