mirror of
https://github.com/MeoProject/lx-music-api-server.git
synced 2025-05-23 19:17:41 +08:00
fix: 修复LRC文件读取歌词
This commit is contained in:
parent
a55da25de5
commit
35f1fe513a
@ -143,7 +143,7 @@ def getAudioMeta(filepath):
|
||||
audio = mutagen.File(filepath)
|
||||
if not audio:
|
||||
return None
|
||||
logger.info(audio.items())
|
||||
logger.debug(audio.items())
|
||||
if (filepath.lower().endswith('.mp3')):
|
||||
cover = audio.get('APIC:')
|
||||
if (cover):
|
||||
@ -161,8 +161,20 @@ def getAudioMeta(filepath):
|
||||
album = album.text
|
||||
if (lyric):
|
||||
lyric = lyric.text
|
||||
else:
|
||||
lyric = [None]
|
||||
if (not lyric):
|
||||
if (os.path.isfile(os.path.splitext(filepath)[0] + '.lrc')):
|
||||
with open(os.path.splitext(filepath)[0] + '.lrc', 'r', encoding='utf-8') as f:
|
||||
t = f.read().replace('\ufeff', '')
|
||||
logger.debug(t)
|
||||
lyric = filterLyricLine(t)
|
||||
logger.debug(lyric)
|
||||
if (not checkLyricValid(lyric)):
|
||||
lyric = [None]
|
||||
else:
|
||||
lyric = [lyric]
|
||||
f.close()
|
||||
else:
|
||||
lyric = [None]
|
||||
else:
|
||||
cover = audio.get('cover')
|
||||
if (cover):
|
||||
@ -182,6 +194,8 @@ def getAudioMeta(filepath):
|
||||
lyric = filterLyricLine(f.read())
|
||||
if (not checkLyricValid(lyric)):
|
||||
lyric = [None]
|
||||
else:
|
||||
lyric = [lyric]
|
||||
f.close()
|
||||
else:
|
||||
lyric = [None]
|
||||
|
1
main.py
1
main.py
@ -159,6 +159,7 @@ async def handle_local(request):
|
||||
t = request.match_info.get('type')
|
||||
data['t'] = t
|
||||
except:
|
||||
logger.info(traceback.format_exc())
|
||||
return handleResult({'code': 6, 'msg': '请求参数有错', 'data': None}, 404)
|
||||
if (data['t'] == 'u'):
|
||||
if (data['p'] in list(localMusic.map.keys())):
|
||||
|
Loading…
x
Reference in New Issue
Block a user