支持配置歌曲下载源 #12

This commit is contained in:
涵曦 2024-02-02 20:55:51 +08:00
parent 67be9125d8
commit 13336cd02c
2 changed files with 5 additions and 1 deletions

View File

@ -85,6 +85,9 @@ class Config:
hostname: str = os.getenv("XIAOMUSIC_HOSTNAME", "192.168.2.5") hostname: str = os.getenv("XIAOMUSIC_HOSTNAME", "192.168.2.5")
port: int = int(os.getenv("XIAOMUSIC_PORT", "8090")) port: int = int(os.getenv("XIAOMUSIC_PORT", "8090"))
proxy: str | None = os.getenv("XIAOMUSIC_PROXY", None) proxy: str | None = os.getenv("XIAOMUSIC_PROXY", None)
search_prefix: str = os.getenv(
"XIAOMUSIC_SEARCH", "ytsearch:"
) # "bilisearch:" or "ytsearch:"
def __post_init__(self) -> None: def __post_init__(self) -> None:
if self.proxy: if self.proxy:

View File

@ -56,6 +56,7 @@ class XiaoMusic:
self.hostname = config.hostname self.hostname = config.hostname
self.port = config.port self.port = config.port
self.proxy = config.proxy self.proxy = config.proxy
self.search_prefix = config.search_prefix
# 下载对象 # 下载对象
self.download_proc = None self.download_proc = None
@ -298,7 +299,7 @@ class XiaoMusic:
sbp_args = ( sbp_args = (
"yt-dlp", "yt-dlp",
f"ytsearch:{name}", f"{self.search_prefix}{name}",
"-x", "-x",
"--audio-format", "--audio-format",
"mp3", "mp3",