Skip to content

Commit

Permalink
新增XIAOMUSIC_DISABLE_DOWNLOAD=true时关闭音乐下载功能 see #82
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxi committed Jun 26, 2024
1 parent 6a0310f commit 725d4c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions xiaomusic/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions xiaomusic/xiaomusic.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,9 @@ async def play(self, **kwargs):

# 本地歌曲不存在时下载
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()
Expand Down

0 comments on commit 725d4c4

Please sign in to comment.