IMDb plugin + downloader: parse IMDb plots
[cinaest] / src / imdb / imdb-plaintext-downloader.vala
index e3df558..a7c28e7 100644 (file)
@@ -72,6 +72,8 @@ class IMDbDownloadServer : Object, IMDbDownloader {
                        var movie_parser = new MovieLineParser (sqlite);
                        var genre_parser = new GenreLineParser (sqlite);
                        var rating_parser = new RatingLineParser (sqlite);
+                       var aka_parser = new AkaLineParser (sqlite);
+                       var plot_parser = new PlotLineParser (sqlite);
 
                        var downloader = new IMDbFtpDownloader (cancellable);
                        downloader.progress_changed.connect (on_progress_changed);
@@ -79,19 +81,28 @@ class IMDbDownloadServer : Object, IMDbDownloader {
                        if (MOVIES in flags) {
                                description_changed ("Downloading movie list ...");
                                downloader.download (url + "movies.list.gz", movie_parser);
-                               description_changed ("Creating title index ...");
-                               sqlite.create_title_index ();
                        }
-                       percent_finished = 33;
+                       percent_finished = 20;
                        if (GENRES in flags) {
                                description_changed ("Downloading genre data ...");
                                downloader.download (url + "genres.list.gz", genre_parser);
                        }
-                       percent_finished = 66;
+                       percent_finished = 40;
                        if (RATINGS in flags) {
                                description_changed ("Downloading rating data ...");
                                downloader.download (url + "ratings.list.gz", rating_parser);
                        }
+                       percent_finished = 60;
+                       if (AKAS in flags) {
+                               description_changed ("Downloading alternative titles ...");
+                               downloader.download (url + "aka-titles.list.gz", aka_parser);
+                       }
+                       percent_finished = 80;
+                       if (PLOTS in flags) {
+                               description_changed ("Downloading plots ...");
+                               print ("Downloading Plots");
+                               downloader.download (url + "plot.list.gz", plot_parser);
+                       }
                } catch (Error e2) {
                        if (e2 is IOError.CANCELLED)
                                stdout.printf ("Download cancelled.\n");
@@ -100,7 +111,10 @@ class IMDbDownloadServer : Object, IMDbDownloader {
                }
 
                description_changed ("Creating indices ...");
-               sqlite.create_votes_index ();
+               if (AKAS in flags)
+                       sqlite.create_aka_index ();
+               if (MOVIES in flags)
+                       sqlite.create_votes_index ();
 
                if (!cancellable.is_cancelled ()) {
                        stdout.printf ("Download complete.\n");
@@ -116,7 +130,7 @@ class IMDbDownloadServer : Object, IMDbDownloader {
        }
 
        private void on_progress_changed (int percent) {
-               progress (percent_finished + percent / 3);
+               progress (percent_finished + percent / 5);
        }
 
        private void timeout_quit () {