- public void parse_movie () throws Error {
- expect_tag ("div"); // class=movie
- expect_tag ("div"); // class=name
- expect_tag ("a"); // href="/movies?near=city&mid=..."
- expect_tag ("span"); // dir=ltr
- var title = unescape_unicode (convert (parse_text (), -1, "utf-8", "iso-8859-1")); // FIXME
- expect_tag ("/span");
- expect_tag ("/a");
- expect_tag ("/div");
- expect_tag ("span"); // class=info
- string info_text = parse_text ().replace ("‎", "");
- string[] runtime_and_fsk = {};
- double rating = 0.0;
- var tag = parse_tag ();
- if (tag == "a") {
- // Trailer
- expect_tag ("/a");
- tag = parse_tag ();
- }
- if (tag == "a") {
- // IMDb
- expect_tag ("/a");
- tag = parse_tag ();
- }
- if (tag == "nobr") {
- expect_tag ("nobr");
- string rating_string = parse_tag_attribute ("img", "alt").offset (6); // "Rated " ->"0.0 out of 5.0"
- rating = rating_string.to_double ();
- expect_tag ("img");
- expect_tag ("img");
- expect_tag ("img");
- expect_tag ("img");
- expect_tag ("/nobr");
- expect_tag ("/nobr");
- info_text = parse_text ().replace ("‎", "").offset (3);
- if (parse_tag () == "a") {
- // Trailer
- expect_tag ("/a");
- if (parse_tag () == "a") {
- // IMDb link
- expect_tag ("/a");
- expect_tag ("/span");
- }
- }
- }
- runtime_and_fsk = info_text.split (" - ");
- expect_tag ("div"); // class=times
- var showtimes = parse_text ().replace (" ", ",");
- while (parse_tag () == "a") {
- showtimes += parse_text () + ",";
- expect_tag ("/a");
+ private Xml.Node* parse_movie (Xml.Node* m, Theater theater) {
+ var movie = new GoogleMovie ();
+ movie.theater = theater;
+ Xml.Node* n;
+ for (n = m->children; n != null; n = n->next) {
+ if (n->name == "div" && n->get_prop ("class") == "name")
+ movie.title = parse_movie_name (n);
+ if (n->name == "span" && n->get_prop ("class") == "info")
+ parse_movie_info (n, movie);
+ if (n->name == "div" && n->get_prop ("class") == "times")
+ parse_movie_times (n, movie);