Browse Source

Update Amica restaurants for latest remote changes

Toni Fadjukoff 8 years ago
parent
commit
3d8844c957
1 changed files with 11 additions and 9 deletions
  1. 11 9
      amica.pl

+ 11 - 9
amica.pl View File

@@ -2,8 +2,8 @@ use vars qw(@day_names);
2 2
 use JSON;
3 3
 
4 4
 my @restaurant_info = (
5
-  [ "(TaY) Amica Minerva", "http://www.amica.fi/minerva", "", "middle", "http://www.amica.fi/modules/json/json/Index?costNumber=0815" ],
6
-  [ "(TTY) Ravintola Reaktori", "http://www.amica.fi/reaktori", "", "middle", "http://www.amica.fi/modules/json/json/Index?costNumber=0812" ]
5
+  [ "(TaY) Amica Minerva", "http://www.amica.fi/minerva", "", "middle", "http://www.amica.fi/api/restaurant/menu/week?language=fi&restaurantPageId=7381" ],
6
+  [ "(TTY) Ravintola Reaktori", "http://www.amica.fi/reaktori", "", "middle", "http://www.amica.fi/api/restaurant/menu/week?language=fi&restaurantPageId=69171" ]
7 7
 );
8 8
 
9 9
 sub utf8_to_8859 {
@@ -28,14 +28,16 @@ sub parse_amica {
28 28
   my @week_foods = ();
29 29
 
30 30
   my $data = from_json($json);
31
-  my $MenusForDays = $data->{'MenusForDays'};
32
-  foreach my $MenuForDay (@$MenusForDays) {
33
-    my $SetMenus = $MenuForDay->{'SetMenus'};
31
+  my $LunchMenus = $data->{'LunchMenus'};
32
+  foreach my $LunchMenu (@$LunchMenus) {
33
+    my $SetMenus = $LunchMenu->{'SetMenus'};
34 34
     foreach my $SetMenu (@$SetMenus) {
35
-      my $Components = $SetMenu->{'Components'};
36
-      foreach my $Component (@$Components) {
35
+      my $Meals = $SetMenu->{'Meals'};
36
+      foreach my $Meal (@$Meals) {
37 37
         $cur_food .= "\n" if $cur_food ne "";
38
-        $cur_food .= $Component;
38
+        $cur_food .= $Meal->{'Name'};
39
+	my $Diets = $Meal->{'Diets'};
40
+	$cur_food .= ' (' . join(', ', @$Diets) . ')';
39 41
       }
40 42
       push @cur_day_foods, utf8_to_8859($cur_food) if ($cur_food ne "");
41 43
       $cur_food = "";
@@ -64,7 +66,7 @@ sub get_amica_restaurant {
64 66
   foreach my $i (@restaurant_info) {
65 67
     my @info = @{$i};
66 68
     my $temp_fname = "amica$count.temp.html";
67
-    my $url = "${info[4]}&firstDay=$first_day&lastDay=$last_day&language=fi";
69
+    my $url = "${info[4]}&weekDate=$first_day";
68 70
     if (!-f $temp_fname || !$use_old) {
69 71
       system("wget -q --timeout=10 -O $temp_fname.tmp '$url' && mv $temp_fname.tmp $temp_fname") if ($url ne "");
70 72
     }