diff --git a/cps/db.py b/cps/db.py index c908e1f2..a22215b0 100644 --- a/cps/db.py +++ b/cps/db.py @@ -449,7 +449,7 @@ class CalibreDB(threading.Thread): match = title_pat.search(title) if match: prep = match.group(1) - title = title.replace(prep, '') + ', ' + prep + title = title[len(prep):] + ', ' + prep return title.strip() conn = conn or self.session.connection().connection.connection diff --git a/cps/templates/layout.html b/cps/templates/layout.html index 170535c9..4e529eea 100644 --- a/cps/templates/layout.html +++ b/cps/templates/layout.html @@ -228,7 +228,9 @@ $(document).ready(function() { var inp = $('#query').first() var val = inp.val() - inp.val('').blur().focus().val(val) + if (val.length) { + inp.val('').blur().focus().val(val) + } }); });