Photomat -> Fotomat

This commit is contained in:
Jean-Marie Favreau 2024-04-20 13:54:28 +02:00
parent aa878b8fb3
commit 44b6458d73
7 changed files with 43 additions and 11 deletions

View File

@ -1,3 +1,4 @@
*.json
*.html
*.ical
*.xml

View File

@ -28,14 +28,14 @@ from src.agenda_culturel.import_tasks.custom_extractors import *
if __name__ == "__main__":
u2e = URL2Events(SimpleDownloader(), LePhotomatExtractor())
u2e = URL2Events(SimpleDownloader(), LeFotomatExtractor())
url = "https://www.lefotomat.com/feed"
url_human = "https://www.lefotomat.com/"
try:
events = u2e.process(url, url_human, cache = "cache-lephotomat.xml", default_values = {"location": "Le Photomat'"}, published = True)
events = u2e.process(url, url_human, cache = "cache-lefotomat.xml", default_values = {"location": "Le Fotomat'"}, published = True)
exportfile = "events-lephotomat.json"
exportfile = "events-lefotomat.json"
print("Saving events to file {}".format(exportfile))
with open(exportfile, "w") as f:
json.dump(events, f, indent=4, default=str)

View File

@ -105,8 +105,8 @@ def run_recurrent_import(self, pk):
extractor = LaCoopeExtractor()
elif rimport.processor == RecurrentImport.PROCESSOR.LACOMEDIE:
extractor = LaComedieExtractor()
elif rimport.processor == RecurrentImport.PROCESSOR.LEPHOTOMAT:
extractor = LePhotomatExtractor()
elif rimport.processor == RecurrentImport.PROCESSOR.LEFOTOMAT:
extractor = LeFotomatExtractor()
else:
extractor = None

View File

@ -130,13 +130,13 @@ class LaComedieExtractor(TwoStepsExtractor):
# A class dedicated to get events from Le Photomat'
# A class dedicated to get events from Le Fotomat'
# URL: https://www.lefotomat.com/
class LePhotomatExtractor(TwoStepsExtractor):
class LeFotomatExtractor(TwoStepsExtractor):
nom_lieu = "Le Photomat'"
nom_lieu = "Le Fotomat'"
def category_photomat2agenda(self, category):
def category_fotomat2agenda(self, category):
if not category:
return None
mapping = { "Concerts": "Concert"}
@ -157,7 +157,7 @@ class LePhotomatExtractor(TwoStepsExtractor):
title = e.find("title").contents[0]
self.add_event_title(e_url, title)
category = self.category_photomat2agenda(e.find("category").contents[0])
category = self.category_fotomat2agenda(e.find("category").contents[0])
if category:
self.add_event_category(e_url, category)

View File

@ -0,0 +1,13 @@
# Generated by Django 4.2.7 on 2024-04-20 11:53
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('agenda_culturel', '0051_alter_recurrentimport_processor'),
]
operations = [
]

View File

@ -0,0 +1,18 @@
# Generated by Django 4.2.7 on 2024-04-20 11:53
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('agenda_culturel', '0052_auto_20240420_1353'),
]
operations = [
migrations.AlterField(
model_name='recurrentimport',
name='processor',
field=models.CharField(choices=[('ical', 'ical'), ('icalnobusy', 'ical no busy'), ('icalnovc', 'ical no VC'), ('lacoope', 'lacoope.org'), ('lacomedie', 'la comédie'), ('lefotomat', 'le fotomat')], default='ical', max_length=20, verbose_name='Processor'),
),
]

View File

@ -759,7 +759,7 @@ class RecurrentImport(models.Model):
ICALNOVC = "icalnovc", _("ical no VC")
LACOOPE = "lacoope", _('lacoope.org')
LACOMEDIE = "lacomedie", _('la comédie')
LEPHOTOMAT = "lephotomat", _('le photomat')
LEFOTOMAT = "lefotomat", _('le fotomat')
class DOWNLOADER(models.TextChoices):
SIMPLE = "simple", _("simple")