From d17b2b3a1799e541dc3c1f459616ada955b5c72f Mon Sep 17 00:00:00 2001 From: Manuel Weiser Date: Sat, 5 Jul 2025 21:18:46 +0200 Subject: [PATCH] =?UTF-8?q?F=C3=BCge=20eine=20Methode=20zur=20Formatierung?= =?UTF-8?q?=20von=20Datumsangaben=20im=20RFC=202822=20Format=20hinzu=20und?= =?UTF-8?q?=20aktualisiere=20die=20RSS-Feed-Erstellung=20zur=20Verwendung?= =?UTF-8?q?=20dieser=20Methode=20f=C3=BCr=20lastBuildDate=20und=20pubDate.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- local_podcast_generator.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/local_podcast_generator.py b/local_podcast_generator.py index 072a795..e9c316e 100644 --- a/local_podcast_generator.py +++ b/local_podcast_generator.py @@ -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)