migliorie updater
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
from threading import Thread
|
||||
|
||||
import xbmc
|
||||
from platformcode import config, logger
|
||||
@@ -17,7 +16,7 @@ sys.path.insert(0, librerias)
|
||||
|
||||
if not config.dev_mode():
|
||||
from platformcode import updater
|
||||
Thread(target=updater.timer())
|
||||
updater.showSavedChangelog()
|
||||
|
||||
from platformcode import launcher
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ repo = 'addon'
|
||||
addonDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))).replace('\\', '/') + '/'
|
||||
maxPage = 5 # le api restituiscono 30 commit per volta, quindi se si è rimasti troppo indietro c'è bisogno di andare avanti con le pagine
|
||||
trackingFile = "last_commit.txt"
|
||||
changelogFile = "special://profile/addon_data/plugin.video.kod/changelog.txt"
|
||||
|
||||
|
||||
def loadCommits(page=1):
|
||||
@@ -46,7 +47,7 @@ def loadCommits(page=1):
|
||||
return ret
|
||||
|
||||
|
||||
def check():
|
||||
def check(background=False):
|
||||
if not addon.getSetting('addon_update_enabled'):
|
||||
return False
|
||||
logger.info('Cerco aggiornamenti..')
|
||||
@@ -155,7 +156,11 @@ def check():
|
||||
changelog += commitJson['commit']['message'] + "\n"
|
||||
nCommitApplied += 1
|
||||
if addon.getSetting("addon_update_message"):
|
||||
platformtools.dialog_ok('Kodi on Demand', 'Aggiornamenti applicati:\n' + changelog)
|
||||
if background:
|
||||
with open(xbmc.translatePath(changelogFile), 'a+') as fileC:
|
||||
fileC.write(changelog)
|
||||
else:
|
||||
platformtools.dialog_ok('Kodi on Demand', 'Aggiornamenti applicati:\n' + changelog)
|
||||
|
||||
localCommitFile.seek(0)
|
||||
localCommitFile.truncate()
|
||||
@@ -171,33 +176,14 @@ def check():
|
||||
return updated
|
||||
|
||||
|
||||
def timer(force=False):
|
||||
import time
|
||||
curTime = time.time()
|
||||
file = "special://profile/addon_data/plugin.video.kod/updater_last_check.txt"
|
||||
period = float(addon.getSetting('addon_update_timer')) * 3600
|
||||
updated = False
|
||||
|
||||
if force:
|
||||
updated = check()
|
||||
checked = True
|
||||
else:
|
||||
checked = False
|
||||
try:
|
||||
with open(xbmc.translatePath(file), 'r') as fileC:
|
||||
lastCheck = float(fileC.read())
|
||||
if curTime - lastCheck > period:
|
||||
updated = check()
|
||||
checked = True
|
||||
except:
|
||||
updated = check()
|
||||
checked = True
|
||||
if checked:
|
||||
with open(xbmc.translatePath(file), 'w') as fileC:
|
||||
fileC.write(str(curTime))
|
||||
return updated
|
||||
|
||||
|
||||
def showSavedChangelog():
|
||||
try:
|
||||
with open(xbmc.translatePath(changelogFile), 'r') as fileC:
|
||||
changelog = fileC.read()
|
||||
platformtools.dialog_ok('Kodi on Demand', 'Aggiornamenti applicati:\n' + changelog)
|
||||
filetools.remove(xbmc.translatePath(changelogFile))
|
||||
except:
|
||||
pass
|
||||
|
||||
def calcCurrHash():
|
||||
treeHash = githash.tree_hash(addonDir).hexdigest()
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
<setting label="70579" type="lsep"/>
|
||||
<setting id="addon_update_enabled" type="bool" label="70581" default="true"/>
|
||||
<setting id="addon_update_message" type="bool" label="70582" default="true"/>
|
||||
<setting id="addon_update_timer" type="labelenum" values="0.5|1|2|4|8|24" label="707416" default="1"/>
|
||||
<setting id="addon_update_timer" type="labelenum" values="1|2|4|8|24" label="707416" default="1"/>
|
||||
|
||||
<setting label="Lista activa" type="text" id="lista_activa" default="kodfavorites-default.json" visible="false"/>
|
||||
|
||||
|
||||
@@ -343,7 +343,7 @@ def check_quickfixes(item):
|
||||
|
||||
if not config.dev_mode():
|
||||
from platformcode import updater
|
||||
if not updater.timer(True):
|
||||
if not updater.check():
|
||||
platformtools.dialog_ok('Kodi on Demand', config.get_localized_string(70667))
|
||||
else:
|
||||
return False
|
||||
|
||||
@@ -22,6 +22,7 @@ from core import channeltools, filetools, videolibrarytools
|
||||
from platformcode import logger
|
||||
from platformcode import platformtools
|
||||
from specials import videolibrary
|
||||
from platformcode import updater
|
||||
|
||||
|
||||
def update(path, p_dialog, i, t, serie, overwrite):
|
||||
@@ -306,6 +307,15 @@ def monitor_update():
|
||||
logger.info("Inicio actualizacion programada para las %s h.: %s" % (update_start, datetime.datetime.now()))
|
||||
check_for_update(overwrite=False)
|
||||
|
||||
if not config.dev_mode():
|
||||
period = float(config.get_setting('addon_update_timer')) * 3600
|
||||
curTime = time.time()
|
||||
lastCheck = float(config.get_setting("updater_last_check", "videolibrary", '0'))
|
||||
|
||||
if curTime - lastCheck > period:
|
||||
updater.check(background=True)
|
||||
config.set_setting("updater_last_check", "videolibrary", str(curTime))
|
||||
|
||||
# def get_channel_json():
|
||||
# import urllib, os, xbmc
|
||||
# addon = config.get_addon_core()
|
||||
@@ -377,8 +387,7 @@ if __name__ == "__main__":
|
||||
|
||||
# Verificar quick-fixes al abrirse Kodi, y dejarlo corriendo como Thread
|
||||
if not config.dev_mode():
|
||||
from platformcode import updater
|
||||
updater.timer(True)
|
||||
updater.check()
|
||||
|
||||
# Copia Custom code a las carpetas de Alfa desde la zona de Userdata
|
||||
from platformcode import custom_code
|
||||
|
||||
Reference in New Issue
Block a user