From 27e9d92a0ab48ef4ab6f7e007a30406bceabcf1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B6=B5=E6=9B=A6?= Date: Sun, 30 Jun 2024 03:54:39 +0000 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4config.json=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config-example.json | 28 ++++++++++++++++++++++++++++ xiaomusic/config.py | 7 ++++++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 config-example.json diff --git a/config-example.json b/config-example.json new file mode 100644 index 0000000..ab2277b --- /dev/null +++ b/config-example.json @@ -0,0 +1,28 @@ +{ + "hardware": "L07A", + "account": "", + "password": "", + "mi_did": "", + "cookie": "", + "verbose": false, + "music_path": "music", + "conf_path": null, + "hostname": "192.168.2.5", + "port": 8090, + "proxy": null, + "search_prefix": "ytsearch:", + "ffmpeg_location": "./ffmpeg/bin", + "active_cmd": "play,random_play,playlocal,play_music_list,stop", + "exclude_dirs": "@eaDir", + "music_path_depth": 10, + "disable_httpauth": true, + "httpauth_username": "admin", + "httpauth_password": "admin", + "music_list_url": "", + "music_list_json": "", + "disable_download": false, + "use_music_api": false, + "log_file": "/tmp/xiaomusic.txt", + "fuzzy_match_cutoff": 0.6, + "enable_fuzzy_match": true +} \ No newline at end of file diff --git a/xiaomusic/config.py b/xiaomusic/config.py index 895c368..533c709 100644 --- a/xiaomusic/config.py +++ b/xiaomusic/config.py @@ -3,7 +3,7 @@ from __future__ import annotations import argparse import json import os -from dataclasses import dataclass +from dataclasses import dataclass,asdict from xiaomusic.utils import validate_proxy @@ -107,6 +107,11 @@ class Config: keywords_stop = os.getenv("XIAOMUSIC_KEYWORDS_STOP", "关机,暂停,停止") self.append_keyword(keywords_stop, "stop") + # 保存配置到 config-example.json 文件 + #with open("config-example.json", "w") as f: + # data = asdict(self) + # json.dump(data, f, ensure_ascii=False, indent=4) + @classmethod def from_options(cls, options: argparse.Namespace) -> Config: config = {}