var m = new string[results.length ()];
int i = 0;
for (unowned GLib.List<GoogleMovie> node = results.first (); node != null; node = node.next) {
- m[i++] = "{\"title\":\"%s\",\"rating\":%f,\"showtimes\":\"%s\",\"cinema_name\":\"%s\",\"cinema_phone\":\"%s\"}".printf (node.data.title, node.data.rating, node.data.showtimes, node.data.cinema.name, node.data.cinema.phone);
+ m[i++] = "{\"title\":\"%s\",\"rating\":%f,\"runtime\":%d,\"showtimes\":\"%s\",\"cinema_name\":\"%s\",\"cinema_phone\":\"%s\"}".printf (node.data.title, node.data.rating, node.data.runtime, node.data.showtimes, node.data.cinema.name, node.data.cinema.phone);
}
movies_found (m, true);
service.timeout_quit ();
public class GoogleMovie {
public string title;
public int rating;
- public string secondary;
public Cinema cinema;
- public string runtime;
+ public int runtime;
public string fsk;
public string showtimes;
}
movie.rating = (int) (rating * 10);
movie.cinema = last_cinema;
+ movie.runtime = 0;
if (runtime_and_fsk.length >= 2) {
- movie.runtime = runtime_and_fsk[0];
+ unowned string runtime = runtime_and_fsk[0];
+ movie.runtime = 3600 * runtime.to_int ();
+ runtime = runtime.str ("hr ");
+ if (runtime != null)
+ movie.runtime += 60 * runtime.offset (3).to_int ();
movie.fsk = runtime_and_fsk[1];
}
movie.showtimes = showtimes;
-
- // TODO - could be configurable by settings
- if (movie.runtime != null)
- movie.secondary = "%s - %s - %s".printf (movie.runtime, last_cinema.name, showtimes);
- else
- movie.secondary = "%s - %s".printf (last_cinema.name, showtimes);
-
_get_callback (movie);
}
public class GoogleMovie : Movie {
public string cinema_name;
public string cinema_phone;
- public string runtime;
+ public int runtime;
public string showtimes;
}
timeinfo.hour = hour;
showtime = timeinfo.mktime ();
- int runtime = 3600 * movie.runtime.to_int () + 60 * movie.runtime.str ("hr ").offset (3).to_int ();
+ int runtime = movie.runtime;
if (runtime == 0) {
// Default to 120min if we failed to parse the runtime
runtime = 7200;
movie.rating = (int) object.get_double_member ("rating");
movie.cinema_name = object.get_string_member ("cinema_name");
movie.cinema_phone = object.get_string_member ("cinema_phone");
+ movie.runtime = (int) object.get_int_member ("runtime");
movie.showtimes = object.get_string_member ("showtimes");
- movie.secondary = movie.cinema_name + " - " + movie.showtimes;
+ if (movie.runtime > 0)
+ movie.secondary = "%d min - %s - %s".printf (movie.runtime / 60, movie.cinema_name, movie.showtimes);
+ else
+ movie.secondary = movie.cinema_name + " - " + movie.showtimes;
callback (movie);
}