On gère mieux les urls sans événement

This commit is contained in:
Jean-Marie Favreau 2024-09-04 12:28:11 +02:00
parent 9bb3373f99
commit 1c812a3d65
3 changed files with 11 additions and 7 deletions

View File

@ -243,14 +243,17 @@ def import_events_from_url(self, url, cat):
url, published=False, default_values=values url, published=False, default_values=values
) )
# convert it to json if events:
json_events = json.dumps(events, default=str) # convert it to json
json_events = json.dumps(events, default=str)
# import events (from json) # import events (from json)
success, error_message = importer.import_events(json_events) success, error_message = importer.import_events(json_events)
# finally, close task # finally, close task
close_import_task(self.request.id, success, error_message, importer) close_import_task(self.request.id, success, error_message, importer)
else:
close_import_task(self.request.id, False, "Cannot find any event", importer)
except Exception as e: except Exception as e:
logger.error(e) logger.error(e)
close_import_task(self.request.id, False, e, importer) close_import_task(self.request.id, False, e, importer)

View File

@ -264,6 +264,8 @@ class FacebookEventExtractor(Extractor):
event["category"] = default_values["category"] event["category"] = default_values["category"]
self.add_event(**event) self.add_event(**event)
return self.get_structure() return self.get_structure()
else:
logger.warning("cannot find any event in page")
return None return None

View File

@ -66,5 +66,4 @@ class GoogleCalendarLinkEventExtractor(Extractor):
break break
logger.warning("ça marche")
return self.get_structure() return self.get_structure()