findhost in channels.json
This commit is contained in:
@@ -258,10 +258,10 @@ def check_channels(inutile=''):
|
||||
|
||||
risultato = {}
|
||||
|
||||
for chann, host in sorted(data.items()):
|
||||
for chann, host in sorted(data['direct'].items()):
|
||||
|
||||
ris = []
|
||||
# to get an idea of the timing
|
||||
# to get an idea of the timing
|
||||
# useful only if you control all channels
|
||||
# for channels with error 522 about 40 seconds are lost ...
|
||||
logger.info("check #### INIZIO #### channel - host :%s - %s " % (chann, host))
|
||||
@@ -290,6 +290,7 @@ def check_channels(inutile=''):
|
||||
|
||||
logger.info("check #### FINE #### rslt :%s " % (rslt))
|
||||
|
||||
risultato = {'findhost': data['findhost'], 'direct': risultato}
|
||||
fileJson_test = 'channels-test.json'
|
||||
# I write the updated file
|
||||
with open(folderJson+'/'+fileJson_test, 'w') as f:
|
||||
|
||||
@@ -15,7 +15,7 @@ __language__ = __settings__.getLocalizedString
|
||||
__version_fix = None
|
||||
__dev_mode = None
|
||||
|
||||
channels_data = list()
|
||||
channels_data = dict()
|
||||
|
||||
def get_addon_core():
|
||||
return __settings__
|
||||
@@ -101,27 +101,29 @@ def is_xbmc():
|
||||
def get_videolibrary_support():
|
||||
return True
|
||||
|
||||
def get_channel_url(findhostMethod=None, name=None):
|
||||
|
||||
def get_channel_url(findhostMethod=None, name=None, forceFindhost=False):
|
||||
from core import jsontools
|
||||
import inspect
|
||||
|
||||
LOCAL_FILE = os.path.join(get_runtime_path(), "channels.json")
|
||||
global channels_data
|
||||
if not channels_data:
|
||||
with open(LOCAL_FILE) as f:
|
||||
channels_data = jsontools.load(f.read())
|
||||
|
||||
frame = inspect.stack()[1]
|
||||
if not name:
|
||||
name = os.path.basename(frame[0].f_code.co_filename).replace('.py', '')
|
||||
if findhostMethod:
|
||||
url = jsontools.get_node_from_file(name, 'url')
|
||||
if not url or 'web.archive.org' in url: # per eliminare tutti i webarchive salvati causa bug httptools CF, eliminare in futuro
|
||||
url = findhostMethod()
|
||||
if not url or 'web.archive.org' in url or forceFindhost: # per eliminare tutti i webarchive salvati causa bug httptools CF, eliminare in futuro
|
||||
url = findhostMethod(channels_data['findhost'][name])
|
||||
jsontools.update_node(url, name, 'url')
|
||||
return url
|
||||
else:
|
||||
ROOT_DIR = xbmc.translatePath(__settings__.getAddonInfo('Path'))
|
||||
LOCAL_FILE = os.path.join(ROOT_DIR, "channels.json")
|
||||
global channels_data
|
||||
if not channels_data:
|
||||
with open(LOCAL_FILE) as f:
|
||||
channels_data = jsontools.load(f.read())
|
||||
return channels_data[name]
|
||||
return channels_data['direct'][name]
|
||||
|
||||
|
||||
def get_system_platform():
|
||||
""" function: to recover the platform that xbmc is running """
|
||||
|
||||
Reference in New Issue
Block a user