新增忽略目录的环境变量

This commit is contained in:
涵曦 2024-06-16 05:40:30 +00:00
parent c22fc99235
commit 881c34bcb5
2 changed files with 3 additions and 0 deletions

View File

@ -95,6 +95,7 @@ class Config:
) # "bilisearch:" or "ytsearch:"
ffmpeg_location: str = os.getenv("XIAOMUSIC_FFMPEG_LOCATION", "./ffmpeg/bin")
active_cmd: str = os.getenv("XIAOMUSIC_ACTIVE_CMD", "play,random_play")
exclude_dirs: str = os.getenv("XIAOMUSIC_EXCLUDE_DIRS", "@eadir")
def __post_init__(self) -> None:
if self.proxy:

View File

@ -62,6 +62,7 @@ class XiaoMusic:
self.search_prefix = config.search_prefix
self.ffmpeg_location = config.ffmpeg_location
self.active_cmd = config.active_cmd.split(",")
self.exclude_dirs = set(config.exclude_dirs.split(","))
# 下载对象
self.download_proc = None
@ -347,6 +348,7 @@ class XiaoMusic:
self._all_music = {}
all_music_by_dir = {}
for root, dirs, filenames in os.walk(self.music_path):
dirs[:] = [d for d in dirs if d not in self.exclude_dirs]
self.log.debug("root:%s dirs:%s music_path:%s", root, dirs, self.music_path)
dir_name = os.path.basename(root)
if self.music_path == root: