IMDb plugin: optionally download actors and actresses
[cinaest] / src / imdb / imdb-sqlite.vala
index 11adef8..a49160c 100644 (file)
@@ -362,8 +362,25 @@ class IMDbSqlite : Object {
                return count;
        }
 
-       public bool has_plots () {
-               return (count ("Plots") > 0);
+       public bool has_table (string table) {
+               string sql = "SELECT * FROM sqlite_master WHERE type=\"table\" AND name=\"%s\"".printf (table);
+               Statement stmt;
+               int rc;
+
+               rc = db.prepare_v2 (sql, -1, out stmt);
+               if (rc != Sqlite.OK) {
+                       stderr.printf ("SQL error: %d, %s\n", rc, db.errmsg ());
+                       db.progress_handler (0, null);
+                       return false;
+               }
+
+               do {
+                       rc = stmt.step ();
+                       if (rc == Sqlite.ROW)
+                               return true;
+               } while (rc == Sqlite.ROW);
+
+               return false;
        }
 
        public string get_plot (string title) {