htdocs/automations/rss_feed.py
2025-01-28 15:26:47 +00:00

43 lines
1.4 KiB
Python

import root
import blogs
rss_feed_path = f"{root.path}/rss"
url = "https://deadvey.com"
images_path = f"{url}/images"
title = "DeaDvey's Blog"
blog_avatar_url = "{url}/images/pfp6.png"
description = "Linux, tech and film reviews"
with open(rss_feed_path, "w") as rss_file:
content = f'''<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>{title}</title>
<link>{url}</link>
<description>{description}</description>
<pubDate>{blogs.blogs_array[0][2]} +0000</pubDate>
<lastBuildDate>{blogs.blogs_array[0][2]} +0000</lastBuildDate>
<image>
<url>{blog_avatar_url}</url>
<title>{title}</title>
<link>{url}</link>
</image>
'''
for current_blog in range(len(blogs.blogs_array)-1,0,-1):
# Add images to feed item
images_div = ""
for i in blogs.blogs_array[current_blog][3]:
images_div += f'<![CDATA[<img src="{images_path}/{i}"/>]]>'
content += f'''
<item>
<title>{blogs.blogs_array[current_blog][0]}</title>
<link>https://deadvey.com/blog/{current_blog}.html</link>
<description>{blogs.blogs_array[current_blog][1]}{images_div}</description>
<pubDate>{blogs.blogs_array[current_blog][2]} +0000</pubDate>
</item>
'''
content += "</channel>\n\n</rss>"
rss_file.write(content)