diff --git a/addon.xml b/addon.xml index 3542d0df..88ad8837 100644 --- a/addon.xml +++ b/addon.xml @@ -6,6 +6,7 @@ + video diff --git a/channelselector.py b/channelselector.py index 7cee396a..007d8e56 100644 --- a/channelselector.py +++ b/channelselector.py @@ -16,6 +16,16 @@ def getmainlist(view="thumb_"): logger.info() itemlist = list() + ################################################################ + ################################################################ + # Questa voce è per TESTING e NON DOVRà MAI andare in stable + itemlist.append(Item(title="KDICC", channel="checkhost", action="check", + thumbnail='', + category=config.get_localized_string(30119), viewmode="thumbnails", + context=[{"title": config.get_localized_string(70285), "channel": "checkhost", "action": "menu_opciones", + "goto": True}])) + ################################################################ + ################################################################ # Añade los canales que forman el menú principal if addon.getSetting('enable_news_menu') == "true": itemlist.append(Item(title=config.get_localized_string(30130), channel="news", action="mainlist", diff --git a/default.py b/default.py index 26a058fd..f4508aab 100644 --- a/default.py +++ b/default.py @@ -10,6 +10,7 @@ import sys import xbmc from platformcode import config, logger + logger.info("init...") if os.path.isfile(os.path.join(config.get_data_path(), 'alfavorites-default.json')) == True and os.path.isfile(os.path.join(config.get_data_path(), 'kodfavorites-default.json')) == False: os.rename(os.path.join(config.get_data_path(), 'alfavorites-default.json'), os.path.join(config.get_data_path(), 'kodfavorites-default.json')) @@ -19,6 +20,7 @@ if os.path.isfile(os.path.join(config.get_data_path(), 'alfa_db.sqlite')) == Tru librerias = xbmc.translatePath(os.path.join(config.get_runtime_path(), 'lib')) sys.path.append(librerias) + from platformcode import launcher if sys.argv[2] == "": diff --git a/platformcode/launcher.py b/platformcode/launcher.py index 1c374009..bbf9f87f 100644 --- a/platformcode/launcher.py +++ b/platformcode/launcher.py @@ -30,6 +30,13 @@ def start(): # Test if all the required directories are created config.verify_directories_created() + # controlla se l'utente ha qualche problema di connessione + # se lo ha, non lo fa entrare nell'addon e visualizza un messaggio + # se tutto ok, entra nell'addon + from kdicc import test_conn + test_conn(is_exit = True, check_dns = True, view_msg = True, + lst_urls = [], lst_site_check_dns = [], in_addon = True) + def run(item=None): logger.info() diff --git a/specials/checkhost.py b/specials/checkhost.py new file mode 100644 index 00000000..49b5d277 --- /dev/null +++ b/specials/checkhost.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- +""" + leggo gli host dei canali dal file channels.json + li controllo + scrivo il file channels-test.json + con i codici di errore e i nuovi url in caso di redirect + + gli url DEVONO avere http(s) + + Durante il controllo degli url vengono rieffettuati + i controlli di ip, asdl e dns. + Questo perchè può succedere che in un qualsiasi momento + la connessione può avere problemi. + Nel caso succeda il controllo e relativa scrittura del file viene interrotto + con messaggio di avvertimento + +""" +import xbmc +import xbmcaddon +import json +from platformcode import logger +from kdicc import test_conn + + +def check(item): + logger.info() + + folderJson = xbmc.translatePath(xbmcaddon.Addon().getAddonInfo('path')).decode('utf-8') + fileJson = 'channels.json' + + with open(folderJson+'/'+fileJson) as f: + data = json.load(f) +## logger.info("DATA :%s" % data) + + risultato = {} + + for chann, host in sorted(data.items()): + ris = [] + logger.info("channel - host :%s - %s " % (chann, host)) + + lst_host = [] + lst_host.append(host) + + rslt = test_conn(is_exit = True, check_dns = False, view_msg = True, + lst_urls = lst_host, lst_site_check_dns = [], in_addon = True) + + logger.info("checkhost rslt :%s " % (rslt)) + rslt = rslt[0] + # tutto ok + if rslt['code'] == 200 and rslt['isRedirect'] == False: + risultato[chann] = host + # redirect + elif rslt['code'] == 200 and rslt['isRedirect'] == True: + risultato[chann] = str(rslt['code']) +' - '+ rslt['rdrcturl'] + # sito inesistente + elif rslt['code'] == -2: + risultato[chann] = 'Host Sconosciuto - '+ str(rslt['code']) +' - '+ host + else: + # altri tipi di errore + risultato[chann] = str(rslt['code']) +' - '+ host + + fileJson_test = 'channels-test.json' + # scrivo il file aggiornato + with open(folderJson+'/'+fileJson_test, 'w') as f: + data = json.dump(risultato, f, sort_keys=True, indent=4) + logger.info(data)