diff --git a/beetsplug/fromfilename.py b/beetsplug/fromfilename.py index be7fee23af..38a0a628b4 100644 --- a/beetsplug/fromfilename.py +++ b/beetsplug/fromfilename.py @@ -32,7 +32,7 @@ r"^(?P.+?)\s*-\s*(?P.+?)(\s*-\s*(?P<tag>.*))?$", r"^(?P<track>\d+)\.?[\s_-]+(?P<title>.+)$", r"^(?P<title>.+) by (?P<artist>.+)$", - r"^(?P<track>\d+).*$", + r"^(track ?)?(?P<track>\d+).*$", r"^(?P<title>.+)$", ] diff --git a/docs/changelog.rst b/docs/changelog.rst index 17e192aaa5..90db3d7c2a 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -24,6 +24,8 @@ New features Archives are preserved if any file in the archive was not imported (e.g. skipped as a duplicate, or the import was aborted), and in non-move import modes. +- :doc:`plugins/fromfilename`: Support ``track`` prefix when parsing the track + number from the filename (e.g., ``track01.m4a``). .. Bug fixes diff --git a/test/plugins/test_fromfilename.py b/test/plugins/test_fromfilename.py index f13e88aea2..35c1812d4c 100644 --- a/test/plugins/test_fromfilename.py +++ b/test/plugins/test_fromfilename.py @@ -70,6 +70,10 @@ def __init__(self, items): ("/tmp/Song One.m4a", 0, "", "Song One"), ("/tmp/Song Two.m4a", 0, "", "Song Two"), ), + ( + ("/tmp/track01.m4a", 1, "", "track01"), + ("/tmp/track 2.m4a", 2, "", "track 2"), + ), ], ) def test_fromfilename(song1, song2):