From 2feb6219f7384d2c263b71be621dd4e206856b92 Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Sat, 12 Oct 2024 19:30:20 +0200 Subject: [PATCH] feat: handling various timeslot descriptions --- .../import_tasks/custom_extractors/acolab.py | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/agenda_culturel/import_tasks/custom_extractors/acolab.py b/src/agenda_culturel/import_tasks/custom_extractors/acolab.py index f132cdc..5466b38 100644 --- a/src/agenda_culturel/import_tasks/custom_extractors/acolab.py +++ b/src/agenda_culturel/import_tasks/custom_extractors/acolab.py @@ -63,9 +63,14 @@ class CExtractor(Extractor): if not date is None and is_open: # we reach a new day result.append((date, tstart, tend)) - date = day - tstart = None - tend = None + if isinstance(day, tuple): + date = day[0] + tstart = day[1] + tend = day[2] + else: + date = day + tstart = None + tend = None is_open = False continue elif not is_open: @@ -79,8 +84,14 @@ class CExtractor(Extractor): hours = CExtractor.find_hours(e) if not hours is None: # we found hours - tstart = hours[0] - tend = hours[1] + if tstart is None: + tstart = hours[0] + else: + tstart = min(tstart, hours[0]) + if tend is None: + tend = hours[1] + else: + tend = max(tend, hours[1]) continue if CExtractor.is_canceled(e):