diff --git a/lyric_search_new/sources/aggregate.py b/lyric_search_new/sources/aggregate.py index c0a74b0..5812fdb 100644 --- a/lyric_search_new/sources/aggregate.py +++ b/lyric_search_new/sources/aggregate.py @@ -43,4 +43,4 @@ class Aggregate: if search_result: break logging.info("%s: NOT FOUND!", source.label) - return search_result + return search_result \ No newline at end of file diff --git a/lyric_search_new/sources/cache.py b/lyric_search_new/sources/cache.py index 90512af..79f37eb 100644 --- a/lyric_search_new/sources/cache.py +++ b/lyric_search_new/sources/cache.py @@ -24,7 +24,8 @@ class Cache: "lib", "singerdbs", "cached_lyrics.db") - self.cache_pre_query: str = "pragma journal_mode = WAL; pragma synchronous = normal; pragma temp_store = memory; pragma mmap_size = 30000000000;" + self.cache_pre_query: str = "pragma journal_mode = WAL; pragma synchronous = normal;\ + pragma temp_store = memory; pragma mmap_size = 30000000000;" self.sqlite_exts: list[str] = ['/usr/local/lib/python3.11/dist-packages/spellfix1.cpython-311-x86_64-linux-gnu.so'] self.label: str = "Cache" @@ -52,12 +53,13 @@ class Cache: check_query = "SELECT id FROM lyrics WHERE artistsong LIKE ? LIMIT 1" params = (f"%{artistsong}%",) async with sqlite3.connect(self.cache_db, timeout=2) as db_conn: - async with db_conn.execute(check_query, params) as db_cursor: - result = await db_cursor.fetchone() - if result: - logging.debug("%s is already stored.", - artistsong.replace("\n", " - ")) - return True + async with await db_conn.executescript(self.cache_pre_query) as _db_cursor: + async with await db_conn.execute(check_query, params) as db_cursor: + result = await db_cursor.fetchone() + if result: + logging.debug("%s is already stored.", + artistsong.replace("\n", " - ")) + return True logging.debug("%s cleared to be stored.", artistsong) return False @@ -91,8 +93,9 @@ class Cache: lyr_result.song, artistsong, lyr_result.confidence, lyrics) async with sqlite3.connect(self.cache_db, timeout=2) as db_conn: - async with db_conn.execute(insert_query, params) as _cursor: - await db_conn.commit() + async with await db_conn.executescript(self.cache_pre_query) as _db_cursor: + async with await db_conn.execute(insert_query, params) as _cursor: + await db_conn.commit() logging.info("Stored %s!", artistsong.replace("\n", " - ")) except: logging.critical("Cache storage error!") @@ -159,8 +162,4 @@ class Cache: except: if log_level == "DEBUG": traceback.print_exc() - return - - - - \ No newline at end of file + return \ No newline at end of file diff --git a/lyric_search_new/sources/genius.py b/lyric_search_new/sources/genius.py index ad1c89e..8aca6da 100644 --- a/lyric_search_new/sources/genius.py +++ b/lyric_search_new/sources/genius.py @@ -123,6 +123,4 @@ class Genius: except: # if log_level == "DEBUG": traceback.print_exc() - return - - + return \ No newline at end of file diff --git a/lyric_search_new/sources/lrclib.py b/lyric_search_new/sources/lrclib.py index 60a9aea..7e0f99d 100644 --- a/lyric_search_new/sources/lrclib.py +++ b/lyric_search_new/sources/lrclib.py @@ -112,6 +112,4 @@ class LRCLib: except: if log_level == "DEBUG": traceback.print_exc() - return - - + return \ No newline at end of file