docstring stuff

This commit is contained in:
2025-01-19 07:01:07 -05:00
parent 151643c5dc
commit be0ef08f3d
9 changed files with 118 additions and 52 deletions

View File

@ -6,6 +6,7 @@ import traceback
import logging
import os
import urllib.parse
from typing import Optional
import regex
import aiohttp
import aiosqlite as sqlite3
@ -186,11 +187,22 @@ class LyricSearch(FastAPI):
if data.src.upper() not in self.acceptable_request_sources:
raise HTTPException(detail="Invalid request", status_code=500)
search_artist: Optional[str] = data.a
search_song: Optional[str] = data.s
if search_artist and search_song:
search_artist = self.constants.DOUBLE_SPACE_REGEX.sub(" ", search_artist.strip())
search_song = self.constants.DOUBLE_SPACE_REGEX.sub(" ", search_song.strip())
search_artist = urllib.parse.unquote(search_artist)
search_song = urllib.parse.unquote(search_song)
excluded_sources = data.excluded_sources
aggregate_search = aggregate.Aggregate(exclude_methods=excluded_sources)
plain_lyrics = not data.lrc
result = await aggregate_search.search(data.a, data.s, plain_lyrics)
result = await aggregate_search.search(search_artist, search_song, plain_lyrics)
if not result:
return {
@ -201,6 +213,7 @@ class LyricSearch(FastAPI):
result = result.todict()
if data.sub and not data.lrc:
seeked_found_line = None
lyric_lines = result['lyrics'].strip().split(" / ")
for i, line in enumerate(lyric_lines):
line = regex.sub(r'\u2064', '', line.strip())
@ -223,12 +236,10 @@ class LyricSearch(FastAPI):
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']:
if "cache" in result['src']:
result['from_cache'] = True
"""
@ -333,8 +344,6 @@ class LyricSearch(FastAPI):
if not reg_helper:
continue
reg_helper = reg_helper[0]
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 = ""