fix: 修复windows下路径问题

This commit is contained in:
涵曦 2024-09-26 07:32:02 +08:00
parent aa7b25cd33
commit 02d9987ad7

View File

@ -433,9 +433,9 @@ class XiaoMusic:
tags = copy.copy(self.all_music_tags.get(name, asdict(Metadata()))) tags = copy.copy(self.all_music_tags.get(name, asdict(Metadata())))
picture = tags["picture"] picture = tags["picture"]
if picture: if picture:
picture = picture.replace("\\", "/")
if picture.startswith(self.config.picture_cache_path): if picture.startswith(self.config.picture_cache_path):
picture = picture[len(self.config.picture_cache_path) :] picture = picture[len(self.config.picture_cache_path) :]
picture = picture.replace("\\", "/")
if picture.startswith("/"): if picture.startswith("/"):
picture = picture[1:] picture = picture[1:]
encoded_name = urllib.parse.quote(picture) encoded_name = urllib.parse.quote(picture)
@ -473,9 +473,9 @@ class XiaoMusic:
self.log.warning(f"Failed to convert file to MP3 format: {filename}") self.log.warning(f"Failed to convert file to MP3 format: {filename}")
# 构造音乐文件的URL # 构造音乐文件的URL
filename = filename.replace("\\", "/")
if filename.startswith(self.config.music_path): if filename.startswith(self.config.music_path):
filename = filename[len(self.config.music_path) :] filename = filename[len(self.config.music_path) :]
filename = filename.replace("\\", "/")
if filename.startswith("/"): if filename.startswith("/"):
filename = filename[1:] filename = filename[1:]