mirror of
http://nostr-git-proxy.forgejo.svc.cluster.local/git/45387ca441053e230b2126802005eb03767ab59d84555e8bac86b6e7def14e27/bestdadjokes
synced 2026-11-03 07:26:59 +00:00
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
import json
|
|
import uuid
|
|
|
|
# Load existing jokes
|
|
try:
|
|
with open('content/jokes.json', 'r') as f:
|
|
data = json.load(f)
|
|
except Exception as e:
|
|
print(f"Error loading: {e}")
|
|
exit(1)
|
|
|
|
existing_setups = set(j.get('setup', '').lower().strip() for j in data.get('jokes', []))
|
|
|
|
new_jokes_batch3 = [
|
|
{"setup": "I bought some shoes from a drug dealer.", "punch": "I don't know what he laced them with, but I've been tripping all day.", "cat": "one-liners"},
|
|
{"setup": "Why don't blind people skydive?", "punch": "Because it scares the dogs.", "cat": "sports"},
|
|
{"setup": "Why did the old man fall in the well?", "punch": "Because he couldn't see that well.", "cat": "family"},
|
|
{"setup": "How does a rabbi make coffee?", "punch": "Hebrews it.", "cat": "work"},
|
|
{"setup": "What do you call a parade of rabbits hopping backwards?", "punch": "A receding hare-line.", "cat": "animals"}
|
|
]
|
|
|
|
added = 0
|
|
jokes = data.get("jokes", [])
|
|
for joke in new_jokes_batch3:
|
|
if joke['setup'].lower().strip() not in existing_setups:
|
|
joke['id'] = str(uuid.uuid4())
|
|
jokes.append(joke)
|
|
existing_setups.add(joke['setup'].lower().strip())
|
|
added += 1
|
|
|
|
data['jokes'] = jokes
|
|
|
|
print(f"Added {added} jokes.")
|
|
|
|
with open('content/jokes.json', 'w') as f:
|
|
json.dump(data, f, indent=4)
|
|
# Ensure trailing newline
|
|
f.write('\n')
|