From 8f76a16e5a22128f7171ce5a9f583bc4e368de79 Mon Sep 17 00:00:00 2001 From: Cyril NOVEL <5690282+cnovel@users.noreply.github.com> Date: Tue, 28 Jul 2026 15:47:32 +0200 Subject: [PATCH] Support all EBRA websites Better formatting --- gen_website.py | 52 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/gen_website.py b/gen_website.py index 90491f9..d8566ce 100644 --- a/gen_website.py +++ b/gen_website.py @@ -1,18 +1,30 @@ -import json import locale -import paramiko import os from datetime import datetime -from gen_feed import generate_feed + +import paramiko from dotenv import load_dotenv +from gen_feed import generate_feed + + def get_publisher(link): - if "ledauphine.com" in link: - return "Le Dauphiné Libéré" - if "bienpublic.com" in link: - return "Le Bien Public" - if "leprogres.fr" in link: - return "Le Progrès" + publishers = { + "ledauphine.com": "Le Dauphiné Libéré", + "bienpublic.com": "Le Bien Public", + "leprogres.fr": "Le Progrès", + "lalsace.fr": "L'Alsace", + "dna.fr": "Dernières Nouvelles d'Alsace", + "estrepublicain.fr": "L'Est Républicain", + "lejsl.com": "Journal de Saône-et-Loire", + "republicain-lorrain.fr": "Le Républicain Lorrain", + "vosgesmatin.fr": "Vosges Matin", + } + + for k,v in publishers.items(): + if k in link: + return v + return "" @@ -44,29 +56,31 @@ def generate_web(): towns = [] print("Getting articles for each link...") for link in urls: - town_id = link.rsplit('/', 1)[-1] + town_id = link.rsplit("/", 1)[-1] town_xml = town_id + ".xml" town_rss = website + "/" + town_xml if not generate_feed(link, town_rss, town_xml): print(f"Failed to generate feed for {town_id}") return False towns.append((town_id, town_rss, get_publisher(link), town_xml)) - + print("Updating HTML template...") - with open("template.html", 'r', encoding="utf-8") as template: + with open("template.html", "r", encoding="utf-8") as template: data = template.read() - + li = "" for town in towns: li += f'