Switched from JSON config file to yaml
This commit is contained in:
parent
3d8f0f5f3c
commit
a55403758d
3 changed files with 8 additions and 7 deletions
|
@ -25,6 +25,7 @@ yt-dlp = "*"
|
|||
customtkinter = "^5.2.1"
|
||||
qrcode = "^7.4.2"
|
||||
pymediainfo = "^6.1.0"
|
||||
pyyaml = "^6.0.1"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
|
|
|
@ -39,7 +39,7 @@ import tempfile
|
|||
from argparse import ArgumentParser
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import field
|
||||
from json import load
|
||||
from yaml import load, Loader
|
||||
from traceback import print_exc
|
||||
from typing import Any
|
||||
from typing import Optional
|
||||
|
@ -385,7 +385,7 @@ async def start_client(config: dict[str, Any]) -> None:
|
|||
if "config" in config:
|
||||
last_song = (
|
||||
datetime.datetime.fromisoformat(config["config"]["last_song"])
|
||||
if "last_song" in config["config"]
|
||||
if "last_song" in config["config"] and config["config"]["last_song"]
|
||||
else None
|
||||
)
|
||||
state.config |= config["config"] | {"last_song": last_song}
|
||||
|
@ -423,14 +423,14 @@ def main() -> None:
|
|||
|
||||
parser.add_argument("--room", "-r")
|
||||
parser.add_argument("--secret", "-s")
|
||||
parser.add_argument("--config-file", "-C", default="syng-client.json")
|
||||
parser.add_argument("--config-file", "-C", default="syng-client.yaml")
|
||||
parser.add_argument("--key", "-k", default=None)
|
||||
parser.add_argument("--server", "-S")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
with open(args.config_file, encoding="utf8") as file:
|
||||
config = load(file)
|
||||
config = load(file, Loader=Loader)
|
||||
|
||||
if "config" not in config:
|
||||
config["config"] = {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import builtins
|
||||
from json import load
|
||||
from yaml import load, Loader
|
||||
import customtkinter
|
||||
import qrcode
|
||||
import secrets
|
||||
|
@ -164,8 +164,8 @@ class SyngGui(customtkinter.CTk):
|
|||
def __init__(self):
|
||||
super().__init__(className="Syng")
|
||||
|
||||
with open("syng-client.json") as cfile:
|
||||
loaded_config = load(cfile)
|
||||
with open("syng-client.yaml") as cfile:
|
||||
loaded_config = load(cfile, Loader=Loader)
|
||||
config = {"sources": {}, "config": default_config()}
|
||||
if "config" in loaded_config:
|
||||
config["config"] |= loaded_config["config"]
|
||||
|
|
Loading…
Add table
Reference in a new issue