mirror of
https://github.com/hanxi/xiaomusic.git
synced 2026-05-09 00:34:25 +08:00
fix: 修改cache目录,修复播放时长问题
This commit is contained in:
@@ -94,7 +94,7 @@ class Config:
|
||||
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")
|
||||
cache_dir: str = os.getenv("XIAOMUSIC_CACHE_DIR", "music/cache")
|
||||
hostname: str = os.getenv("XIAOMUSIC_HOSTNAME", "192.168.2.5")
|
||||
port: int = int(os.getenv("XIAOMUSIC_PORT", "8090")) # 监听端口
|
||||
public_port: int = int(os.getenv("XIAOMUSIC_PUBLIC_PORT", 0)) # 歌曲访问端口
|
||||
|
||||
@@ -897,24 +897,7 @@ class MusicLibrary:
|
||||
# 获取并缓存歌曲时长(如果还没有)
|
||||
if name in all_music_tags and "duration" not in all_music_tags[name]:
|
||||
try:
|
||||
# 跳过电台
|
||||
if not self.is_web_radio_music(name):
|
||||
duration = 0
|
||||
if self.is_web_music(name):
|
||||
# 网络音乐
|
||||
duration, _ = await get_web_music_duration(
|
||||
file_or_url, self.config
|
||||
)
|
||||
self.log.info(f"网络音乐 {name} 时长: {duration} 秒")
|
||||
elif os.path.exists(file_or_url):
|
||||
# 本地音乐
|
||||
duration = await get_local_music_duration(
|
||||
file_or_url, self.config
|
||||
)
|
||||
self.log.info(f"本地音乐 {name} 时长: {duration} 秒")
|
||||
|
||||
if duration > 0:
|
||||
all_music_tags[name]["duration"] = duration
|
||||
duration = await self.get_music_duration(name)
|
||||
except Exception as e:
|
||||
self.log.warning(f"获取歌曲 {name} 时长失败: {e}")
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class MusicUrlHandler:
|
||||
self.log.info(
|
||||
f"get_music_sec_url. name:{name} url:{url} origin_url:{origin_url}"
|
||||
)
|
||||
sec = self.music_library.get_music_duration(name)
|
||||
sec = await self.music_library.get_music_duration(name)
|
||||
return sec, url
|
||||
|
||||
async def get_music_url(self, name):
|
||||
|
||||
2
xiaomusic/static/default/setting.html
vendored
2
xiaomusic/static/default/setting.html
vendored
@@ -96,7 +96,7 @@ var vConsole = new window.VConsole();
|
||||
<input id="conf_path" type="text" />
|
||||
|
||||
<label for="cache_dir">缓存文件目录:</label>
|
||||
<input id="cache_dir" type="text" value='cache' />
|
||||
<input id="cache_dir" type="text" value='music/cache' />
|
||||
|
||||
<label for="temp_path">临时文件目录:</label>
|
||||
<input id="temp_path" type="text" value="music/tmp" />
|
||||
|
||||
Reference in New Issue
Block a user