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