linter fixes

This commit is contained in:
codey 2025-01-17 07:54:17 -05:00
parent ce04722763
commit 83db5730f2
3 changed files with 16 additions and 12 deletions

View File

@ -203,12 +203,12 @@ class LyricSearch(FastAPI):
if data.sub and not data.lrc: if data.sub and not data.lrc:
lyric_lines = result['lyrics'].strip().split(" / ") lyric_lines = result['lyrics'].strip().split(" / ")
for i, line in enumerate(lyric_lines): for i, line in enumerate(lyric_lines):
line = regex.sub(r'\u2064', '', line.strip()) line = regex.sub(r'\u2064', '', line.strip())
if data.sub.strip().lower() in line.strip().lower(): if data.sub.strip().lower() in line.strip().lower():
seeked_found_line = i seeked_found_line = i
logging.debug("Found %s at %s, match for %s!", logging.debug("Found %s at %s, match for %s!",
line, seeked_found_line, data.sub) # REMOVEME: DEBUG line, seeked_found_line, data.sub) # REMOVEME: DEBUG
break break
if not seeked_found_line: if not seeked_found_line:
return { return {

View File

@ -73,9 +73,9 @@ class LRCLib:
possible_matches = [(x, f"{result.get('artistName')} - {result.get('trackName')}") possible_matches = [(x, f"{result.get('artistName')} - {result.get('trackName')}")
for x, result in enumerate(search_data)] for x, result in enumerate(search_data)]
else: else:
logging.info("Limiting possible matches to only those with non-null syncedLyrics") logging.info("Limiting possible matches to only those with non-null syncedLyrics")
possible_matches = [(x, f"{result.get('artistName')} - {result.get('trackName')}") possible_matches = [(x, f"{result.get('artistName')} - {result.get('trackName')}")
for x, result in enumerate(search_data) if isinstance(result['syncedLyrics'], str)] for x, result in enumerate(search_data) if isinstance(result['syncedLyrics'], str)]

View File

@ -94,7 +94,9 @@ class DataUtils:
def scrub_lyrics(self, lyrics: str) -> str: def scrub_lyrics(self, lyrics: str) -> str:
"""Regex Chain""" """Regex Chain
@lyrics: The lyrics (str) to scrub
"""
lyrics = regex.sub(r'(\[.*?\])(\s){0,}(\:){0,1}', '', lyrics) lyrics = regex.sub(r'(\[.*?\])(\s){0,}(\:){0,1}', '', lyrics)
lyrics = regex.sub(r'(\d?)(Embed\b)', '', lyrics, flags=regex.IGNORECASE) lyrics = regex.sub(r'(\d?)(Embed\b)', '', lyrics, flags=regex.IGNORECASE)
lyrics = regex.sub(r'\n{2}', '\n', lyrics) # Gaps between verses lyrics = regex.sub(r'\n{2}', '\n', lyrics) # Gaps between verses
@ -102,6 +104,9 @@ class DataUtils:
return lyrics return lyrics
def create_lrc_object(self, lrc_str: str) -> list[dict]: def create_lrc_object(self, lrc_str: str) -> list[dict]:
"""Create LRC Object
@lrc_str: The raw LRCLib syncedLyrics (str)
"""
lrc_out: list = [] lrc_out: list = []
for line in lrc_str.split("\n"): for line in lrc_str.split("\n"):
_timetag = None _timetag = None
@ -125,5 +130,4 @@ class DataUtils:
}) })
logging.info("util: returning %s, type: %s", logging.info("util: returning %s, type: %s",
lrc_out, type(lrc_out)) lrc_out, type(lrc_out))
return lrc_out return lrc_out