From a6b1bb1bbc7fc60ed53ad3db36ad9191d0cc1d74 Mon Sep 17 00:00:00 2001 From: Tai Lee Date: Sat, 25 May 2013 14:05:03 +1000 Subject: [PATCH] Move articles to the front of Discogs artist names. --- beetsplug/discogs.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/beetsplug/discogs.py b/beetsplug/discogs.py index da415536b..ffb8b8045 100644 --- a/beetsplug/discogs.py +++ b/beetsplug/discogs.py @@ -112,8 +112,12 @@ class DiscogsPlugin(BeetsPlugin): for artist in artists: if not artist_id: artist_id = artist['id'] - # Strip disambiguation number from artist name. - bits.append(re.sub(r' \(\d+\)$', '', artist['name'])) + name = artist['name'] + # Strip disambiguation number. + name = re.sub(r' \(\d+\)$', '', name) + # Move articles to the front. + name = re.sub(r'^(.*?), (a|an|the)$', r'\2 \1', name, flags=re.I) + bits.append(name) if artist['join']: bits.append(artist['join']) artist = ' '.join(bits).replace(' ,', ',') or None