KoD 0.5.1

-override DNS di default
-nuovi canali: streamtime e netfreex
-fixato cloudflare
-aggiunta opzione apri nel browser
This commit is contained in:
marco
2019-11-30 20:27:09 +01:00
parent 4332859f47
commit daad0d3ddb
176 changed files with 31086 additions and 13812 deletions
+28 -31
View File
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import xbmc, xbmcgui
import xbmcaddon
import json
@@ -12,13 +13,12 @@ addon = xbmcaddon.Addon()
addonname = addon.getAddonInfo('name')
addonid = addon.getAddonInfo('id')
LIST_SITE = ['https://www.google.com', 'https://www.google.it',
'http://www.ansa.it/']#, 'https://www.debian.org/']
LIST_SITE = ['https://www.google.com', 'https://www.google.it', 'http://www.ansa.it/']
# lista di siti che non verranno raggiunti con i DNS del gestore
LST_SITE_CHCK_DNS = ['https://www.italia-film.pw', 'https://casacinema.space',
'https://documentari-streaming-da.com']
LST_SITE_CHCK_DNS = ['https://casacinema.space', 'https://www.cb01.uno/']
#'https://www.italia-film.pw', 'https://documentari-streaming-da.com',] # tolti
class Kdicc():
@@ -34,18 +34,13 @@ class Kdicc():
self.view_msg = view_msg
self.lst_site_check_dns = lst_site_check_dns
self.urls = []
## self.in_addon = in_addon
## self.server_dns = xbmc.getInfoLabel('Network.DHCPAddress') # stringa vuota...
## self.gateway = xbmc.getInfoLabel('Network.GatewayAddress')
## self.subnet = xbmc.getInfoLabel('Network.SubnetMask')
def check_Ip(self):
"""
controllo l'ip
se ip_addr = 127.0.0.1 o ip_addr = '' allora il device non
e' connesso al modem/router
check the ip
if ip_addr = 127.0.0.1 or ip_addr = '' then the device does not
is connected to the modem/router
@@ -168,7 +163,7 @@ class Kdicc():
rslt['redirect'] = code.previous['-x-permanent-redirect-url']
rslt['status'] = code.status
else:
rslt['code'] = code.status
rslt['code'] = code.status
except httplib2.ServerNotFoundError as msg:
# sia per mancanza di ADSL che per i siti non esistenti
rslt['code'] = -2
@@ -192,18 +187,21 @@ class Kdicc():
else:
txt += '\nIP: %s' % self.ip_addr
## if self.in_addon == False and self.view_msg == True:
dialog = xbmcgui.Dialog()
dialog.textviewer(addonname, txt)
if config.get_setting('checkdns'):
risposta= dialog.yesno(addonname, txt, nolabel='Disattiva', yeslabel='Ricordami')
if risposta == False:
config.set_setting('checkdns', False)
dialog.textviewer(addonname+ ' '+config.get_localized_string(707403), config.get_localized_string(707404))
else:
txt = config.get_localized_string(707402)
dialog.notification(addonname, txt, xbmcgui.NOTIFICATION_INFO, 5000)
"""
def richiamato in launcher.py
"""
def test_conn(is_exit, check_dns, view_msg,
lst_urls, lst_site_check_dns, in_addon):
# debug
# import web_pdb; web_pdb.set_trace()
ktest = Kdicc(is_exit, check_dns, view_msg, lst_urls, lst_site_check_dns, in_addon)
# se non ha l'ip lo comunico all'utente
if not ktest.check_Ip():
@@ -214,7 +212,7 @@ def test_conn(is_exit, check_dns, view_msg,
ktest.view_Advise(config.get_localized_string(70720))
if ktest.is_exit == True:
exit()
# se non ha connessione ADSL lo comunico all'utente
# se non ha connessione ADSL lo comunico all'utente
elif not ktest.check_Adsl():
if view_msg == True:
ktest.view_Advise(config.get_localized_string(70721))
@@ -227,8 +225,8 @@ def test_conn(is_exit, check_dns, view_msg,
ktest.view_Advise(config.get_localized_string(70722))
xbmc.log("############ Inizio Check DNS ############", level=xbmc.LOGNOTICE)
xbmc.log("IP: %s" % (ktest.ip_addr), level=xbmc.LOGNOTICE)
xbmc.log("DNS: %s" % (ktest.dns), level=xbmc.LOGNOTICE)
xbmc.log("## IP: %s" % (ktest.ip_addr), level=xbmc.LOGNOTICE)
xbmc.log("## DNS: %s" % (ktest.dns), level=xbmc.LOGNOTICE)
xbmc.log("############ Fine Check DNS ############", level=xbmc.LOGNOTICE)
if ktest.check_Ip() and ktest.check_Adsl() and ktest.check_Dns():
return True
@@ -241,30 +239,28 @@ def check_channels(inutile=''):
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
con il codice di errore e il nuovio url in caso di redirect
gli url DEVONO avere http(s)
Durante il controllo degli url vengono rieffettuati
Durante il controllo degli urls vengono rieffettuati
i controlli di ip, asdl e dns.
Questo perchè può succedere che in un qualsiasi momento
la connessione p avere problemi.
Nel caso accada un problema, il controllo e relativa scrittura del file viene interrotto
con messaggio di avvertimento
"""
la connessione possa avere problemi. Nel caso accada, il controllo e
relativa scrittura del file viene interrotto con messaggio di avvertimento
"""
logger.info()
folderJson = xbmc.translatePath(xbmcaddon.Addon().getAddonInfo('path')).decode('utf-8')
fileJson = 'channels.json'
fileJson = 'channels.json'
with open(folderJson+'/'+fileJson) as f:
data = json.load(f)
risultato = {}
for chann, host in sorted(data.items()):
ris = []
# per avere un'idea della tempistica
# utile solo se si controllano tutti i canali
@@ -294,13 +290,14 @@ def check_channels(inutile=''):
risultato[chann] = host
logger.info("check #### FINE #### rslt :%s " % (rslt))
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)
# per il futuro
# codice per l'invio del file su git!!!
# 1. Bottone OKNO richiesta se vuole inviare file
+100 -95
View File
@@ -66,7 +66,6 @@ def show_channels(item):
if file_path.startswith('http'): file_url = httptools.downloadpage(file_path, follow_redirects=True).data
elif os.path.isfile(file_path): file_url = open(file_path, "r").read()
else:
support.log('KEY=',key)
item.channel_id = key
remove_channel(item)
file_url=''
@@ -81,15 +80,15 @@ def show_channels(item):
plot = json_url['plot'] if json_url.has_key('plot') else ''
itemlist.append(Item(channel=item.channel,
title=typo(channel['channel_name'],'bold'),
url=file_path,
thumbnail=thumbnail,
fanart=fanart,
plot=plot,
action='show_menu',
channel_id = key,
context=context,
path=path))
title=typo(channel['channel_name'],'bold'),
url=file_path,
thumbnail=thumbnail,
fanart=fanart,
plot=plot,
action='show_menu',
channel_id = key,
context=context,
path=path))
autoplay.show_option(item.channel, itemlist)
support.channel_config(item, itemlist)
@@ -119,21 +118,21 @@ def show_menu(item):
plot = ''
itemlist.append(Item(channel=item.channel,
title=typo(title,'submenu' if not url else 'bold'),
url=url if url else item.url,
path=item.path,
thumbnail=thumbnail,
plot=plot,
action='submenu' if not url else 'show_menu',
filterkey=key if not url else '' ))
title=typo(title,'submenu' if not url else 'bold'),
url=url if url else item.url,
path=item.path,
thumbnail=thumbnail,
plot=plot,
action='submenu' if not url else 'show_menu',
filterkey=key if not url else '' ))
if menu.has_key('search'):
itemlist.append(Item(channel=item.channel,
title=typo('Cerca ' + item.fulltitle +'...','color kod bold'),
thumbnail=get_thumb('search.png'),
action='search',
url=item.url,
path=item.path))
title=typo('Cerca ' + item.fulltitle +'...','color kod bold'),
thumbnail=get_thumb('search.png'),
action='search',
url=item.url,
path=item.path))
return itemlist
else:
@@ -148,15 +147,15 @@ def show_menu(item):
submenu = option['submenu'] if option.has_key('submenu') else []
level2 = option['level2'] if option.has_key('level2') else []
itemlist.append(Item(channel=item.channel,
title=format_title(option['title']),
fulltitle=option['title'],
thumbnail=thumbnail,
fanart=fanart,
plot=plot,
action='show_menu',
url=url,
path=item.path,
menu=level2))
title=format_title(option['title']),
fulltitle=option['title'],
thumbnail=thumbnail,
fanart=fanart,
plot=plot,
action='show_menu',
url=url,
path=item.path,
menu=level2))
if submenu:
for key in submenu:
@@ -169,22 +168,21 @@ def show_menu(item):
title = submenu[key]
thumbnail = item.thumbnail
plot = ''
itemlist.append(Item(channel=item.channel,
title=typo(title,'submenu'),
url=url,
path=item.path,
thumbnail=thumbnail,
plot=plot,
action='submenu',
filterkey=key))
title=typo(title,'submenu'),
url=url,
path=item.path,
thumbnail=thumbnail,
plot=plot,
action='submenu',
filterkey=key))
if submenu.has_key('search'):
itemlist.append(Item(channel=item.channel,
title=typo('Cerca ' + option['title'] +'...','color kod bold'),
thumbnail=get_thumb('search.png'),
action='search',
url=url,
path=item.path))
title=typo('Cerca ' + option['title'] +'...','color kod bold'),
thumbnail=get_thumb('search.png'),
action='search',
url=url,
path=item.path))
elif 'list' in key:
# select type of list
@@ -205,7 +203,7 @@ def show_menu(item):
elif key == "generic_list":
item.media_type= 'generic_list'
itemlist += list_all(item)
# add Search
if 'channel_name' in json_data:
itemlist.append(Item(channel=item.channel,
@@ -233,7 +231,7 @@ def submenu(item):
media_type = item.media_type
for media in json_data[media_type]:
if media.has_key(item.filterkey):
if media.has_key(item.filterkey) and media[item.filterkey]:
if type(media[item.filterkey]) == str and media[item.filterkey] not in filter_list:
filter_list.append(media[item.filterkey])
elif type(media[item.filterkey]) == list:
@@ -241,6 +239,7 @@ def submenu(item):
if f not in filter_list:
filter_list.append(f)
filter_list.sort()
support.log(filter_list)
for filter in filter_list:
thumbnail = ''
@@ -262,14 +261,14 @@ def submenu(item):
action='list_filtered',
thumbnail=thumbnail,
plot=plot,
path=item.path,
filterkey=item.filterkey,
filter=filter))
return itemlist
def list_all(item):
support.log('CONTENT TYPE ', item.contentType)
support.log()
if inspect.stack()[1][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes']:
pagination = int(defp) if defp.isdigit() else ''
else: pagination = ''
@@ -333,15 +332,16 @@ def list_all(item):
if inspect.stack()[1][3] != 'get_newest':
itemlist.append(
Item(channel=item.channel,
action = item.action,
contentType=contentType,
title=typo(config.get_localized_string(30992), 'color kod bold'),
fulltitle= item.fulltitle,
show= item.show,
url=item.url,
args=item.args,
page=pag + 1,
thumbnail=support.thumb()))
action = item.action,
contentType=contentType,
title=typo(config.get_localized_string(30992), 'color kod bold'),
fulltitle= item.fulltitle,
show= item.show,
url=item.url,
args=item.args,
page=pag + 1,
path=item.path,
thumbnail=support.thumb()))
if not 'generic_list' in json_data:
tmdb.set_infoLabels(itemlist, seekTmdb=True)
@@ -398,35 +398,36 @@ def list_filtered(item):
action = 'episodios'
itemlist.append(Item(channel=item.channel,
contentType=contentType,
title=format_title(title),
fulltitle=fulltitle,
show=fulltitle,
quality=quality,
language=language,
plot=plot,
personal_plot=plot,
thumbnail=poster,
path=item.path,
url=url,
contentTitle=contentTitle,
contentSerieName=contentSerieName,
infoLabels=infoLabels,
action=action))
contentType=contentType,
title=format_title(title),
fulltitle=fulltitle,
show=fulltitle,
quality=quality,
language=language,
plot=plot,
personal_plot=plot,
thumbnail=poster,
path=item.path,
url=url,
contentTitle=contentTitle,
contentSerieName=contentSerieName,
infoLabels=infoLabels,
action=action))
if pagination and len(json_data[media_type]) >= pag * pagination and len(itemlist) >= pag * pagination:
if inspect.stack()[1][3] != 'get_newest':
itemlist.append(
Item(channel=item.channel,
action = item.action,
contentType=contentType,
title=typo(config.get_localized_string(30992), 'color kod bold'),
fulltitle= item.fulltitle,
show= item.show,
url=item.url,
args=item.args,
page=pag + 1,
thumbnail=support.thumb()))
action = item.action,
contentType=contentType,
title=typo(config.get_localized_string(30992), 'color kod bold'),
fulltitle= item.fulltitle,
show= item.show,
url=item.url,
args=item.args,
page=pag + 1,
path=item.path,
thumbnail=support.thumb()))
if not 'generic_list' in json_data:
tmdb.set_infoLabels(itemlist, seekTmdb=True)
@@ -457,7 +458,8 @@ def get_seasons(item):
action='episodios',
contentSeason=season['season'],
infoLabels=infoLabels,
contentType='tvshow'))
contentType='tvshow',
path=item.path))
if inspect.stack()[1][3] in ['add_tvshow', "get_seasons"] or show_seasons == False:
@@ -539,17 +541,18 @@ def episodios(item):
title = '%sx%s%s' % (season_number, episode_number, title)
if season_number == item.filter or not item.filterseason:
itemlist.append(Item(channel= item.channel,
title= format_title(title),
fulltitle = item.fulltitle,
show = item.show,
url= episode,
action= 'findvideos',
plot= plot,
thumbnail= thumbnail,
contentSeason= season_number,
contentEpisode= episode_number,
infoLabels= infoLabels,
contentType= 'episode'))
title= format_title(title),
fulltitle = item.fulltitle,
show = item.show,
url= episode,
action= 'findvideos',
plot= plot,
thumbnail= thumbnail,
contentSeason= season_number,
contentEpisode= episode_number,
infoLabels= infoLabels,
contentType= 'episode',
path=item.path))
if show_seasons == True and inspect.stack()[1][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes'] and not item.filterseason:
@@ -569,7 +572,8 @@ def episodios(item):
action='episodios',
contentSeason=season,
infoLabels=infoLabels,
filterseason=season))
filterseason=season,
path=item.path))
elif pagination and len(json_data['episodes_list']) >= pag * pagination:
if inspect.stack()[1][3] != 'get_newest':
@@ -583,7 +587,8 @@ def episodios(item):
url=item.url,
args=item.args,
page=pag + 1,
thumbnail=support.thumb()))
thumbnail=support.thumb(),
path=item.path))
tmdb.set_infoLabels(itemlist, seekTmdb=True)
return itemlist
+31
View File
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# -*- CLOUDFLARE'S DNS -*-
##from lib import dns
##import dns.resolver
##from dns.resolver import override_system_resolver
##import socket
##import requests
##
##def dns_resolver():
## res = dns.resolver.Resolver(configure=True)
## res.nameservers = ['1.1.1.1', '2606:4700:4700::1111',
## '1.0.0.1', '2606:4700:4700::1001']
## override_system_resolver(res)
## Da prevedere di aggiungere la possibilità
## di inserire i dns a piacere degli utenti!!!
from lib import dns
import dns.resolver
from dns.resolver import override_system_resolver
import dns.name
import socket
import requests
res = dns.resolver.Resolver(configure=True)
res.nameservers = ['1.1.1.1', '2606:4700:4700::1111',
'1.0.0.1', '2606:4700:4700::1001' ]
override_system_resolver(res)
+19 -13
View File
@@ -400,16 +400,17 @@ def show_result(item):
if item.__dict__.has_key('tecleado'):
tecleado = item.__dict__.pop('tecleado')
try:
channel = __import__('channels.%s' % item.channel, fromlist=["channels.%s" % item.channel])
except:
import traceback
logger.error(traceback.format_exc())
return []
# try:
# channel = __import__('channels.%s' % item.channel, fromlist=["channels.%s" % item.channel])
# except:
# import traceback
# logger.error(traceback.format_exc())
# return []
if tecleado:
# Mostrar resultados: agrupados por canales
return channel.search(item, tecleado)
return [Item().fromurl(i) for i in item.itemlist]
# return channel.search(item, tecleado)
else:
# Mostrar resultados: todos juntos
if item.infoPlus: #Si viene de una ventana de InfoPlus, hay que salir de esta forma...
@@ -438,8 +439,9 @@ def channel_search(search_results, channel_parameters, tecleado):
if len(result):
if not channel_parameters["title"].capitalize() in search_results:
search_results[channel_parameters["title"].capitalize()] = []
search_results[channel_parameters["title"].capitalize()].append({"item": item,
search_results[channel_parameters['title'].capitalize()].append({"item": item,
"itemlist": result,
"thumbnail": channel_parameters["thumbnail"],
"adult": channel_parameters["adult"]})
except:
@@ -610,11 +612,15 @@ def do_search(item, categories=None):
if result_mode == 0:
if len(search_results[channel]) > 1:
title += " -%s" % element["item"].title.strip()
title += " (%s)" % len(element["itemlist"])
title = re.sub("\[COLOR [^\]]+\]", "", title)
title = re.sub("\[/COLOR]", "", title)
title = re.sub(r"\[[^\]]+\]|•", "", title)
title = typo(title,'bold') + typo("%02d" % len(element["itemlist"]),'_ [] color kod bold')
plot = config.get_localized_string(60491) + '\n' + typo('','submenu')+ '\n'
for i in element["itemlist"]:
if type(i) == Item:
plot += re.sub(r'\[(?:/)?B\]','', i.title) + '\n'
itemlist.append(Item(title=title, channel="search", action="show_result", url=element["item"].url,
extra=element["item"].extra, folder=True, adult=element["adult"],
extra=element["item"].extra, folder=True, adult=element["adult"], plot=plot,
thumbnail=element["thumbnail"], itemlist=[e.tourl() for e in element["itemlist"]],
from_action="search", from_channel=element["item"].channel, tecleado=tecleado))
# todos los resultados juntos, en la misma lista
else:
@@ -699,7 +705,7 @@ def discover_list(item):
elem['tmdb_id']=elem['id']
if 'title' in elem:
title = unify.normalize(elem['title']).capitalize()
elem['year'] = scrapertools.find_single_match(elem['release_date'], '(\d{4})-\d+-\d+')
elem['year'] = scrapertools.find_single_match(elem['release_date'], r'(\d{4})-\d+-\d+')
else:
title = unify.normalize(elem['name']).capitalize()
tvshow = True