Browse Source

Update Amica restaurants for latest remote changes

Toni Fadjukoff 9 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
 use JSON;
2
 use JSON;
3
 
3
 
4
 my @restaurant_info = (
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
 sub utf8_to_8859 {
9
 sub utf8_to_8859 {
28
   my @week_foods = ();
28
   my @week_foods = ();
29
 
29
 
30
   my $data = from_json($json);
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
     foreach my $SetMenu (@$SetMenus) {
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
         $cur_food .= "\n" if $cur_food ne "";
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
       push @cur_day_foods, utf8_to_8859($cur_food) if ($cur_food ne "");
42
       push @cur_day_foods, utf8_to_8859($cur_food) if ($cur_food ne "");
41
       $cur_food = "";
43
       $cur_food = "";
64
   foreach my $i (@restaurant_info) {
66
   foreach my $i (@restaurant_info) {
65
     my @info = @{$i};
67
     my @info = @{$i};
66
     my $temp_fname = "amica$count.temp.html";
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
     if (!-f $temp_fname || !$use_old) {
70
     if (!-f $temp_fname || !$use_old) {
69
       system("wget -q --timeout=10 -O $temp_fname.tmp '$url' && mv $temp_fname.tmp $temp_fname") if ($url ne "");
71
       system("wget -q --timeout=10 -O $temp_fname.tmp '$url' && mv $temp_fname.tmp $temp_fname") if ($url ne "");
70
     }
72
     }