diff --git a/beets/library.py b/beets/library.py index d1125ff8b..1e46fe5ef 100644 --- a/beets/library.py +++ b/beets/library.py @@ -23,6 +23,7 @@ import unicodedata import time import re import six +import string from beets import logging from beets.mediafile import MediaFile, UnreadableFileError @@ -1456,7 +1457,7 @@ class DefaultTemplateFunctions(object): @staticmethod def tmpl_title(s): """Convert a string to title case.""" - return s.title() + return string.capwords(s) @staticmethod def tmpl_left(s, chars): diff --git a/docs/changelog.rst b/docs/changelog.rst index 61e244310..6033cdc9c 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -103,7 +103,9 @@ Fixes: Thanks to :user:`TaizoSimpson`. :bug:`3501` * Confusing typo when the convert plugin copies the art covers. :bug:`3063` - +* The ``%title`` template function now works correctly with apostrophes. + Thanks to :user:`GuilhermeHideki`. + :bug:`3033` .. _python-itunes: https://github.com/ocelma/python-itunes diff --git a/test/test_library.py b/test/test_library.py index c36e95a5e..e8cdb0530 100644 --- a/test/test_library.py +++ b/test/test_library.py @@ -589,6 +589,10 @@ class DestinationFunctionTest(_common.TestCase, PathFormattingMixin): self._setf(u'%title{$title}') self._assert_dest(b'/base/The Title') + def test_title_case_variable_aphostrophe(self): + self._setf(u'%title{I can\'t}') + self._assert_dest(b'/base/I Can\'t') + def test_asciify_variable(self): self._setf(u'%asciify{ab\xa2\xbdd}') self._assert_dest(b'/base/abC_ 1_2 d')