新增XIAOMUSIC_DISABLE_DOWNLOAD=true时关闭音乐下载功能 see #82

This commit is contained in:
涵曦 2024-06-26 16:14:41 +00:00
parent 6a0310fe05
commit 725d4c4ab3
2 changed files with 6 additions and 0 deletions

View File

@ -83,6 +83,9 @@ class Config:
httpauth_password: str = os.getenv("XIAOMUSIC_HTTPAUTH_PASSWORD", "admin")
music_list_url: str = os.getenv("XIAOMUSIC_MUSIC_LIST_URL", "")
music_list_json: str = os.getenv("XIAOMUSIC_MUSIC_LIST_JSON", "")
disable_download: bool = (
os.getenv("XIAOMUSIC_DISABLE_DOWNLOAD", "false").lower() == "true"
)
def __post_init__(self) -> None:
if self.proxy:

View File

@ -642,6 +642,9 @@ class XiaoMusic:
# 本地歌曲不存在时下载
if not self.is_music_exist(name):
if self.config.disable_download:
await self.do_tts(f"本地不存在歌曲{name}")
return
await self.download(search_key, name)
self.log.info("正在下载中 %s", search_key + ":" + name)
await self.download_proc.wait()