Compare commits
2 Commits
94a51fcaf8
...
3718a745b2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3718a745b2 | ||
|
|
df382d7f53 |
13
chef_mou.py
13
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,10 +94,12 @@ 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')
|
||||
idx = 9
|
||||
idx = 25
|
||||
if chunks[1].lower() == "souba" or chunks[1].lower() == "soubassophone" or chunks[1].lower() == "sb":
|
||||
idx = 0
|
||||
elif chunks[1].lower() == "basse" or chunks[1].lower() == "bs" :
|
||||
@@ -112,7 +119,7 @@ class ChefMou(Plugin):
|
||||
try :
|
||||
await evt.respond("["+originalList[idxTitre[0]]+ " " + chunks[1]+"]"+"(<https://partoches.pustule.org"+t[idx].get("href")+">)")
|
||||
except IndexError:
|
||||
await evt.respond("Le morceau "+ strTitre[0] + " existe mais pas ta partoche")
|
||||
await evt.respond("Le morceau "+ originalList[idxTitre[0]] + " existe mais pas ta partoche")
|
||||
|
||||
else:
|
||||
await evt.respond("Morceau non trouvé")
|
||||
|
||||
Reference in New Issue
Block a user