lrc tweaks
This commit is contained in:
@ -191,14 +191,17 @@ class LyricSearch(FastAPI):
|
||||
aggregate_search = aggregate.Aggregate(exclude_methods=excluded_sources)
|
||||
plain_lyrics = not data.lrc
|
||||
result = await aggregate_search.search(data.a, data.s, plain_lyrics)
|
||||
|
||||
if not result:
|
||||
return {
|
||||
'err': True,
|
||||
'errorText': 'Sources exhausted, lyrics not located.',
|
||||
}
|
||||
result = result.dict()
|
||||
lyric_lines = result['lyrics'].strip().split(" / ")
|
||||
if data.sub:
|
||||
|
||||
result = result.todict()
|
||||
|
||||
if data.sub and not data.lrc:
|
||||
lyric_lines = result['lyrics'].strip().split(" / ")
|
||||
for i, line in enumerate(lyric_lines):
|
||||
line = regex.sub(r'\u2064', '', line.strip())
|
||||
if data.sub.strip().lower() in line.strip().lower():
|
||||
@ -213,9 +216,18 @@ class LyricSearch(FastAPI):
|
||||
}
|
||||
result['lyrics'] = " / ".join(lyric_lines[seeked_found_line:])
|
||||
|
||||
result['lyrics'] = regex.sub(r'(\s/\s|\n)', '<br>', result['lyrics']).strip()
|
||||
result['confidence'] = int(result.get('confidence', 0))
|
||||
result['time'] = f'{float(result['time']):.4f}'
|
||||
|
||||
if plain_lyrics:
|
||||
result['lyrics'] = regex.sub(r'(\s/\s|\n)', '<br>', result['lyrics']).strip()
|
||||
else:
|
||||
# Swap lyrics key for 'lrc'
|
||||
logging.info("lyrics: %s, type: %s",
|
||||
result['lyrics'], type(result['lyrics']))
|
||||
result['lrc'] = result['lyrics']
|
||||
result.pop('lyrics')
|
||||
|
||||
if "cached" in result['src']:
|
||||
result['from_cache'] = True
|
||||
|
||||
|
Reference in New Issue
Block a user