fromfilename: fix #460: crash w/ no capture groups

This commit is contained in:
Adrian Sampson 2014-01-30 08:19:16 -08:00
parent a3c1b15198
commit 456c8a7f01
2 changed files with 6 additions and 1 deletions

View file

@ -73,7 +73,10 @@ def all_matches(names, pattern):
matches = {}
for item, name in names.items():
m = re.match(pattern, name, re.IGNORECASE)
if m:
if m and m.groupdict():
# Only yield a match when the regex applies *and* has
# capture groups. Otherwise, no information can be extracted
# from the filename.
matches[item] = m.groupdict()
else:
return None

View file

@ -49,6 +49,8 @@ Other little fixes:
* The importer now uses the album artist field when guessing existing
metadata for albums (rather than just the track artist field). Thanks to
geigerzaehler.
* :doc:`/plugins/fromfilename`: Fix a crash when a filename contained only a
track number (e.g., ``02.mp3``).
1.3.2 (December 22, 2013)