Refactored some regular expressions. Added changelog entry

Some more changes to the regular expressions in the "PATTERNS" list.
Also allow "_" as a separator, where only "-" was allowed.
Replaced similar regexps containing different combinations of \s, "-", "."
with a single regexp using a set of characters [\s.\-_].
This commit is contained in:
Vrihub 2017-12-21 14:47:41 +01:00
parent 7132ad094b
commit 84cf3361ce
2 changed files with 8 additions and 12 deletions

View file

@ -28,18 +28,13 @@ import six
# Filename field extraction patterns.
PATTERNS = [
# Useful patterns.
r'^(?P<artist>.+)-(?P<title>.+)-(?P<tag>.*)$',
r'^(?P<track>\d+)\s*-(?P<artist>.+)-(?P<title>.+)-(?P<tag>.*)$',
r'^(?P<track>\d+)\s(?P<artist>.+)-(?P<title>.+)-(?P<tag>.*)$',
r'^(?P<artist>.+)-(?P<title>.+)$',
r'^(?P<track>\d+)\.\s*(?P<artist>.+)-(?P<title>.+)$',
r'^(?P<track>\d+)\s*-\s*(?P<artist>.+)-(?P<title>.+)$',
r'^(?P<track>\d+)\s*-(?P<artist>.+)-(?P<title>.+)$',
r'^(?P<track>\d+)\s(?P<artist>.+)-(?P<title>.+)$',
r'^(?P<artist>.+)[\-_](?P<title>.+)[\-_](?P<tag>.*)$',
r'^(?P<track>\d+)[\s.\-_]+(?P<artist>.+)[\-_](?P<title>.+)[\-_](?P<tag>.*)$',
r'^(?P<artist>.+)[\-_](?P<title>.+)$',
r'^(?P<track>\d+)[\s.\-_]+(?P<artist>.+)[\-_](?P<title>.+)$',
r'^(?P<title>.+)$',
r'^(?P<track>\d+)\.\s*(?P<title>.+)$',
r'^(?P<track>\d+)\s*-\s*(?P<title>.+)$',
r'^(?P<track>\d+)\s(?P<title>.+)$',
r'^(?P<track>\d+)[\s.\-_]+(?P<title>.+)$',
r'^(?P<track>\d+)\s+(?P<title>.+)$',
r'^(?P<title>.+) by (?P<artist>.+)$',
r'^(?P<track>\d+).*$',
]
@ -47,7 +42,6 @@ PATTERNS = [
# Titles considered "empty" and in need of replacement.
BAD_TITLE_PATTERNS = [
r'^$',
r'\d+?\s?-?\s*track\s*\d+',
]

View file

@ -80,6 +80,8 @@ Fixes:
"Edit Candidates" option is used. :bug:`2734`
* Fix a crash when numeric metadata fields contain just a minus or plus sign
with no following numbers. Thanks to :user:`eigengrau`. :bug:`2741`
* :doc:`/plugins/fromfilename`: Allow file names such as "01.mp3" to extract the track number.
Also allow "_" as a separator. Refactor some regular expressions. :bug:`2738`
For developers: