fix(backend): RSS validation

This commit is contained in:
Ewen 2024-05-14 08:39:21 +02:00
parent 6b1d9924be
commit 91881fa177
3 changed files with 5 additions and 5 deletions

View file

@ -59,7 +59,7 @@ def parse_page():
response.headers["Content-Type"] = "application/json"
return response
else:
rss_xml = render_template("rss.xml", feed=feed, build_date=datetime.now())
rss_xml = render_template("rss.xml", feed=feed, build_date=datetime.now().astimezone())
response = make_response(rss_xml)
response.headers["Content-Type"] = "application/rss+xml"
return response

View file

@ -12,7 +12,7 @@ class FeedItem:
self.link = link
self.author = author
if item_datetime:
self.item_datetime = item_datetime.isoformat()
self.item_datetime = item_datetime.strftime("%a, %d %b %Y %H:%M:%S %z")
else:
self.item_datetime = None
@ -74,7 +74,7 @@ def scrape(request, args):
title_class = {"class": args.get("titleClass")}
title = article.find(args.get("title"), title_class)
if title:
title = title.get_text()
title = title.get_text().strip()
content_tag = "p"
content_class = {}
@ -121,7 +121,7 @@ def scrape(request, args):
author=author
)
if item.title is not None:
if item.title is not None and item.title != "":
feed.items.append(item)
# Sort by datetime if any

View file

@ -5,7 +5,7 @@
<atom:link href="{{ request.url }}" rel="self" type="application/rss+xml"/>
<link>{{ request.url }}</link>
<description>A feed generated from {{ feed.url }} with Rudibridge</description>
<lastBuildDate>{{ build_date.strftime("%a, %d %b %Y %T") }} +0000</lastBuildDate>
<lastBuildDate>{{ build_date.strftime("%a, %d %b %Y %H:%M:%S %z") }}</lastBuildDate>
{% for item in feed.items %}
<item>
{% if item.title %}