From 56aab05ae3fdd016c53a980dadd09a72360d46e0 Mon Sep 17 00:00:00 2001 From: cttynul Date: Thu, 6 Jun 2019 19:09:56 +0200 Subject: [PATCH] autoset json url with a very unundestrandable code --- videolibrary_service.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/videolibrary_service.py b/videolibrary_service.py index 568022d0..03b56047 100644 --- a/videolibrary_service.py +++ b/videolibrary_service.py @@ -3,7 +3,7 @@ # Service for updating new episodes on library series # ------------------------------------------------------------ -import datetime, imp, math, threading, traceback, sys +import datetime, imp, math, threading, traceback, sys, glob @@ -323,17 +323,15 @@ def get_channel_json(): channels_path = os.path.join(ROOT_DIR, "channels", '*.json') channel_files = sorted(glob.glob(channels_path), key=lambda x: os.path.basename(x)) for channel_file in channel_files: - if 1: - try: - import json - except: - import simplejson as json + if channel_file: + try: import json + except: import simplejson as json with open(LOCAL_FILE) as f: data = json.load(f) - if data[channel_file] is not None: - config.set_setting(name=data[channel_file], value="value", channel=channel_file) - else: - pass + try: + if data[channel_file]: + config.set_setting(name=data[channel_file], value="value", channel=channel_file) + except: pass #channel not in json if __name__ == "__main__": # Se ejecuta en cada inicio