From 97be0db3d14d00f2af89e7f0b8990815c42c3eba Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Sat, 19 Oct 2024 18:51:41 +0200 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20de=20la=20d=C3=A9tection=20?= =?UTF-8?q?des=20cat=C3=A9gories=20(avec=20accents)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../import_tasks/custom_extractors/arachnee.py | 14 ++++++++------ src/agenda_culturel/models.py | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/agenda_culturel/import_tasks/custom_extractors/arachnee.py b/src/agenda_culturel/import_tasks/custom_extractors/arachnee.py index dccb21c..12b56c6 100644 --- a/src/agenda_culturel/import_tasks/custom_extractors/arachnee.py +++ b/src/agenda_culturel/import_tasks/custom_extractors/arachnee.py @@ -66,16 +66,18 @@ class CExtractor(TwoStepsExtractorNoPause): description = None category = soup.select_one(".event_category").text + first_cat = Extractor.remove_accents(category.split(",")[0].lower()) + print(first_cat) tags = [] - if category in ["Grand Spectacle"]: + if first_cat in ["grand spectacle"]: category = "Danse" - elif category in ["Théâtre"]: - category = "Théâtre" - elif category in ["Chanson française", "Musique du monde", "Pop / Rock", "Rap, RnB", "Raggae", "Variété"]: + elif first_cat in ["theatre", "humour / one man show"]: + category = "Theatre" + elif first_cat in ["chanson francaise", "musique du monde", "pop / rock", "rap", "rnb", "raggae", "variete"]: category = "Concert" - elif category in ["Comédie Musicale", "Humour / One Man Show", "Spectacle équestre"]: + elif first_cat in ["comedie musicale", "humour / one man show", "spectacle equestre"]: category = "Art du spectacle" - elif category in ["Spectacle pour enfant"]: + elif first_cat in ["spectacle pour enfant"]: tags = ["jeune public"] category = None else: diff --git a/src/agenda_culturel/models.py b/src/agenda_culturel/models.py index 9e610e5..09d11f2 100644 --- a/src/agenda_culturel/models.py +++ b/src/agenda_culturel/models.py @@ -738,7 +738,7 @@ class Event(models.Model): if "category" in event_structure and event_structure["category"] is not None: try: event_structure["category"] = Category.objects.get( - name=event_structure["category"] + name__unaccent__icontains=remove_accents(event_structure["category"].lower()) ) except Category.DoesNotExist: event_structure["category"] = Category.get_default_category()