From 686ea47449381b8b92991aced060a42dc52bffea Mon Sep 17 00:00:00 2001 From: rembo10 Date: Sun, 6 Apr 2014 13:08:39 -0700 Subject: [PATCH] Slightly improved re matching --- headphones/helpers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/headphones/helpers.py b/headphones/helpers.py index 29f23aeb..12642833 100644 --- a/headphones/helpers.py +++ b/headphones/helpers.py @@ -294,6 +294,8 @@ def expand_subfolders(f): def extract_data(s): + s = s.replace('_', ' ') + #headphones default format pattern = re.compile(r'(?P.*?)\s\-\s(?P.*?)\s\[(?P.*?)\]', re.VERBOSE) match = pattern.match(s) @@ -314,8 +316,8 @@ def extract_data(s): return (name, album, year) #Gonna take a guess on this one - might be enough to search on mb - # TODO: add in a bunch of re pattern matches - pat = re.compile(r"\s*(?P[^:]+)\s*-(?P.*?)\s*$") + pat = re.compile(r"(?P.*?)\s*-\s*(?P[^\[(-]*)") + match = pat.match(s) if match: name = match.group("name")