Skip to content
Snippets Groups Projects
Commit ea142937 authored by Virgile Gerecke's avatar Virgile Gerecke :metal:
Browse files

Added RSS/Atom generator

parent b30f55e9
No related merge requests found
anytree==2.4.3
six==1.11.0
feedgen==0.7.0
python-slugify==1.2.6
rss.py 0 → 100644
from feedgen.feed import FeedGenerator
from slugify import slugify
from json import load
import dateutil.parser
data = load(open('weather.json','r'))
def df(date):
dt = dateutil.parser.parse(date)
return dt.strftime("%d/%m/%Y à %Hh%M")
fg = FeedGenerator()
fg.id('https://support.unistra.fr/')
fg.title('Maintenance des services numériques')
fg.subtitle('Annonces de la Direction du Numérique')
fg.link(href='https://support.unistra.fr/#go-weather')
fg.language('fr')
fg.link(href='https://support.unistra.fr/atom.php', rel='self')
fg.author(name='Direction du Numérique', email='support@unistra.fr')
fg.logo('http://www.unistra.fr/fileadmin/templates/unistra/images/uds_ico.ico')
for item in data:
fe = fg.add_entry()
title=item['title']
fe.title(title)
fe.id(slugify(title))
content = "<p><b>Date de début : </b>{}</p><p><b>Date de fin : </b>{}</p>{}".format(df(item['start']), df(item['end']), item['content'])
fe.description(content)
fe.pubDate(item['start'])
rssfeed = fg.rss_str(pretty=True)
fg.rss_file('rss.xml')
atomfeed = fg.atom_str(pretty=True)
fg.atom_file('atom.xml')
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment