Skip to content

Commit

Permalink
Handle more exceptions in title tag normalization code - 89
Browse files Browse the repository at this point in the history
  • Loading branch information
desbma committed Jul 16, 2020
1 parent 54cb68d commit c3733ce
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
12 changes: 9 additions & 3 deletions amg/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ def __init__(self, artist: str, album: str):
contains=("taken from", "out"),
execute_once=True))

# detect and remove 'a track of the upcoming xxx' suffix
self.registerCleaner(RegexSuffixCleaner("a track of upcoming ",
contains=("a track of upcoming"),
execute_once=True))

# detect and remove 'album: xxx track yy'
self.registerCleaner(RegexCleaner("(album: .+ )?track [0-9]+",
contains=("track",),
Expand Down Expand Up @@ -168,7 +173,7 @@ def __init__(self, artist: str, album: str):
expressions.append(" ".join((w1, rpart)).strip())
else:
expressions.append(w3)
expressions.extend(("full ep", "hd", "official", "pre-listening",
expressions.extend(("full ep", "full-length", "hd", "official", "pre-listening",
"pre-order now", "pre-orders available", "prelistening",
"preorders available", "s/t", "sw exclusive",
"trailer for the upcoming album",
Expand Down Expand Up @@ -524,8 +529,9 @@ class StartParenthesesCleaner(TitleCleanerBase):
def cleanup(self, title: str) -> str:
""" See TitleCleanerBase.cleanup. """
# detect and remove starting parenthesis expression
if title.startswith("(") and (title.find(")") != (len(title) - 1)):
return self.lclean(title[title.find(")") + 1:])
closing_pos = title.find(")")
if title.startswith("(") and (closing_pos != (len(title) - 1)) and (len(title[1:closing_pos]) > 1):
return self.lclean(title[closing_pos + 1:])
return title


Expand Down
12 changes: 12 additions & 0 deletions tests/normalize_title_tag.json
Original file line number Diff line number Diff line change
Expand Up @@ -772,5 +772,17 @@
"artist": "Hexenbrett",
"album": "Zweite Beschwörung: Ein Kind zu töten",
"result": "La Tumba de Los Muertos Vivientes"
},
{
"source": "SKELETAL Bitterness and Burning Hatred (Full-length) - Track \"Burning Hatred\"",
"artist": "Skeletal",
"album": "Bitterness and Burning Hatred",
"result": "Burning Hatred"
},
{
"source": "ATHANATHEOS - (R)evolution, Revelation - (A Track of Upcoming 2020 Death Metal Epos)",
"artist": "AthanaTheos",
"album": "Prophetic Era (Or How Yahveh Became the One)",
"result": "(R)evolution, Revelation"
}
]

0 comments on commit c3733ce

Please sign in to comment.