51 lines
1.4 KiB
Python
51 lines
1.4 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.split("-")
|
|
|
|
year = int(year)
|
|
month = int(month)
|
|
day = int(day)
|
|
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: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())
|