Skip to content

Instantly share code, notes, and snippets.

@wiomoc
Created October 11, 2021 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wiomoc/a438b4f14cc51d3e18ae1924d1d19041 to your computer and use it in GitHub Desktop.
Save wiomoc/a438b4f14cc51d3e18ae1924d1d19041 to your computer and use it in GitHub Desktop.
from urllib import request
import json
import datetime
import base64
import sys
plan = json.load(request.urlopen("https://sws.maxmanager.xyz/extern/mensa_stuttgart-vaihingen.json"))
plan = plan['Mensa Stuttgart-Vaihingen']
#days = sorted(plan.items(), key=lambda item: item[0])
day = plan.get(datetime.date.today().isoformat())
if not day:
print("starvation day")
exit()
def display_image(path):
img = request.urlopen(f"https://sws2.maxmanager.xyz/assets/{path}").read()
sys.stdout.write("\u001B]1337;File=inline=1;width=30:")
sys.stdout.write(base64.b64encode(img).decode("UTF-8"))
sys.stdout.write("\u0007\n")
for meal in day:
if meal.get("foto"):
display_image(meal["foto"])
print(f"{meal['meal']} - {meal['price2']} €")
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment