better showname cleaning and encoding for API search call

This commit is contained in:
simon 2021-05-17 11:34:26 +07:00
parent cbc2c31007
commit 4aeddfc1de
1 changed files with 2 additions and 2 deletions

View File

@ -72,11 +72,11 @@ class Static():
def showname_encoder(showname):
""" encodes showname for best possible match """
# tvmaze doesn't like years in showname
showname = showname.strip().rstrip('.')
showname = showname.strip().rstrip('-').rstrip('.').strip()
year_pattern = re.compile(r'\(?[0-9]{4}\)?')
year = year_pattern.findall(showname)
if year:
showname = showname.rstrip(str(year))
showname = showname.rstrip(str(year)).strip()
encoded = showname.replace(" ", "%20")
encoded = encoded.replace(".", "%20").replace("'", "%20")
return encoded