Skip to content

Commit

Permalink
Merge pull request #71 from katagomo/main
Browse files Browse the repository at this point in the history
获取的歌词去除零宽字符
  • Loading branch information
HisAtri authored Sep 23, 2024
2 parents a0b0305 + 67560a4 commit e954176
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
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"))

0 comments on commit e954176

Please sign in to comment.