123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- # encoding: UTF-8
- import pnalib
- import datetime
- import re
- import json
-
- # last two in order are $kitchen_info_id, $menu_type_id
- restaurant_info = [
- [ "(TaY) Yliopiston Ravintola", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/tayp%C3%A4%C3%A4kampus/yliopistonravintola.aspx", "M", "left", 13, 60 ],
- [ "(TaY) Yliopiston Ravintola / VegeBar", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/tayp%C3%A4%C3%A4kampus/yliopistonravintola.aspx", "", "left", 13, 5 ],
- [ "(TaY) Café Campus", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/tayp%C3%A4%C3%A4kampus/caf%C3%A9campus.aspx", "", "left", 130019, 23 ],
- [ "(TaY) Café Pinni", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/tayp%C3%A4%C3%A4kampus/caf%C3%A9lunchpinni.aspx", "M", "middle", 130016, 60 ],
- [ "(TAYS) Arvo", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/taykaupinkampus/arvo.aspx", "M", "left", 5, 60 ],
- [ "(TAYS) Café Lea (Fusion Kitchen)", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/taykaupinkampus/cafélea.aspx", "M", "left", 50026, 3 ],
- [ "(TAYS) Café Lea (My Salad)", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/taykaupinkampus/cafélea.aspx", "M", "left", 50026, 76 ],
- [ "(TTY) Newton", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/ttykampus/newton.aspx", "", "left", 6, 60],
- [ "(TTY) Café Konehuone / Såås bar", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/ttykampus/caf%C3%A9konehuone.aspx", "", "left", 60038, 77],
- [ "(TTY) Café Konehuone / Fusion Kitchen", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/ttykampus/caf%C3%A9konehuone.aspx", "", "middle", 60038, 3 ],
- [ "(TAMK) Ziberia", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/henkil%C3%B6st%C3%B6ravintolat/ziberia.aspx", "", "middle", 11, 60 ],
- # [ "(TAMK) Frenckell", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/henkil%C3%B6st%C3%B6ravintolat/frenckell.aspx", "", "middle", 33, 60 ],
- [ "(TAMK) Frenckell / Såås bar", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/henkil%C3%B6st%C3%B6ravintolat/frenckell.aspx", "", "middle", 33, 77 ]
- ]
-
-
- def get_restaurants(use_old, week):
- restaurants = []
- for count, info in enumerate(restaurant_info):
- kitchen = info[4]
- menutype = info[5]
- title = info[0]
- cur_title = title
- open_hours = ""
- week_foods = {}
- for weekday in range(1,7):
- url = "http://www.juvenes.fi/DesktopModules/Talents.LunchMenu/LunchMenuServices.asmx/GetMenuByWeekday?KitchenId={kitchen}&MenuTypeId={menutype}&Week={week}&Weekday={weekday}&lang='fi'&format=json".format(kitchen=kitchen, menutype=menutype, week=week, weekday=weekday)
- temp_fname = "juvenes_{count}-{weekday}.temp.js".format(count=count, weekday=weekday)
- data = pnalib.get_jsonp_file(url, temp_fname, use_old, allow_old=False)
- if data and data["d"] != "null":
- data = json.loads(data["d"])
- cur_day_foods = []
- mealoptions = data["MealOptions"]
- for meal_info in mealoptions:
- cur_food = []
- if "ForceMajoure" in meal_info and meal_info["ForceMajoure"] != "":
- cur_food = [meal_info["ForceMajoure"]]
- else:
- menuitems = meal_info["MenuItems"]
- for food_info in menuitems:
- name = food_info["Name"]
- name = re.sub(r"^\*", "", name)
- if food_info["Diets"]:
- cur_food.append("{name} ({diets})".format(name=name, diets=food_info["Diets"]))
- elif name:
- cur_food.append(name)
- if cur_food != ["-"]:
- cur_day_foods.append("\n".join(cur_food))
- week_foods[weekday-1] = cur_day_foods
- restaurants.append([title, open_hours, week, week_foods, info])
- return restaurants
|