diff --git a/xiaomusic/config.py b/xiaomusic/config.py
index 2aa9552..18256a6 100644
--- a/xiaomusic/config.py
+++ b/xiaomusic/config.py
@@ -88,9 +88,8 @@ class Config:
miio_tts_command: str = os.getenv("MIIO_TTS_CMD", "")
cookie: str = ""
verbose: bool = os.getenv("XIAOMUSIC_VERBOSE", "").lower() == "true"
- music_path: str = os.getenv(
- "XIAOMUSIC_MUSIC_PATH", "music"
- ) # 只能是music目录下的子目录
+ music_path: str = os.getenv("XIAOMUSIC_MUSIC_PATH", "music")
+ temp_path: str = os.getenv("XIAOMUSIC_TEMP_PATH", "music/tmp")
download_path: str = os.getenv("XIAOMUSIC_DOWNLOAD_PATH", "music/download")
conf_path: str = os.getenv("XIAOMUSIC_CONF_PATH", "conf")
cache_dir: str = os.getenv("XIAOMUSIC_CACHE_DIR", "cache")
@@ -307,6 +306,12 @@ class Config:
cookies_path = os.path.join(self.conf_path, "yt-dlp-cookie.txt")
return cookies_path
+ @property
+ def temp_dir(self):
+ if not os.path.exists(self.temp_path):
+ os.makedirs(self.temp_path)
+ return self.temp_path
+
def get_play_type_tts(self, play_type):
if play_type == PLAY_TYPE_ONE:
return self.play_type_one_tts_msg
diff --git a/xiaomusic/static/default/setting.html b/xiaomusic/static/default/setting.html
index 42f8790..4dde8dd 100644
--- a/xiaomusic/static/default/setting.html
+++ b/xiaomusic/static/default/setting.html
@@ -71,10 +71,12 @@ var vConsole = new window.VConsole();
-
+
+
+
diff --git a/xiaomusic/utils.py b/xiaomusic/utils.py
index c50dd4a..7059904 100644
--- a/xiaomusic/utils.py
+++ b/xiaomusic/utils.py
@@ -407,14 +407,6 @@ def no_padding(info):
return 0
-def get_temp_dir(music_path: str):
- # 指定临时文件的目录为 music_path 目录下的 tmp 文件夹
- temp_dir = os.path.join(music_path, "tmp")
- if not os.path.exists(temp_dir):
- os.makedirs(temp_dir) # 确保目录存在
- return temp_dir
-
-
def remove_id3_tags(input_file: str, config) -> str:
audio = MP3(input_file, ID3=ID3)
@@ -426,7 +418,7 @@ def remove_id3_tags(input_file: str, config) -> str:
return None
music_path = config.music_path
- temp_dir = get_temp_dir(music_path)
+ temp_dir = config.temp_dir
# 构造新文件的路径
out_file_name = os.path.splitext(os.path.basename(input_file))[0]
@@ -459,7 +451,7 @@ def remove_id3_tags(input_file: str, config) -> str:
def convert_file_to_mp3(input_file: str, config) -> str:
music_path = config.music_path
- temp_dir = get_temp_dir(music_path)
+ temp_dir = config.temp_dir
out_file_name = os.path.splitext(os.path.basename(input_file))[0]
out_file_path = os.path.join(temp_dir, f"{out_file_name}.mp3")