From 5224c90918be9f4785bd6d0100b1b98f3570417d Mon Sep 17 00:00:00 2001 From: hygienic-books Date: Tue, 22 Mar 2022 02:33:57 +0100 Subject: [PATCH] Extend config options --- config.ini | 14 +++++++++++++- kodi-nfo-feeder.py | 10 ++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/config.ini b/config.ini index 266c6c5..b8e8aec 100644 --- a/config.ini +++ b/config.ini @@ -1,3 +1,15 @@ +[DEFAULT] +self_name = kodi-nfo-feeder +ignored_target_file_exts = .jpg, .jpeg, .png, .nfo +title_regex_search = +title_regex_replace = + [maus] watch_dir = /var/lib/kodi-nfo-feeder/watch -output_dir = /var/lib/kodi-nfo-feeder/output \ No newline at end of file +output_dir = /var/lib/kodi-nfo-feeder/output +# title_regex_search = (\w)-(\s) +# title_regex_replace = \1 -\2 + +[otto] +watch_dir = /var/lib/kodi-nfo-feeder/test/watch +output_dir = /var/lib/kodi-nfo-feeder/test/output \ No newline at end of file diff --git a/kodi-nfo-feeder.py b/kodi-nfo-feeder.py index e018dcf..569e5b5 100644 --- a/kodi-nfo-feeder.py +++ b/kodi-nfo-feeder.py @@ -22,11 +22,15 @@ class CONST(object): CFG_DEFAULT_ABS_PATH = os.path.join(CFG_THIS_FILE_DIRNAME, CFG_DEFAULT_FILENAME) CFG_KNOWN_DEFAULTS = [ {"key": "self_name", "value": "kodi-nfo-feeder"}, - {"key": "watch_dir", "value": os.path.join(CFG_THIS_FILE_DIRNAME, "data/var/lib/%(self_name)s/watch")} + {"key": "ignored_target_file_exts", "value": ".jpg, .jpeg, .png, .nfo"}, + {"key": "title_regex_search", "value": ""}, + {"key": "title_regex_replace", "value": ""} ] CFG_KNOWN_SECTION = [ {"key": "watch_dir", "is_mandatory": True}, - {"key": "output_dir", "is_mandatory": True} + {"key": "output_dir", "is_mandatory": True}, + {"key": "title_regex_search", "is_mandatory": False}, + {"key": "title_regex_replace", "is_mandatory": False} ] CFG_MANDATORY = [section_cfg["key"] for section_cfg in CFG_KNOWN_SECTION if section_cfg["is_mandatory"]] @@ -71,6 +75,8 @@ ini_defaults = [] internal_defaults = {default["key"]: default["value"] for default in CONST.CFG_KNOWN_DEFAULTS} config = ConfigParser(defaults=internal_defaults) config.read(CONST.CFG_DEFAULT_FILENAME) +ignored_target_file_exts_str = config.get(config.default_section, "ignored_target_file_exts") +ignored_target_file_exts = re.split(r""",\s?|\s""", ignored_target_file_exts_str) def print_section_header(