handle acronyms in showname for tvmaze api call

This commit is contained in:
simon 2021-08-02 10:16:24 +07:00
parent e8d64536d3
commit 6f571c82d4
1 changed files with 7 additions and 0 deletions

View File

@ -71,6 +71,13 @@ class Static:
@staticmethod
def showname_encoder(showname):
""" encodes showname for best possible match """
# handle acronyms
acro_pattern = re.compile(r'[A-Z]{1}\.')
acronym_match = acro_pattern.findall(showname)
if acronym_match:
acronym = ''.join(acronym_match)
shortened = ''.join([i.strip('.') for i in acronym])
showname = showname.replace(acronym, shortened)
# tvmaze doesn't like years in showname
showname = showname.strip().rstrip('-').rstrip('.').strip()
year_pattern = re.compile(r'\(?[0-9]{4}\)?')