src: added rss

This commit is contained in:
tiyn 2022-07-31 00:22:32 +02:00
parent 61aa869b93
commit 65c5ff76bc
2 changed files with 26 additions and 1 deletions

View File

@ -55,6 +55,8 @@ def entry(ident):
abort(404)
@app.route("/feed")
@app.route("/rss")
@app.route("/feed.xml")
@app.route("/rss.xml")
def feed():

View File

@ -1,3 +1,4 @@
import config
from database import Database
db = Database()
@ -113,4 +114,26 @@ def get_rss_string():
Returns:
string: rss-string of everything that is in the ENTRY_DIR.
"""
return ""
content_string = ""
entries = db.get_entries()
if entries is None:
return ""
entries.reverse()
for entry in entries:
ident = entry[0]
title = entry[1]
year = entry[2]
text = entry[3]
rating = entry[4]
username = db.get_user_by_id(entry[5])[1]
reviewed = entry[6]
content_string += "<item>\n"
content_string += "<title>" + title + "(" + year + ") " + str(rating) + "/100 </title>\n"
content_string += "<guid>" + config.WEBSITE + \
"/index.html#" + str(ident) + "</guid>\n"
content_string += "<pubDate>" + reviewed + "</pubDate>\n"
content_string += "<description>"
content_string += text
content_string += "</description>\n"
content_string += "</item>\n"
return content_string