Eine voting seite für falsch zugeordnete Zitate https://zitate.prapsschnalinen.de
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
zitate/init_important_files.py

31 lines
1002 B

from db import WrongQuote
import requests
import os
import pickle
if os.path.isfile("apikeys.pkl"):
print("apikeys.pkl already exists.")
else:
with open("apikeys.pkl", "wb") as file:
pickle.dump(["123456"], file)
print("created apikey.pkl with '123456' as a key")
if len(WrongQuote.select()) > 0:
print("quotes.db is already populated.")
else:
response = requests.get("https://zitate.prapsschnalinen.de/api/wrongquotes").json()
for wrongquote in response:
WrongQuote.get_or_create(
wrongquote["quote"]["quote"],
wrongauthor=wrongquote["author"]["author"],
realauthor=wrongquote["quote"]["author"]["author"],
voted=wrongquote["voted"],
showed=wrongquote["showed"],
rating=wrongquote["rating"],
checked=wrongquote["checked"],
contributed_by="idk"
)
print("added quotes to quotes.db (attention: they are not the same as on zitate.prapsschnalinen.de)")