Füge eine Methode zur Formatierung von Datumsangaben im RFC 2822 Format hinzu und aktualisiere die RSS-Feed-Erstellung zur Verwendung dieser Methode für lastBuildDate und pubDate.
This commit is contained in:
@ -205,6 +205,19 @@ class LocalPodcastGenerator:
|
||||
# Verwende quote_plus für bessere URL-Sicherheit (ersetzt Leerzeichen mit +)
|
||||
return urllib.parse.quote(filename, safe='')
|
||||
|
||||
def format_rfc2822_date(self, dt):
|
||||
"""Formatiert ein Datum im RFC 2822 Format für RSS."""
|
||||
# RFC 2822 Format: "Wed, 02 Oct 2002 08:00:00 EST"
|
||||
# Verwende englische Wochentag/Monat-Namen und GMT
|
||||
weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
||||
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
|
||||
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
||||
|
||||
weekday = weekdays[dt.weekday()]
|
||||
month = months[dt.month - 1]
|
||||
|
||||
return f"{weekday}, {dt.day:02d} {month} {dt.year} {dt.hour:02d}:{dt.minute:02d}:{dt.second:02d} GMT"
|
||||
|
||||
def format_duration(self, seconds):
|
||||
"""Formatiert die Dauer in HH:MM:SS Format."""
|
||||
if not seconds:
|
||||
@ -264,11 +277,11 @@ Ich spezialisiere mich auf House Music, die mehr als nur Beats bietet – sie er
|
||||
|
||||
# Wichtig: lastBuildDate für bessere Erkennung von Updates (RFC 2822 konform)
|
||||
last_build = ET.SubElement(channel, "lastBuildDate")
|
||||
last_build.text = datetime.now().strftime('%a, %d %b %Y %H:%M:%S +0000')
|
||||
last_build.text = self.format_rfc2822_date(datetime.now())
|
||||
|
||||
# pubDate für den Channel (RFC 2822 konform)
|
||||
channel_pub_date = ET.SubElement(channel, "pubDate")
|
||||
channel_pub_date.text = datetime.now().strftime('%a, %d %b %Y %H:%M:%S +0000')
|
||||
channel_pub_date.text = self.format_rfc2822_date(datetime.now())
|
||||
|
||||
# Generator Info
|
||||
generator = ET.SubElement(channel, "generator")
|
||||
@ -354,8 +367,8 @@ Ich spezialisiere mich auf House Music, die mehr als nur Beats bietet – sie er
|
||||
|
||||
# Veröffentlichungsdatum (RFC 2822 konform)
|
||||
item_pubdate = ET.SubElement(item, "pubDate")
|
||||
# RFC 2822 Format mit korrekter Timezone
|
||||
pub_date_formatted = metadata['pub_date'].strftime('%a, %d %b %Y %H:%M:%S +0000')
|
||||
# RFC 2822 Format mit korrekter Formatierung
|
||||
pub_date_formatted = self.format_rfc2822_date(metadata['pub_date'])
|
||||
item_pubdate.text = pub_date_formatted
|
||||
|
||||
# Audio-Enclosure (das ist die eigentliche Audio-URL)
|
||||
|
Reference in New Issue
Block a user