IMDb plugin: make plot downloading optional
[cinaest] / src / imdb / imdb-plaintext-downloader.vala
index a978527..a7c28e7 100644 (file)
@@ -73,6 +73,7 @@ class IMDbDownloadServer : Object, IMDbDownloader {
                        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);
@@ -81,21 +82,27 @@ class IMDbDownloadServer : Object, IMDbDownloader {
                                description_changed ("Downloading movie list ...");
                                downloader.download (url + "movies.list.gz", movie_parser);
                        }
-                       percent_finished = 25;
+                       percent_finished = 20;
                        if (GENRES in flags) {
                                description_changed ("Downloading genre data ...");
                                downloader.download (url + "genres.list.gz", genre_parser);
                        }
-                       percent_finished = 50;
+                       percent_finished = 40;
                        if (RATINGS in flags) {
                                description_changed ("Downloading rating data ...");
                                downloader.download (url + "ratings.list.gz", rating_parser);
                        }
-                       percent_finished = 75;
+                       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");
@@ -123,7 +130,7 @@ class IMDbDownloadServer : Object, IMDbDownloader {
        }
 
        private void on_progress_changed (int percent) {
-               progress (percent_finished + percent / 4);
+               progress (percent_finished + percent / 5);
        }
 
        private void timeout_quit () {