From 466d7a89ce9dbf6d21b7c55bd1a2a362b7784ec9 Mon Sep 17 00:00:00 2001
From: Marcel Heidemann
Date: Fri, 6 Mar 2026 08:13:31 +0100
Subject: [PATCH] initial morningpaper script
---
archive/2026-03-04.html | 33 ++++++++++
archive/2026-03-05.html | 33 ++++++++++
input.csv | 4 ++
morningpaper.py | 142 ++++++++++++++++++++++++++++++++++++++++
template.html | 24 +++++++
template_1.html | 33 ++++++++++
6 files changed, 269 insertions(+)
create mode 100644 archive/2026-03-04.html
create mode 100644 archive/2026-03-05.html
create mode 100644 input.csv
create mode 100644 morningpaper.py
create mode 100644 template.html
create mode 100644 template_1.html
diff --git a/archive/2026-03-04.html b/archive/2026-03-04.html
new file mode 100644
index 0000000..195faac
--- /dev/null
+++ b/archive/2026-03-04.html
@@ -0,0 +1,33 @@
+
+
+Morning Paper
+
+
+
+
+Kurioser Feiertag
+
+
+Mitarbeiter
+
+
+| Name | Geburtstag | Eintritt | Tagegesamt | Jahre | Monate | Tage |
+
+
+| Becky | 12.05.1990 | 01.03.2018 | 2925 | 8 | 0 | 3 |
+| Tatjana | 22.08.1988 | 15.06.2020 | 2088 | 5 | 8 | 17 |
+| Max | 10.01.1995 | 01.02.2022 | 1492 | 4 | 1 | 3 |
+
+
+
+Geburtstage heute
+[]
+
+Geburtstage im Monat
+[]
+
+Jubiläum
+[]
+
+
+
\ No newline at end of file
diff --git a/archive/2026-03-05.html b/archive/2026-03-05.html
new file mode 100644
index 0000000..5205662
--- /dev/null
+++ b/archive/2026-03-05.html
@@ -0,0 +1,33 @@
+
+
+Morning Paper
+
+
+
+
+Kurioser Feiertag
+
+
+Mitarbeiter
+
+
+| Name | Geburtstag | Eintritt | Tagegesamt | Jahre | Monate | Tage |
+
+
+| Max | 10.01.1995 | 01.02.2022 | 1493 | 4 | 1 | 4 |
+| Becky | 12.05.1990 | 01.03.2018 | 2926 | 8 | 0 | 4 |
+| Tatjana | 22.08.1988 | 15.06.2020 | 2089 | 5 | 8 | 18 |
+
+
+
+Geburtstage heute
+[]
+
+Geburtstage im Monat
+[]
+
+Jubiläum
+[]
+
+
+
\ No newline at end of file
diff --git a/input.csv b/input.csv
new file mode 100644
index 0000000..cb98dc3
--- /dev/null
+++ b/input.csv
@@ -0,0 +1,4 @@
+Name;Geburtstag;Eintritt
+Becky;12.05.1990;01.03.2018
+Tatjana;22.08.1988;15.06.2020
+Max;10.01.1995;01.02.2022
\ No newline at end of file
diff --git a/morningpaper.py b/morningpaper.py
new file mode 100644
index 0000000..3adf244
--- /dev/null
+++ b/morningpaper.py
@@ -0,0 +1,142 @@
+from datetime import datetime
+from dateutil.relativedelta import relativedelta
+import os
+import requests
+import re
+import shutil
+import csv
+from tabulate import tabulate
+import random
+import time
+import webbrowser
+from bs4 import BeautifulSoup
+
+# url = 'https://www.kuriose-feiertage.de/'
+# webbrowser.open(url)
+
+#Dateimanagement
+os.chdir(os.path.dirname(__file__))
+path =os.path.join(os.path.join(os.environ['USERPROFILE']), 'Desktop')
+new_file=os.path.join(path ,"goodmorning.html")
+shutil.copyfile('template.html', 'template_1.html')
+
+#Datumsaufgaben
+date_format = "%d.%m.%Y"
+Now = datetime.now()
+
+#Berechnung der Differenz von Einstiegsdatum bis jetzt
+def datecalc(employee_row):
+ date = datetime.strptime(employee_row, date_format)
+ delta = Now - date
+ difference = relativedelta(Now, date)
+ return str(delta.days),str(difference.years),str(difference.months),str(difference.days)
+
+employedata=list(csv.reader((open('input.csv')), delimiter=';'))
+employedata[0].extend(['Tagegesamt', 'Jahre', 'Monate', 'Tage'])
+
+
+for i in range(1, len(employedata)):
+ a=datecalc(employedata[i][2])
+ employedata[i].extend([a[0], a[1], a[2], a[3]])
+
+table = tabulate(employedata, tablefmt='html')
+
+def getdateinfo():
+ response = requests.get('https://welcher-tag-ist-heute.org/')
+ title= re.sub(r'.*(.*).*','\g<1>', response.text, flags=re.S)
+ name_dat= re.sub('.*(.*?
).*','\g<1>', response.text, flags=re.S)
+ spec_day = re.sub('.*(.*)
.*','\g<1>', response.text, flags=re.S)
+ spec_day = re.sub('.*','', spec_day, flags=re.S)
+ spec_day = re.sub('','', spec_day, flags=re.S)
+ spec_day = re.sub('','', spec_day, flags=re.S)
+ return title,name_dat,spec_day
+
+def templator(templatorid, templatorresult):
+ with open('template_1.html', 'r', encoding="utf-8") as file:
+ string = file.read()
+ string = string.replace(templatorid, templatorresult)
+ with open('template_1.html', 'w', encoding="utf-8") as file:
+ file.write(string)
+
+# title,name_dat,spec_day = getdateinfo()
+
+def getdateinfo_new():
+ headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}
+ response = requests.get('https://www.kuriose-feiertage.de/', headers=headers)
+ html = BeautifulSoup(response.text, 'html.parser')
+ titles = html.find_all(class_='entry-title')
+ spec_day=''
+ for title in titles:
+ #print (str(title))
+ spec_day+=str(title)
+
+ return spec_day
+ #print ('---->'+str(title_element.text)+'<-----')
+
+spec_day = getdateinfo_new()
+
+#Test:
+#Rebecca immer mo-donnerstag ganz oben und Tatjana di-do direkt hinter rebecca, sonst random
+tablehead = employedata[0]
+tablebody = employedata[1:]
+shuffled_tablebody = tablebody[:]
+random.shuffle(shuffled_tablebody)
+
+
+#HTML Tabelle erstellen
+tablehead_html = """
+
+
+ | """ + " | ".join(tablehead) + " |
"
+tablebody_html = tabulate(shuffled_tablebody, headers=tablehead, tablefmt='html')
+html_table = tablebody_html
+
+def makeitpretty():
+ with open('template_1.html', 'r', encoding="utf-8") as file:
+ string = file.read()
+ string = string.replace('
', '')
+ string= string.replace('h2', 'h3')
+ with open('template_1.html', 'w', encoding="utf-8") as file:
+ file.write(string)
+
+def birthdaychecker():
+ check = Now.strftime('%d.%m')
+ geburtstagskind = [row[0] for row in employedata if row[1][:5] == check]
+ return geburtstagskind
+
+
+def birthdaymonthchecker():
+ check = Now.strftime('%m')
+ geburtstagskinddesmonats = [row[0] for row in employedata if row[1][3:5] == check]
+ return geburtstagskinddesmonats
+
+geburtstagskinddesmonats=str(birthdaymonthchecker())
+
+def anniversarychecker():
+ return [row[0] for row in employedata if (row[5] == '0' and row[6] == '0') or len(set(str(row[3]).split(" test")[0])) <= 1]
+
+anniversary=anniversarychecker()
+geburtstagskind=str(birthdaychecker())
+
+
+templator('$geburtstagskind$', geburtstagskind)
+templator('$geburtstagskinddesmonats$', geburtstagskinddesmonats)
+templator('$specialday$', spec_day)
+templator('$namenstage$', ' ')
+templator('$specialday_d$', ' ')
+templator('$tablehead$', tablehead_html)
+templator('$table$', html_table)
+templator('$anniversary$', str(anniversary))
+makeitpretty()
+
+now_file_name = time.strftime('%Y-%m-%d')
+print(now_file_name)
+
+archivepath = os.path.join(os.path.dirname(__file__), 'archive')
+os.makedirs(archivepath, exist_ok=True)
+
+shutil.copyfile('template_1.html', os.path.join(archivepath, now_file_name + '.html'))
+shutil.copyfile('template_1.html', new_file)
+
+os.system(new_file)
+
diff --git a/template.html b/template.html
new file mode 100644
index 0000000..ccbcd6e
--- /dev/null
+++ b/template.html
@@ -0,0 +1,24 @@
+
+
+Morning Paper
+
+
+
+
+Kurioser Feiertag
+$specialday$
+
+Mitarbeiter
+$table$
+
+Geburtstage heute
+$geburtstagskind$
+
+Geburtstage im Monat
+$geburtstagskinddesmonats$
+
+Jubiläum
+$anniversary$
+
+
+
\ No newline at end of file
diff --git a/template_1.html b/template_1.html
new file mode 100644
index 0000000..5205662
--- /dev/null
+++ b/template_1.html
@@ -0,0 +1,33 @@
+
+
+Morning Paper
+
+
+
+
+Kurioser Feiertag
+
+
+Mitarbeiter
+
+
+| Name | Geburtstag | Eintritt | Tagegesamt | Jahre | Monate | Tage |
+
+
+| Max | 10.01.1995 | 01.02.2022 | 1493 | 4 | 1 | 4 |
+| Becky | 12.05.1990 | 01.03.2018 | 2926 | 8 | 0 | 4 |
+| Tatjana | 22.08.1988 | 15.06.2020 | 2089 | 5 | 8 | 18 |
+
+
+
+Geburtstage heute
+[]
+
+Geburtstage im Monat
+[]
+
+Jubiläum
+[]
+
+
+
\ No newline at end of file