Compare commits
3 Commits
3718a745b2
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61676f2374 | ||
|
|
57d889340d | ||
|
|
48ed397bc8 |
10
chef_mou.py
10
chef_mou.py
@@ -44,7 +44,7 @@ class ChefMou(Plugin):
|
||||
|
||||
return BeautifulSoup(text.decode('iso-8859-1'), 'html.parser')
|
||||
|
||||
@command.new("chefmou")
|
||||
@command.new(aliases=["chefmou","chefmu","cm"])
|
||||
@command.argument("pattern", pass_raw=True, required=False)
|
||||
async def morceau(self, evt: MessageEvent, pattern: str) -> None:
|
||||
loop = asyncio.new_event_loop()
|
||||
@@ -63,7 +63,7 @@ class ChefMou(Plugin):
|
||||
s = soup.findAll('th', background='/fond3.gif')
|
||||
ps = random.choice(s)
|
||||
await evt.respond(ps.text)
|
||||
elif pattern.__contains__("partition"):
|
||||
elif pattern.__contains__("part"):
|
||||
chunks = pattern.split(None, 2)
|
||||
if len(chunks) != 3 :
|
||||
await evt.respond(
|
||||
@@ -86,16 +86,16 @@ class ChefMou(Plugin):
|
||||
continue
|
||||
fullTitre = ts.text
|
||||
#Supression des ()
|
||||
parsedList.append(re.sub("[\(\[].*?[\)\]]", "", fullTitre))
|
||||
parsedList.append(re.sub("[\(\[].*?[\)\]]", "", fullTitre).lower())
|
||||
#On garde une copie pour la recherche
|
||||
originalList.append(ts.text)
|
||||
|
||||
# Fonction qui retourne l'index du string le plus proche
|
||||
idxTitre = self.get_close_matches_indexes(chunks[2], parsedList, cutoff=0.4)
|
||||
idxTitre = self.get_close_matches_indexes(chunks[2].lower(), 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()))
|
||||
self.log.info(originalList[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')
|
||||
|
||||
Reference in New Issue
Block a user