From 3718a745b24e1bbd5f0da3db9d48aa0aca5b5ca3 Mon Sep 17 00:00:00 2001 From: tfa Date: Wed, 7 Sep 2022 15:17:35 +0200 Subject: [PATCH] Ajout liste exclusion + logs --- chef_mou.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/chef_mou.py b/chef_mou.py index b23333d..22ba2cc 100644 --- a/chef_mou.py +++ b/chef_mou.py @@ -11,6 +11,7 @@ from difflib import SequenceMatcher from heapq import nlargest as _nlargest class ChefMou(Plugin): + listRemove = ["", "Souba", "Basse", "Trombone", "Trompette", "Sax Mib", "Clarinette", "Midi", "Original", "Enregistrement", "Paroles", "Commentaire"] async def start(self) -> None: self.on_external_config_update() @@ -56,6 +57,7 @@ class ChefMou(Plugin): """ ) else: + self.log.info("Commande : " + pattern) if pattern == "morceau": soup = await self.get_site_content() s = soup.findAll('th', background='/fond3.gif') @@ -74,11 +76,14 @@ class ChefMou(Plugin): return soup = await self.get_site_content() # Récuperer liste morceaux - s = soup.select('th', background='/fond3.gif') + #s = soup.select('th', background='/fond3.gif') + s = soup.select('th') # Object bts en str parsedList=[] originalList=[] for ts in s: + if ts.text in self.listRemove : + continue fullTitre = ts.text #Supression des () parsedList.append(re.sub("[\(\[].*?[\)\]]", "", fullTitre)) @@ -89,6 +94,8 @@ class ChefMou(Plugin): idxTitre = self.get_close_matches_indexes(chunks[2], parsedList, cutoff=0.4) # Si trouvé le chercher sinon erreur if len(idxTitre) > 0 : + for el in idxTitre : + self.log.info(parsedList[el] + ': ' + str(SequenceMatcher(None, chunks[2], parsedList[el]).ratio())) #Et on recherche dans la liste originale avec le titre original s = soup.find('th', string=originalList[idxTitre[0]]) t = s.parent.findAll('a')