From 83db5730f21953d8012bd04fff9aa8dc10c826aa Mon Sep 17 00:00:00 2001 From: codey Date: Fri, 17 Jan 2025 07:54:17 -0500 Subject: [PATCH] linter fixes --- endpoints/lyric_search.py | 12 ++++++------ lyric_search_new/sources/lrclib.py | 6 +++--- lyric_search_new/utils.py | 10 +++++++--- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/endpoints/lyric_search.py b/endpoints/lyric_search.py index 7c7463f..870058e 100644 --- a/endpoints/lyric_search.py +++ b/endpoints/lyric_search.py @@ -203,12 +203,12 @@ class LyricSearch(FastAPI): 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(): - seeked_found_line = i - logging.debug("Found %s at %s, match for %s!", - line, seeked_found_line, data.sub) # REMOVEME: DEBUG - break + line = regex.sub(r'\u2064', '', line.strip()) + if data.sub.strip().lower() in line.strip().lower(): + seeked_found_line = i + logging.debug("Found %s at %s, match for %s!", + line, seeked_found_line, data.sub) # REMOVEME: DEBUG + break if not seeked_found_line: return { diff --git a/lyric_search_new/sources/lrclib.py b/lyric_search_new/sources/lrclib.py index 0d57848..00f80d2 100644 --- a/lyric_search_new/sources/lrclib.py +++ b/lyric_search_new/sources/lrclib.py @@ -73,9 +73,9 @@ class LRCLib: possible_matches = [(x, f"{result.get('artistName')} - {result.get('trackName')}") for x, result in enumerate(search_data)] else: - logging.info("Limiting possible matches to only those with non-null syncedLyrics") - possible_matches = [(x, f"{result.get('artistName')} - {result.get('trackName')}") - for x, result in enumerate(search_data) if isinstance(result['syncedLyrics'], str)] + logging.info("Limiting possible matches to only those with non-null syncedLyrics") + possible_matches = [(x, f"{result.get('artistName')} - {result.get('trackName')}") + for x, result in enumerate(search_data) if isinstance(result['syncedLyrics'], str)] diff --git a/lyric_search_new/utils.py b/lyric_search_new/utils.py index 19518f5..9262f9e 100644 --- a/lyric_search_new/utils.py +++ b/lyric_search_new/utils.py @@ -94,7 +94,9 @@ class DataUtils: 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'(\d?)(Embed\b)', '', lyrics, flags=regex.IGNORECASE) lyrics = regex.sub(r'\n{2}', '\n', lyrics) # Gaps between verses @@ -102,6 +104,9 @@ class DataUtils: return lyrics def create_lrc_object(self, lrc_str: str) -> list[dict]: + """Create LRC Object + @lrc_str: The raw LRCLib syncedLyrics (str) + """ lrc_out: list = [] for line in lrc_str.split("\n"): _timetag = None @@ -125,5 +130,4 @@ class DataUtils: }) logging.info("util: returning %s, type: %s", lrc_out, type(lrc_out)) - return lrc_out - + return lrc_out \ No newline at end of file