Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

获取的歌词去除零宽字符 #71

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def cover_api():
elif result.status_code == 404:
abort(404)
else:
abort(500, '后端存在错误,暂时无法查询')
abort(500, '服务存在错误,暂时无法查询')


@v1_bp.route('/cover/<path:s_type>', methods=['GET'])
Expand Down
4 changes: 2 additions & 2 deletions mod/args/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ def __init__(self):
self.debug = kw_args.debug
self.version = "1.5.4"

def valid(self, key):
def valid(self, key) -> bool:
"""
返回该key是否有效
:param key:
:return:
"""
return key in self.auth.keys()

def permission(self, key):
def permission(self, key) -> str:
"""
返回该key的权限组字符串
:param key:
Expand Down
7 changes: 5 additions & 2 deletions mod/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ def standard_lrc(lrc_text: str) -> str:
if not lrc_text or type(lrc_text) is not str:
return lrc_text
elif '[' in lrc_text and ']' in lrc_text:
lrc_text = lrc_text.replace("\r\n", "\n")
# 去除零宽字符
lrc_text = re.sub(r'[\ufeff\u200b]', '',
lrc_text.replace("\r\n", "\n"))
pattern = re.compile(r'\[([^]]+)]')
# 使用findall方法找到所有匹配的字符串
matches = pattern.findall(lrc_text)
Expand All @@ -81,4 +83,5 @@ def standard_lrc(lrc_text: str) -> str:
# 进行匹配和替换
return re.sub(pattern, lambda match: "[" + match.group(1) + "0]", lrc_text)
else:
return lrc_text.replace("\r\n", "\n")
return re.sub(r'[\ufeff\u200b]', '',
lrc_text.replace("\r\n", "\n"))
Loading