This commit is contained in:
2025-01-11 20:59:10 -05:00
parent 85a0d6bc62
commit 3c57f13557
18 changed files with 464 additions and 365 deletions

View File

@ -1,10 +1,12 @@
#!/usr/bin/env python3.12
# pylint: disable=bare-except, broad-exception-raised, broad-exception-caught
import importlib
import traceback
import logging
import urllib.parse
import regex
import aiohttp
import traceback
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
@ -92,6 +94,7 @@ class LyricSearch(FastAPI):
}
async def lyric_search_log_handler(self, data: ValidLyricSearchLogRequest):
"""Lyric Search Log Handler"""
include_radio = data.webradio
await self.glob_state.increment_counter('lyrichistory_requests')
last_10k_sings = await self.lyrics_engine.getHistory(limit=10000, webradio=include_radio)
@ -181,7 +184,8 @@ class LyricSearch(FastAPI):
lrc_content = response_json.get('syncedLyrics')
returned_artist = response_json.get('artistName')
returned_song = response_json.get('trackName')
print(f"Synced Lyrics [LRCLib]: {lrc_content}")
logging.debug("Synced Lyrics [LRCLib]: %s",
lrc_content)
lrc_content_out = []
for line in lrc_content.split("\n"):
_timetag = None
@ -192,7 +196,8 @@ class LyricSearch(FastAPI):
if not reg_helper:
continue
reg_helper = reg_helper[0]
print(f"Reg helper: {reg_helper} for line: {line}; len: {len(reg_helper)}")
logging.debug("Reg helper: %s for line: %s; len: %s",
reg_helper, line, len(reg_helper))
_timetag = reg_helper[0]
if not reg_helper[1].strip():
_words = ""
@ -214,7 +219,7 @@ class LyricSearch(FastAPI):
'reqn': await self.glob_state.get_counter('lyric_requests'),
}
except:
print(traceback.format_exc())
traceback.print_exc()
return {
'err': True,
'errorText': 'Search failed!',
@ -225,6 +230,7 @@ class LyricSearch(FastAPI):
'err': True,
'errorText': 'Search failed!',
}
if lrc:
return {
'err': False,
'artist': search_worker['artist'],
@ -236,7 +242,7 @@ class LyricSearch(FastAPI):
'reqn': await self.glob_state.get_counter('lyric_requests'),
}
search_worker = await self.lyrics_engine.lyrics_worker(searching=search_object, recipient='anyone')
search_worker = await self.lyrics_engine.lyrics_worker(searching=search_object)
if not search_worker or not 'l' in search_worker.keys():