From daa502797a0e6831ec3ecc627847743ab31adb31 Mon Sep 17 00:00:00 2001 From: desbma Date: Sun, 28 Jan 2018 21:51:15 +0100 Subject: [PATCH] Handle more exceptions in title tag normalization code - 52 --- amg/tag.py | 7 ++++++- tests/test_tag.py | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/amg/tag.py b/amg/tag.py index b723001..6f9fbd1 100644 --- a/amg/tag.py +++ b/amg/tag.py @@ -82,7 +82,8 @@ def __init__(self, artist, album): expressions.append(w3) expressions.extend(("pre-orders available", "preorders available", "hd", "official", "pre-listening", "prelistening", "trollzorn", - "uncensored", "s/t")) + "uncensored", "s/t", + "transcending obscurity india")) # crappy label suffixes TODO how to handle that? year = datetime.datetime.today().year for y in range(year - 5, year + 1): expressions.append(str(y)) @@ -279,11 +280,15 @@ def cleanup(self, title, artist): return SimplePrefixCleaner.cleanup(self, title, artist) elif self.startslike(title, artist.replace(" ", "")): return SimplePrefixCleaner.cleanup(self, title, artist.replace(" ", "")) + elif self.startslike(title, artist.replace("and", "&")): + return SimplePrefixCleaner.cleanup(self, title, artist.replace("and", "&")) # detect and remove artist suffix elif self.endslike(title, artist): return SimpleSuffixCleaner.cleanup(self, title, artist) elif self.endslike(title, artist.replace(" ", "")): return SimpleSuffixCleaner.cleanup(self, title, artist.replace(" ", "")) + elif self.endslike(title, artist.replace("and", "&")): + return SimpleSuffixCleaner.cleanup(self, title, artist.replace("and", "&")) return title diff --git a/tests/test_tag.py b/tests/test_tag.py index db78621..daad328 100644 --- a/tests/test_tag.py +++ b/tests/test_tag.py @@ -421,7 +421,11 @@ def test_normalize_title_tag(self): ("Death Doom Metal - DRUID LORD \"House of Dripping Gore\"", "Druid Lord", "Grotesque Offerings", - "House of Dripping Gore")) + "House of Dripping Gore"), + ("DJINN & MISKATONIC (India) - Frost And Steel (Doom Metal) Transcending Obscurity India HD", + "Djinn and Miskatonic", + "Even Gods Must Die", + "Frost and Steel")) for source, artist, album, expected_result in references: with self.subTest(source=source, expected_result=expected_result, artist=artist, album=album):