mirror of
https://github.com/beetbox/beets.git
synced 2025-12-26 02:24:33 +01:00
Also perform bareasc queries in SQL
This commit is contained in:
parent
0f1b5d6f7c
commit
b5b1afbfff
3 changed files with 12 additions and 0 deletions
|
|
@ -23,6 +23,8 @@ import threading
|
|||
import sqlite3
|
||||
import contextlib
|
||||
|
||||
from unidecode import unidecode
|
||||
|
||||
import beets
|
||||
from beets.util import functemplate
|
||||
from beets.util import py3_path
|
||||
|
|
@ -995,6 +997,7 @@ class Database:
|
|||
return re.search(pattern, str(value)) is not None
|
||||
|
||||
conn.create_function("regexp", 2, regexp)
|
||||
conn.create_function("unidecode", 1, unidecode)
|
||||
|
||||
def _close(self):
|
||||
"""Close the all connections to the underlying SQLite database
|
||||
|
|
|
|||
|
|
@ -42,6 +42,14 @@ class BareascQuery(StringFieldQuery):
|
|||
val = unidecode(val)
|
||||
return pattern in val
|
||||
|
||||
def col_clause(self):
|
||||
"""Compare ascii version of the pattern."""
|
||||
clause = f"unidecode({self.field})"
|
||||
if self.pattern.islower():
|
||||
clause = f"lower({clause})"
|
||||
|
||||
return rf"{clause} LIKE ? ESCAPE '\'", [f"%{unidecode(self.pattern)}%"]
|
||||
|
||||
|
||||
class BareascPlugin(BeetsPlugin):
|
||||
"""Plugin to provide bare-ASCII option for beets matching."""
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ New features:
|
|||
|
||||
* --from-logfile now parses log files using a UTF-8 encoding in `beets/beets/ui/commands.py`.
|
||||
:bug:`4693`
|
||||
* :doc:`/plugins/bareasc` lookups have been made faster
|
||||
* :ref:`list-cmd` lookups using the pattern operator `::` have been made faster
|
||||
* Added additional error handling for `spotify` plugin.
|
||||
:bug:`4686`
|
||||
|
|
|
|||
Loading…
Reference in a new issue