4
1
Fork 1
This repository has been archived on 2024-08-07. You can view files and clone it, but cannot push or open issues or pull requests.
qBitDownload-Bot/Config.py

34 lines
971 B
Python

# -*- coding: utf-8 -*-
from json import load as jsonLoad
from TYPES import DirParserTypes, LogTypes
CFG_PATH = "config.json"
def loadCFG(config_path: str) -> dict:
with open(config_path, "r") as cfg:
return jsonLoad(cfg)
def loadParser(options: dict) -> tuple:
dirParser = None
parser_value = options["Main"]["DirParser"]
for av_parser in DirParserTypes:
if parser_value == av_parser.value:
dirParser = av_parser
if dirParser is None:
raise Exception(f"Directory parser '{parser_value}' not found")
else:
match dirParser:
case DirParserTypes.Jellyfin:
JellyfinConfig = {}
for i in options["JellyfinConfig"].keys():
JellyfinConfig[i] = options["JellyfinConfig"][i]
return dirParser, JellyfinConfig
configuration = loadCFG(CFG_PATH)
dirParser, JellyfinConfig = loadParser(configuration)
DBPath = configuration["Main"]["DBPath"]