From 6f571c82d4928812039b5305170c086f2fe5e27c Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 2 Aug 2021 10:16:24 +0700 Subject: [PATCH] handle acronyms in showname for tvmaze api call --- src/tvsort.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tvsort.py b/src/tvsort.py index 3873e8d..6a41d0b 100644 --- a/src/tvsort.py +++ b/src/tvsort.py @@ -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}\)?')