beta autoupdate addon still disabled
This commit is contained in:
@@ -7,7 +7,7 @@ import os
|
||||
import sys
|
||||
import urllib2
|
||||
import time
|
||||
|
||||
import updater
|
||||
from core import channeltools
|
||||
from core import scrapertools
|
||||
from core import servertools
|
||||
@@ -32,7 +32,6 @@ def start():
|
||||
|
||||
def run(item=None):
|
||||
logger.info()
|
||||
|
||||
if not item:
|
||||
# Extract item from sys.argv
|
||||
if sys.argv[2]:
|
||||
@@ -60,7 +59,7 @@ def run(item=None):
|
||||
from channels import side_menu
|
||||
item= Item()
|
||||
item = side_menu.check_user_home(item)
|
||||
item.start = True;
|
||||
item.start = True
|
||||
else:
|
||||
item = Item(channel="channelselector", action="getmainlist", viewmode="movie")
|
||||
if not config.get_setting('show_once'):
|
||||
@@ -75,6 +74,9 @@ def run(item=None):
|
||||
if item.action == "":
|
||||
logger.info("Item sin accion")
|
||||
return
|
||||
|
||||
if item.action == "update":
|
||||
updater.update()
|
||||
|
||||
# Action for main menu in channelselector
|
||||
elif item.action == "getmainlist":
|
||||
@@ -117,10 +119,9 @@ def run(item=None):
|
||||
|
||||
# Action in certain channel specified in "action" and "channel" parameters
|
||||
else:
|
||||
|
||||
# Entry point for a channel is the "mainlist" action, so here we check parental control
|
||||
if item.action == "mainlist":
|
||||
|
||||
#updater.checkforupdates() beta version checking for update, still disabled
|
||||
|
||||
# Parental control
|
||||
# If it is an adult channel, and user has configured pin, asks for it
|
||||
@@ -128,7 +129,6 @@ def run(item=None):
|
||||
tecleado = platformtools.dialog_input("", config.get_localized_string(60334), True)
|
||||
if tecleado is None or tecleado != config.get_setting("adult_password"):
|
||||
return
|
||||
|
||||
# # Actualiza el canal individual
|
||||
# if (item.action == "mainlist" and item.channel != "channelselector" and
|
||||
# config.get_setting("check_for_channel_updates") == True):
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
# Updater (kodi)
|
||||
# --------------------------------------------------------------------------------
|
||||
|
||||
import os
|
||||
import os, sys
|
||||
import time
|
||||
import threading
|
||||
import traceback
|
||||
import urllib
|
||||
import json
|
||||
import xbmc
|
||||
|
||||
|
||||
from platformcode import config, logger, platformtools
|
||||
|
||||
@@ -16,6 +20,9 @@ from core import downloadtools
|
||||
from core import ziptools
|
||||
from core import filetools
|
||||
|
||||
REMOTE_FILE = "https://github.com/kodiondemand/addon/archive/master.zip"
|
||||
DESTINATION_FOLDER = xbmc.translatePath("special://home/addons") + "/plugin.video.kod"
|
||||
REMOTE_VERSION_FILE = "https://raw.githubusercontent.com/kodiondemand/addon/master/version.json"
|
||||
|
||||
def check_addon_init():
|
||||
logger.info()
|
||||
@@ -68,8 +75,153 @@ def check_addon_init():
|
||||
time.sleep(5) # Dejamos terminar la primera verificación...
|
||||
|
||||
return
|
||||
|
||||
|
||||
def checkforupdates(plugin_mode=True):
|
||||
logger.info("kodiondemand.core.updater checkforupdates")
|
||||
|
||||
response = urllib.urlopen(REMOTE_VERSION_FILE)
|
||||
data = json.loads(response.read())
|
||||
|
||||
'''
|
||||
{
|
||||
"update": {
|
||||
"name": "Kodi on Demand",
|
||||
"tag": "1.0.0",
|
||||
"version": "1000",
|
||||
"date": "03/05/2019",
|
||||
"changes": "Added Updater"
|
||||
}
|
||||
}
|
||||
'''
|
||||
# remote is addon version without dots
|
||||
remote_version = data["update"]["version"]
|
||||
# tag version is version with dots used to a betterview gui
|
||||
tag_version = data["update"]["tag"]
|
||||
logger.info("kodiondemand.core.updater version remota="+tag_version+" "+remote_version)
|
||||
|
||||
'''
|
||||
# Lee el fichero con la versión instalada
|
||||
localFileName = LOCAL_VERSION_FILE
|
||||
logger.info("kodiondemand.core.updater fichero local version: "+localFileName)
|
||||
infile = open( localFileName )
|
||||
data = infile.read()
|
||||
infile.close()
|
||||
#logger.info("xml local="+data)
|
||||
'''
|
||||
path_local = xbmc.translatePath("special://home/addons/") + "plugin.video.kod/version.json"
|
||||
data = json.loads(open(path_local).read())
|
||||
|
||||
version_local = data["update"]["version"]
|
||||
tag_local = data["update"]["tag"]
|
||||
logger.info("kodiondemand.core.updater version local="+tag_local+" "+version_local)
|
||||
|
||||
try:
|
||||
numero_remote_version = int(remote_version)
|
||||
numero_version_local = int(version_local)
|
||||
except:
|
||||
import traceback
|
||||
logger.info(traceback.format_exc())
|
||||
remote_version = ""
|
||||
version_local = ""
|
||||
|
||||
if remote_version=="" or version_local=="":
|
||||
arraydescargada = tag_version.split(".")
|
||||
arraylocal = tag_local.split(".")
|
||||
|
||||
# local 2.8.0 - descargada 2.8.0 -> no descargar
|
||||
# local 2.9.0 - descargada 2.8.0 -> no descargar
|
||||
# local 2.8.0 - descargada 2.9.0 -> descargar
|
||||
if len(arraylocal) == len(arraydescargada):
|
||||
logger.info("caso 1")
|
||||
hayqueactualizar = False
|
||||
for i in range(0, len(arraylocal)):
|
||||
print arraylocal[i], arraydescargada[i], int(arraydescargada[i]) > int(arraylocal[i])
|
||||
if int(arraydescargada[i]) > int(arraylocal[i]):
|
||||
hayqueactualizar = True
|
||||
# local 2.8.0 - descargada 2.8 -> no descargar
|
||||
# local 2.9.0 - descargada 2.8 -> no descargar
|
||||
# local 2.8.0 - descargada 2.9 -> descargar
|
||||
if len(arraylocal) > len(arraydescargada):
|
||||
logger.info("caso 2")
|
||||
hayqueactualizar = False
|
||||
for i in range(0, len(arraydescargada)):
|
||||
#print arraylocal[i], arraydescargada[i], int(arraydescargada[i]) > int(arraylocal[i])
|
||||
if int(arraydescargada[i]) > int(arraylocal[i]):
|
||||
hayqueactualizar = True
|
||||
# local 2.8 - descargada 2.8.8 -> descargar
|
||||
# local 2.9 - descargada 2.8.8 -> no descargar
|
||||
# local 2.10 - descargada 2.9.9 -> no descargar
|
||||
# local 2.5 - descargada 3.0.0
|
||||
if len(arraylocal) < len(arraydescargada):
|
||||
logger.info("caso 3")
|
||||
hayqueactualizar = True
|
||||
for i in range(0, len(arraylocal)):
|
||||
#print arraylocal[i], arraydescargada[i], int(arraylocal[i])>int(arraydescargada[i])
|
||||
if int(arraylocal[i]) > int(arraydescargada[i]):
|
||||
hayqueactualizar = False
|
||||
elif int(arraylocal[i]) < int(arraydescargada[i]):
|
||||
hayqueactualizar = True
|
||||
break
|
||||
else:
|
||||
hayqueactualizar = (numero_remote_version > numero_version_local)
|
||||
|
||||
if hayqueactualizar:
|
||||
|
||||
if plugin_mode:
|
||||
|
||||
logger.info("kodiondemand.core.updater actualizacion disponible")
|
||||
|
||||
# Añade al listado de XBMC
|
||||
import xbmcgui
|
||||
#thumbnail = IMAGES_PATH+"Crystal_Clear_action_info.png"
|
||||
thumbnail = os.path.join(config.get_runtime_path() , "resources" , "images", "service_update.png")
|
||||
logger.info("thumbnail="+thumbnail)
|
||||
listitem = xbmcgui.ListItem( "Scarica la versione "+tag_version, thumbnailImage=thumbnail )
|
||||
itemurl = '%s?action=update&version=%s' % ( sys.argv[ 0 ] , tag_version )
|
||||
import xbmcplugin
|
||||
xbmcplugin.addDirectoryItem( handle = int(sys.argv[ 1 ]), url = itemurl , listitem=listitem, isFolder=True)
|
||||
|
||||
# Avisa con un popup
|
||||
dialog = xbmcgui.Dialog()
|
||||
dialog.ok("Versione "+tag_version+" disponibile","E' possibile scaricare la nuova versione del plugin\nattraverso l'opzione nel menù principale.")
|
||||
|
||||
else:
|
||||
|
||||
import xbmcgui
|
||||
yes_pressed = xbmcgui.Dialog().yesno( "Versione "+tag_version+" disponibile" , "Installarla?" )
|
||||
|
||||
if yes_pressed:
|
||||
params = {"version":tag_version}
|
||||
update(params)
|
||||
|
||||
|
||||
def update():
|
||||
# Descarga el ZIP
|
||||
logger.info("kodiondemand.core.updater update")
|
||||
remotefilename = REMOTE_FILE
|
||||
localfilename = xbmc.translatePath("special://home/addons/") + "plugin.video.kod/addon-master.zip"
|
||||
logger.info("kodiondemand.core.updater remotefilename=%s" % remotefilename)
|
||||
logger.info("kodiondemand.core.updater localfilename=%s" % localfilename)
|
||||
logger.info("kodiondemand.core.updater descarga fichero...")
|
||||
|
||||
#urllib.urlretrieve(remotefilename,localfilename)
|
||||
from core import downloadtools
|
||||
downloadtools.downloadfile(remotefilename, localfilename, continuar=False)
|
||||
|
||||
# Lo descomprime
|
||||
logger.info("kodiondemand.core.updater descomprime fichero...")
|
||||
unzipper = ziptools.ziptools()
|
||||
destpathname = xbmc.translatePath("special://home/addons/") + "plugin.video.kod"
|
||||
logger.info("kodiondemand.core.updater destpathname=%s" % destpathname)
|
||||
unzipper.extract(localfilename,destpathname)
|
||||
|
||||
# Borra el zip descargado
|
||||
logger.info("kodiondemand.core.updater borra fichero...")
|
||||
os.remove(localfilename)
|
||||
logger.info("kodiondemand.core.updater ...fichero borrado")
|
||||
|
||||
|
||||
'''
|
||||
def check_addon_updates(verbose=False):
|
||||
logger.info()
|
||||
|
||||
@@ -158,3 +310,4 @@ def check_addon_updates(verbose=False):
|
||||
if verbose:
|
||||
platformtools.dialog_notification(config.get_localized_string(70674), config.get_localized_string(70675))
|
||||
return False
|
||||
'''
|
||||
Reference in New Issue
Block a user