diff --git a/src/agenda_culturel/import_tasks/generic_extractors.py b/src/agenda_culturel/import_tasks/generic_extractors.py index 14acc44..d20893a 100644 --- a/src/agenda_culturel/import_tasks/generic_extractors.py +++ b/src/agenda_culturel/import_tasks/generic_extractors.py @@ -102,20 +102,22 @@ class TwoStepsExtractor(Extractor): self.event_urls.append(url) return True - def add_event_start_day(self, url, start_day): + def add_event_property(self, url, key, value): if url not in self.event_properties: self.event_properties[url] = {} - self.event_properties[url]["start_day"] = start_day + self.event_properties[url][key] = value + + def add_event_url_human(self, url, url_human): + self.add_event_property(url, "url_human", url_human) + + def add_event_start_day(self, url, start_day): + self.add_event_property(url, "start_day", start_day) def add_event_start_time(self, url, start_time): - if url not in self.event_properties: - self.event_properties[url] = {} - self.event_properties[url]["start_time"] = start_time + self.add_event_property(url, "start_time", start_time) def add_event_title(self, url, title): - if url not in self.event_properties: - self.event_properties[url] = {} - self.event_properties[url]["title"] = title + self.add_event_property(url, "title", title) def add_event_tag(self, url, tag): if url not in self.event_properties: @@ -125,14 +127,10 @@ class TwoStepsExtractor(Extractor): self.event_properties[url]["tags"].append(tag) def add_event_category(self, url, cat): - if url not in self.event_properties: - self.event_properties[url] = {} - self.event_properties[url]["category"] = cat + self.add_event_property(url, "category", cat) def add_event_location(self, url, loc): - if url not in self.event_properties: - self.event_properties[url] = {} - self.event_properties[url]["location"] = loc + self.add_event_property(url, "location", loc) def add_event_with_props( self, @@ -168,6 +166,8 @@ class TwoStepsExtractor(Extractor): category = self.event_properties[event_url]["category"] if "location" in self.event_properties[event_url]: location = self.event_properties[event_url]["location"] + if "url_human" in self.event_properties[event_url]: + url_human = self.event_properties[event_url]["url_human"] self.add_event( default_values, @@ -221,6 +221,7 @@ class TwoStepsExtractor(Extractor): self.clear_events() self.url = url + self.url_human = url_human self.event_urls = [] self.event_properties.clear()