From b6e7e0b81773240092ce5529aa6a0aba8c6c44f2 Mon Sep 17 00:00:00 2001 From: colin-scott Date: Thu, 26 Sep 2013 12:26:15 -0700 Subject: [PATCH] Support singleton filenames. Previously, track ids were assumed to be part of every filename. This assumption does not hold for singleton tracks. --- beetsplug/fromfilename.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/beetsplug/fromfilename.py b/beetsplug/fromfilename.py index 2d17e3394..f326870c7 100644 --- a/beetsplug/fromfilename.py +++ b/beetsplug/fromfilename.py @@ -27,15 +27,19 @@ PATTERNS = [ r'^\d+$', # Useful patterns. + r'^(?P.+)-(?P.+)-(?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<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<title>.+) by (?P<artist>.+)$', ] # Titles considered "empty" and in need of replacement. @@ -122,7 +126,7 @@ def apply_matches(d): for item in d: if bad_title(item.title): item.title = unicode(d[item][title_field]) - if item.track == 0: + if 'track' in d[item] and item.track == 0: item.track = int(d[item]['track'])