46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
#!/usr/bin/python
|
|
|
|
import rfeed
|
|
import datetime
|
|
import os
|
|
|
|
MAXFILEAGE_IN_DAYS = 4
|
|
|
|
|
|
items = []
|
|
for file in os.listdir("files"):
|
|
|
|
year, month, day, hour, minute, md5 = file.split("-")
|
|
|
|
year = int(year)
|
|
month = int(month)
|
|
day = int(day)
|
|
hour = int(hour)
|
|
minute = int(minute)
|
|
|
|
# remove old files
|
|
if datetime.datetime.now() - datetime.datetime(year, month, day, hour, minute) > datetime.timedelta(MAXFILEAGE_IN_DAYS):
|
|
os.remove(f"files/{file}")
|
|
continue
|
|
|
|
items.append(rfeed.Item(
|
|
title=f"Regionalnachrichten {day:0>2d}.{month:0>2d}.{year} {hour:0>2d}:{minute:0>2d}",
|
|
link = "",
|
|
description = f"{md5}",
|
|
author = "NDR1 Radio MV Studio Greifswald",
|
|
guid = rfeed.Guid(md5),
|
|
enclosure = rfeed.Enclosure(url=f"https://dukun.de/xox/hgwnews/files/{file}", length=os.path.getsize(f"files/{file}"), type="audio/mpeg"),
|
|
pubDate = datetime.datetime(year, month, day, hour, minute)
|
|
))
|
|
|
|
feed = rfeed.Feed(
|
|
title = "NDR1 RadioMV Regionalnachrichten Greifswald",
|
|
link = "",
|
|
description = "",
|
|
language = "de-DE",
|
|
lastBuildDate = datetime.datetime.now(),
|
|
items = items)
|
|
|
|
with open("feed.xml", "w") as f:
|
|
f.write(feed.rss())
|