37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
import os
|
|
import re
|
|
|
|
CONTENT_DIR = "content/podcast"
|
|
updates = [
|
|
{"old": "ep-010-datensouveraenitaet-teil-1.yaml", "new": "ep-011-datensouveraenitaet-teil-1.yaml", "id": "ep-011-datensouveraenitaet-teil-1", "title": "Datensouveränität (Teil 1) & Abhängigkeiten", "date": None},
|
|
{"old": "ep-011-datensouveraenitaet-teil-2.yaml", "new": "ep-012-datensouveraenitaet-teil-2.yaml", "id": "ep-012-datensouveraenitaet-teil-2", "title": "Datensouveränität (Teil 2) & Föderierung", "date": None},
|
|
]
|
|
|
|
for up in updates:
|
|
old_path = os.path.join(CONTENT_DIR, up['old'])
|
|
if not os.path.exists(old_path):
|
|
print(f"Skipping {old_path}, not found.")
|
|
continue
|
|
|
|
with open(old_path, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
# Update id
|
|
content = re.sub(r'^id:\s*.*$', f'id: {up["id"]}', content, flags=re.MULTILINE)
|
|
|
|
# Update title
|
|
content = re.sub(r'^title:\s*.*$', f'title: "{up["title"]}"', content, flags=re.MULTILINE)
|
|
|
|
new_filename = up['new']
|
|
new_path = os.path.join(CONTENT_DIR, new_filename)
|
|
|
|
with open(new_path, 'w', encoding='utf-8') as f:
|
|
f.write(content)
|
|
|
|
print(f"Updated {new_path}")
|
|
|
|
# Remove old file if renamed
|
|
if new_filename != up['old']:
|
|
os.remove(old_path)
|
|
print(f"Removed {old_path}")
|