Google parser: fix for movies with showtime, trailer and IMDb links
authorPhilipp Zabel <philipp.zabel@gmail.com>
Tue, 2 Feb 2010 16:28:42 +0000 (17:28 +0100)
committerPhilipp Zabel <philipp.zabel@gmail.com>
Tue, 2 Feb 2010 16:29:15 +0000 (17:29 +0100)
Fixes https://bugs.maemo.org/show_bug.cgi?id=8250.

src/plugins/google-parser.vala

index 3eb638f..cc5a0de 100644 (file)
@@ -201,7 +201,18 @@ public class GoogleParser : Object {
                expect_tag ("span"); // class=info
                string[] runtime_and_fsk = {};
                double rating = 0.0;
-               if (parse_tag () == "nobr") {
+               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 ();
@@ -212,12 +223,22 @@ public class GoogleParser : Object {
                        expect_tag ("/nobr");
                        expect_tag ("/nobr");
                        runtime_and_fsk = parse_text ().replace ("&#8206;", "").offset (3).split (" - ");
-                       expect_tag ("/span");
+                       if (parse_tag () == "a") {
+                               // Trailer
+                               expect_tag ("/a");
+                               if (parse_tag () == "a") {
+                                       // IMDb link
+                                       expect_tag ("/a");
+                                       expect_tag ("/span");
+                               }
+                       }
                }
                expect_tag ("div"); // class=times
                var showtimes = parse_text ().replace ("&nbsp;", ",");
-               expect_tag ("/div");
-               expect_tag ("/div");
+               while (parse_tag () == "a") {
+                       showtimes += parse_text () + ",";
+                       expect_tag ("/a");
+               }
 
                if (pattern == null) {
                        if (!title.has_prefix (_filter.title))