Created
October 11, 2021 10:46
-
-
Save wiomoc/a438b4f14cc51d3e18ae1924d1d19041 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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