Files
kodimovplus/service.py
T
XoséandClaude Fable 5.2 e72e3d4902 1.0.0+kodimov.10: LALIGA, DAZN LALIGA and Liga de Campeones play again
- These 25 channels are missing from the amazon.tv channel list and their
  streams answer 403 to the CDN token of the classic servers. They are now
  taken from the web player's channel list and guide and opened with a CDN
  token from Movistar's new servers (live and catch-up). Stream session and
  licence stay on the classic servers. The other channels are untouched.
- The new servers need a device registered as a web player and the Movistar
  home network: a box registered otherwise gets one extra registration;
  away from the home network the channels are not listed.
- The CDN token is used for its 12 hours and renewed in the background: the
  server that gives it out at times refuses everything for minutes.
- New setting, off by default: always play at the best quality, up to 1080p
  (InputStream Adaptive stays at 576p on these streams when left on automatic).
- Error 4027 is shown only when the retry after registering the device again
  fails too; the first licence request for these channels always gets it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-13 13:17:20 +01:00

66 lines
2.5 KiB
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
import time
import xbmc
import xbmcgui
from resources.lib.proxy import Proxy
from resources.lib.addon import *
from resources.lib.log import LOG
from resources.lib import kodimov
def file_age(filename):
"""Seconds since the file was last written (or found unchanged)."""
try:
return time.time() - os.path.getmtime(filename)
except OSError:
return float('inf')
if __name__ == '__main__':
LOG('Service started')
proxy = Proxy()
proxy.start()
LOG('proxy_address: {}'.format(proxy.proxy_address))
# Refreshes the TV guide channel list (new channels, new numbers) and the
# 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
max_age = 0 # always refresh once after Kodi starts
try:
pvr_dir = translatePath(xbmcaddon.Addon('pvr.iptvsimple').getAddonInfo('profile'))
restart_iptv = kodimov.set_iptv_refresh(pvr_dir, 'kodimovplus')
except RuntimeError: # IPTV Simple not installed or disabled
restart_iptv = False
player = xbmc.Player()
monitor = xbmc.Monitor()
while not monitor.abortRequested():
if monitor.waitForAbort(1):
break
if restart_iptv and not player.isPlaying(): # restarting stops live TV
restart_iptv = False
kodimov.restart_iptv_simple()
if time.time() >= next_check:
next_check = time.time() + 30 * 60
exporting = False
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 addon.getSettingBool('auto_export_epg'): # channels + programme guide
if file_age(os.path.join(profile_dir, 'epg.xml')) > age_limit:
exporting = True
xbmc.executebuiltin('RunPlugin(plugin://plugin.video.kodimovplus/?action=export_epg_now&quiet=1' + reload_guide + ')')
elif addon.getSettingBool('export_channels'):
if file_age(os.path.join(profile_dir, 'channels.m3u8')) > age_limit:
exporting = True
xbmc.executebuiltin('RunPlugin(plugin://plugin.video.kodimovplus/?action=export_channels_now)')
if not exporting:
# Keeps the pass for the LALIGA / Liga de Campeones streams fresh
xbmc.executebuiltin('RunPlugin(plugin://plugin.video.kodimovplus/?action=new_api_keep_warm)')
proxy.stop()