Browse Source

quickfix mensa json parsing

master
angerstoner 3 years ago
parent
commit
7ac746809f
  1. 3
      mensa.py

3
mensa.py

@ -119,6 +119,7 @@ def mensa(update: Update, context: CallbackContext):
else: else:
message = "Das Essen für %s in der %s \n\n" % (today_data["date"], MENSA_NAME[which]) message = "Das Essen für %s in der %s \n\n" % (today_data["date"], MENSA_NAME[which])
for cat in today_data['categories']: for cat in today_data['categories']:
try:
label = cat['name'] label = cat['name']
meals = cat['meals'] meals = cat['meals']
if label not in filter_categories and ( if label not in filter_categories and (
@ -129,6 +130,8 @@ def mensa(update: Update, context: CallbackContext):
for meal in meals: for meal in meals:
meal_line += meal['name'].strip() + "\n" meal_line += meal['name'].strip() + "\n"
message += meal_line + '\n' message += meal_line + '\n'
except: # TODO: catch correct exception
print("Could not fetch meal. Skipping.")
update.message.reply_text(message, ParseMode.MARKDOWN) update.message.reply_text(message, ParseMode.MARKDOWN)

Loading…
Cancel
Save