diff --git a/bazarr/api/system/searches.py b/bazarr/api/system/searches.py index 755711446..4425251fa 100644 --- a/bazarr/api/system/searches.py +++ b/bazarr/api/system/searches.py @@ -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