On produit un fichier json permettant l'import
This commit is contained in:
parent
e8712bd64c
commit
39c8978a49
@ -11,7 +11,7 @@ from selenium.webdriver.chrome.service import Service
|
|||||||
from selenium.webdriver.chrome.options import Options
|
from selenium.webdriver.chrome.options import Options
|
||||||
import icalendar
|
import icalendar
|
||||||
from datetime import datetime, date
|
from datetime import datetime, date
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ class ICALExtractor(Extractor):
|
|||||||
|
|
||||||
location = self.get_item_from_vevent(event, "LOCATION")
|
location = self.get_item_from_vevent(event, "LOCATION")
|
||||||
if location is None:
|
if location is None:
|
||||||
location = Zself.default_value_if_exists(default_values, "location")
|
location = self.default_value_if_exists(default_values, "location")
|
||||||
|
|
||||||
description = self.get_item_from_vevent(event, "DESCRIPTION")
|
description = self.get_item_from_vevent(event, "DESCRIPTION")
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ class URL2Events:
|
|||||||
self.downloader = downloader
|
self.downloader = downloader
|
||||||
self.extractor = extractor
|
self.extractor = extractor
|
||||||
|
|
||||||
def process(self, url, url_human = None, cache = None, default_values = None):
|
def process(self, url, url_human = None, cache = None, default_values = None, published = False):
|
||||||
|
|
||||||
if cache and os.path.exists(cache):
|
if cache and os.path.exists(cache):
|
||||||
print("Loading cache ({})".format(cache))
|
print("Loading cache ({})".format(cache))
|
||||||
@ -213,7 +213,7 @@ class URL2Events:
|
|||||||
with open(cache, "w") as text_file:
|
with open(cache, "w") as text_file:
|
||||||
text_file.write(content)
|
text_file.write(content)
|
||||||
|
|
||||||
return self.extractor.extract(content, url, url_human, default_values)
|
return self.extractor.extract(content, url, url_human, default_values, published)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
@ -224,4 +224,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
events = u2e.process(url, url_human, cache = "cache-augustes.ical", default_values = {"category": "Autre", "location": "Café lecture les Augustes"}, published = True)
|
events = u2e.process(url, url_human, cache = "cache-augustes.ical", default_values = {"category": "Autre", "location": "Café lecture les Augustes"}, published = True)
|
||||||
|
|
||||||
#print(events)
|
exportfile = "events-augustes.json"
|
||||||
|
print("Saving events to file {}".format(exportfile))
|
||||||
|
with open(exportfile, "w") as f:
|
||||||
|
json.dump(events, f, indent=4, default=str)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user