Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
TooAndy committed Oct 12, 2024
2 parents 2b56a98 + b73b978 commit c17f74b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 1 addition & 4 deletions api/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ def local_cover_search(title: str, artist: str, album: str):
@cache.cached(timeout=86400, key_prefix=make_cache_key)
@no_error(exceptions=AttributeError)
def cover_api():
title = request.args.get('title')
if not title:
abort(400, '歌曲名称不能为空')
title = unquote_plus(title)
title = unquote_plus(request.args.get('title', ''))
artist = unquote_plus(request.args.get('artist', ''))
album = unquote_plus(request.args.get('album', ''))
req_args = {key: request.args.get(key) for key in request.args}
Expand Down
6 changes: 3 additions & 3 deletions api/lyrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from mod.auth.authentication import require_auth


def read_file_with_encoding(file_path, encodings):
def read_file_with_encoding(file_path:str, encodings:list[str]):
for encoding in encodings:
try:
with open(file_path, 'r', encoding=encoding) as f:
Expand All @@ -40,7 +40,7 @@ def lyrics():
if path:
lrc_path = os.path.splitext(path)[0] + '.lrc'
if os.path.isfile(lrc_path):
file_content = read_file_with_encoding(lrc_path, ['utf-8', 'gbk'])
file_content: str|None = read_file_with_encoding(lrc_path, ['utf-8', 'gbk'])
if file_content is not None:
return lrc.standard(file_content)
try:
Expand All @@ -51,7 +51,7 @@ def lyrics():
pass
try:
# 通过request参数获取音乐Tag
title = unquote_plus(request.args.get('title'))
title = unquote_plus(request.args.get('title', ''))
artist = unquote_plus(request.args.get('artist', ''))
album = unquote_plus(request.args.get('album', ''))
result: list = searchx.search_all(title=title, artist=artist, album=album, timeout=30)
Expand Down

0 comments on commit c17f74b

Please sign in to comment.