|
|
|
|
4
|
import re
|
4
|
import re
|
5
|
import json
|
5
|
import json
|
6
|
|
6
|
|
7
|
-# last two in order are $kitchen_info_id, $menu_type_id
|
|
|
|
|
7
|
+# Last three columns are Kitchen Info ID, Menu Type ID and Concept ID. There may be multiple concepts in a single restauranta.
|
|
|
8
|
+# Juvenes API defines also Restaurant ID but that is not used.
|
8
|
restaurant_info = [
|
9
|
restaurant_info = [
|
9
|
- [ "(TaY) Yliopiston Ravintola", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/tayp%C3%A4%C3%A4kampus/yliopistonravintola.aspx", "M", "left", 13, 60 ],
|
|
|
10
|
- [ "(TaY) Yliopiston Ravintola / VegeBar", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/tayp%C3%A4%C3%A4kampus/yliopistonravintola.aspx", "", "left", 13, 5 ],
|
|
|
11
|
- [ "(TaY) Café Campus", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/tayp%C3%A4%C3%A4kampus/caf%C3%A9campus.aspx", "", "left", 130019, 23 ],
|
|
|
12
|
- [ "(TaY) Café Pinni", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/tayp%C3%A4%C3%A4kampus/caf%C3%A9lunchpinni.aspx", "M", "middle", 130016, 60 ],
|
|
|
13
|
- [ "(TAYS) Arvo", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/taykaupinkampus/arvo.aspx", "M", "left", 5, 60 ],
|
|
|
14
|
- [ "(TAYS) Café Lea (Fusion Kitchen)", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/taykaupinkampus/cafélea.aspx", "M", "left", 50026, 3 ],
|
|
|
15
|
- [ "(TAYS) Café Lea (My Salad)", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/taykaupinkampus/cafélea.aspx", "M", "left", 50026, 76 ],
|
|
|
16
|
- [ "(TTY) Newton", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/ttykampus/newton.aspx", "", "left", 6, 60],
|
|
|
17
|
- [ "(TTY) Café Konehuone / Såås bar", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/ttykampus/caf%C3%A9konehuone.aspx", "", "left", 60038, 77],
|
|
|
18
|
- [ "(TTY) Café Konehuone / Fusion Kitchen", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/ttykampus/caf%C3%A9konehuone.aspx", "", "middle", 60038, 3 ],
|
|
|
19
|
- [ "(TAMK) Ziberia", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/henkil%C3%B6st%C3%B6ravintolat/ziberia.aspx", "", "middle", 11, 60 ],
|
|
|
20
|
-# [ "(TAMK) Frenckell", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/henkil%C3%B6st%C3%B6ravintolat/frenckell.aspx", "", "middle", 33, 60 ],
|
|
|
21
|
- [ "(TAMK) Frenckell / Såås bar", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/henkil%C3%B6st%C3%B6ravintolat/frenckell.aspx", "", "middle", 33, 77 ]
|
|
|
|
|
10
|
+ [ "(TaY) Yliopiston Ravintola", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/tayp%C3%A4%C3%A4kampus/yliopistonravintola.aspx", "M", "left", 13, 60, []],
|
|
|
11
|
+ [ "(TaY) Yliopiston Ravintola / VegeBar", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/tayp%C3%A4%C3%A4kampus/yliopistonravintola.aspx", "", "left", 13, 5, []],
|
|
|
12
|
+ [ "(TaY) Café Campus", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/tayp%C3%A4%C3%A4kampus/caf%C3%A9campus.aspx", "", "left", 130019, 23, []],
|
|
|
13
|
+ [ "(TaY) Café Pinni", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/tayp%C3%A4%C3%A4kampus/caf%C3%A9lunchpinni.aspx", "M", "middle", 130016, 60, []],
|
|
|
14
|
+ [ "(TAYS) Arvo", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/taykaupinkampus/arvo.aspx", "M", "left", 5, 60, []],
|
|
|
15
|
+ [ "(TAYS) Café Lea (Fusion Kitchen)", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/taykaupinkampus/cafélea.aspx", "M", "left", 50026, 3, []],
|
|
|
16
|
+ [ "(TAYS) Café Lea (My Salad)", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/taykaupinkampus/cafélea.aspx", "M", "left", 50026, 76, []],
|
|
|
17
|
+ [ "(TTY) Newton", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/ttykampus/newton.aspx", "", "left", 6, 60, [1149]],
|
|
|
18
|
+ [ "(TTY) Café Konehuone / Såås bar", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/ttykampus/caf%C3%A9konehuone.aspx", "", "left", 60038, 77, [3663]],
|
|
|
19
|
+ [ "(TTY) Café Konehuone / Fusion Kitchen", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/opiskelijaravintolat/ttykampus/caf%C3%A9konehuone.aspx", "", "middle", 60038, 3, [1674]],
|
|
|
20
|
+ [ "(TAMK) Ziberia", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/henkil%C3%B6st%C3%B6ravintolat/ziberia.aspx", "", "middle", 11, 60, []],
|
|
|
21
|
+ [ "(TAMK) Frenckell / Såås bar", "http://www.juvenes.fi/fi-fi/ravintolatjakahvilat/henkil%C3%B6st%C3%B6ravintolat/frenckell.aspx", "", "middle", 33, 77, []]
|
22
|
]
|
22
|
]
|
23
|
|
23
|
|
24
|
|
24
|
|
|
|
|
|
27
|
for count, info in enumerate(restaurant_info):
|
27
|
for count, info in enumerate(restaurant_info):
|
28
|
kitchen = info[4]
|
28
|
kitchen = info[4]
|
29
|
menutype = info[5]
|
29
|
menutype = info[5]
|
|
|
30
|
+ concepts = info[6]
|
30
|
title = info[0]
|
31
|
title = info[0]
|
31
|
cur_title = title
|
32
|
cur_title = title
|
32
|
open_hours = ""
|
33
|
open_hours = ""
|
|
|
34
|
+ exception = None
|
33
|
week_foods = {}
|
35
|
week_foods = {}
|
34
|
for weekday in range(1,7):
|
36
|
for weekday in range(1,7):
|
35
|
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)
|
37
|
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)
|
36
|
temp_fname = "juvenes_{count}-{weekday}.temp.js".format(count=count, weekday=weekday)
|
38
|
temp_fname = "juvenes_{count}-{weekday}.temp.js".format(count=count, weekday=weekday)
|
37
|
data = pnalib.get_jsonp_file(url, temp_fname, use_old, allow_old=False)
|
39
|
data = pnalib.get_jsonp_file(url, temp_fname, use_old, allow_old=False)
|
38
|
- if data and data["d"] != "null":
|
|
|
|
|
40
|
+ if not data:
|
|
|
41
|
+ # Try to find problem
|
|
|
42
|
+ for concept in concepts:
|
|
|
43
|
+ url = "http://www.juvenes.fi/DesktopModules/Talents.Restaurants/RestaurantsService.svc/GetConcept?menuId={concept}&lang=fi".format(concept=concept)
|
|
|
44
|
+ temp_fname = "juvenes_{count}-{weekday}-{concept}.temp.js".format(count=count, weekday=weekday, concept=concept)
|
|
|
45
|
+ data = pnalib.get_json_file(url, temp_fname, use_old, allow_old=False)
|
|
|
46
|
+ if data and data["d"]:
|
|
|
47
|
+ exception = data["d"]["OpenInfo"]["Exeption1InfoText"]
|
|
|
48
|
+ elif data and data["d"] != "null":
|
39
|
data = json.loads(data["d"])
|
49
|
data = json.loads(data["d"])
|
40
|
cur_day_foods = []
|
50
|
cur_day_foods = []
|
41
|
mealoptions = data["MealOptions"]
|
51
|
mealoptions = data["MealOptions"]
|
|
|
|
|
55
|
if cur_food != ["-"]:
|
65
|
if cur_food != ["-"]:
|
56
|
cur_day_foods.append("\n".join(cur_food))
|
66
|
cur_day_foods.append("\n".join(cur_food))
|
57
|
week_foods[weekday-1] = cur_day_foods
|
67
|
week_foods[weekday-1] = cur_day_foods
|
58
|
- restaurants.append([title, open_hours, week, week_foods, info])
|
|
|
|
|
68
|
+ restaurants.append([title, open_hours, week, week_foods, info, exception])
|
59
|
return restaurants
|
69
|
return restaurants
|