From 5ef68783a84d9045ce4e1f4fe95c68ce184a4d21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Tue, 18 Jul 2017 16:33:22 -0400 Subject: [PATCH] strip trailing and leading extra dashes those are introduced if non-word characters are found, and are ugly --- beetsplug/lyrics.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index 84f1bf6c0..8bd96c7cf 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -236,12 +236,13 @@ def slug(text): 2. shift everything to lowercase 3. strip whitespace 4. replace other non-word characters with dashes + 5. strip extra dashes This somewhat duplicates the :func:`Google.slugify` function but slugify is not as generic as this one, which can be reused elsewhere. """ - return re.sub(r'\W+', '-', unidecode(text).lower().strip()) + return re.sub(r'\W+', '-', unidecode(text).lower().strip()).strip('-') class Backend(object):