aggiunti test
1. Test di connessione quando l'utente entra nell'addon 2. test per il controllo degli url questo test è stato inserito per testing
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
<import addon="metadata.themoviedb.org"/>
|
||||
<import addon="metadata.tvdb.com"/>
|
||||
<import addon="script.module.web-pdb" />
|
||||
<import addon="script.module.kdicc" />
|
||||
</requires>
|
||||
<extension point="xbmc.python.pluginsource" library="default.py">
|
||||
<provides>video</provides>
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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] == "":
|
||||
|
||||
@@ -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()
|
||||
|
||||
66
specials/checkhost.py
Normal file
66
specials/checkhost.py
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user