mirror of https://github.com/morpheus65535/bazarr
Sorted search results
Used Levenshtein distance to sort by closest match
This commit is contained in:
parent
86b889d3b6
commit
d276f9be5e
|
@ -8,6 +8,8 @@ from app.database import TableShows, TableMovies, database, select
|
|||
|
||||
from ..utils import authenticate
|
||||
|
||||
import Levenshtein
|
||||
|
||||
api_ns_system_searches = Namespace('System Searches', description='Search for series or movies by name')
|
||||
|
||||
|
||||
|
@ -61,4 +63,7 @@ class Searches(Resource):
|
|||
|
||||
results.append(result)
|
||||
|
||||
# sort results by how closely they match the query
|
||||
results = sorted(results, key=lambda x: Levenshtein.distance(query, x['title']))
|
||||
|
||||
return results
|
||||
|
|
Loading…
Reference in New Issue