Skip to content

Commit

Permalink
Handle more exceptions in title tag normalization code - 52
Browse files Browse the repository at this point in the history
  • Loading branch information
desbma committed Jan 28, 2018
1 parent 6404ea0 commit daa5027
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion amg/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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


Expand Down
6 changes: 5 additions & 1 deletion tests/test_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit daa5027

Please sign in to comment.