50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
#!/usr/bin/python
|
|
|
|
import rfeed
|
|
import datetime
|
|
import os
|
|
|
|
MAXFILEAGE_IN_DAYS = 14
|
|
|
|
|
|
items = []
|
|
for file in os.listdir("files"):
|
|
|
|
year, month, day, hour, minute, md5 = file[:-3].split("-")
|
|
|
|
year = int(year)
|
|
month = int(month)
|
|
day = int(month)
|
|
hour = int(hour)
|
|
minute = int(minute)
|
|
|
|
# remove old file
|
|
# if datetime.datetime(year, month, day, hour, minute) \
|
|
# + datetime.timedelta(MAXFILEAGE_IN_DAYS) < datetime.datetime.now():
|
|
# print(f"{file} identified as old - DELETING")
|
|
# print(datetime.datetime(year, month, day, hour, minute))
|
|
# print(datetime.timedelta(MAXFILEAGE_IN_DAYS))
|
|
# print(datetime.datetime.now())
|
|
# #os.remove(f"file/{file}")
|
|
# continue
|
|
|
|
items.append(rfeed.Item(
|
|
title=f"Regionalnachrichten {day}.{month}.{year} {hour}:{minute}",
|
|
link = f"https://dukun.de/xox/hgwnews/files/{file}",
|
|
description = f"{md5}",
|
|
author = "NDR1 Radio MV Studio Greifswald",
|
|
guid = rfeed.Guid(md5),
|
|
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())
|