IMDb plaintext downloader: optionally download actors and actresses
authorPhilipp Zabel <philipp.zabel@gmail.com>
Tue, 13 Jul 2010 16:18:20 +0000 (18:18 +0200)
committerPhilipp Zabel <philipp.zabel@gmail.com>
Mon, 16 Aug 2010 13:11:07 +0000 (15:11 +0200)
This is the start of people support in cinaest.

src/imdb/imdb-downloader-cli.vala
src/imdb/imdb-plaintext-downloader.vala
src/imdb/plaintext-downloader-interface.vala

index 393a21f..8576984 100644 (file)
@@ -56,7 +56,7 @@ class IMDbDownloaderCLI : Object, IMDbDownloader {
 
        private bool do_download () {
                try {
-                       download ("ftp.fu-berlin.de/pub/misc/movies/database/", MOVIES | GENRES | RATINGS | AKAS | PLOTS);
+                       download ("ftp.fu-berlin.de/pub/misc/movies/database/", MOVIES | GENRES | RATINGS | AKAS | PLOTS | ACTORS);
                } catch (Error e) {
                        print ("Error: %s\n", e.message);
                }
@@ -82,6 +82,7 @@ class IMDbDownloaderCLI : Object, IMDbDownloader {
                        var rating_parser = new RatingLineParser (sqlite);
                        var aka_parser = new AkaLineParser (sqlite);
                        var plot_parser = new PlotLineParser (sqlite);
+                       var person_parser = new PersonParser (sqlite);
 
                        var downloader = new FtpDownloader (cancellable);
 
@@ -113,6 +114,25 @@ class IMDbDownloaderCLI : Object, IMDbDownloader {
                                description_changed ("Downloading plots ...");
                                downloader.download (url + "plot.list.gz", Path.build_filename (cache_dir, "plot.list.gz"));
                        }
+                       if (ACTORS in flags) {
+                               description_changed ("Downloading actors ...");
+                               downloader.download (url + "actors.list.gz", Path.build_filename (cache_dir, "actors.list.gz"));
+                               description_changed ("Downloading actresses ...");
+                               downloader.download (url + "actresses.list.gz", Path.build_filename (cache_dir, "actresses.list.gz"));
+                       }
+                       // composers
+                       // costume-designers
+                       if (DIRECTORS in flags) {
+                               description_changed ("Downloading directors ...");
+                               downloader.download (url + "directors.list.gz", Path.build_filename (cache_dir, "directors.list.gz"));
+                       }
+                       // editors
+                       // producers
+                       // production-designers
+                       if (WRITERS in flags) {
+                               description_changed ("Downloading writers ...");
+                               downloader.download (url + "writers.list.gz", Path.build_filename (cache_dir, "writers.list.gz"));
+                       }
 
                        if (MOVIES in flags) {
                                description_changed ("Parsing movie list ...");
@@ -138,6 +158,13 @@ class IMDbDownloaderCLI : Object, IMDbDownloader {
                                description_changed ("Parsing plots ...");
                                parser.parse (Path.build_filename (cache_dir, "plot.list.gz"), plot_parser);
                        }
+                       if (ACTORS in flags) {
+                               description_changed ("Parsing actors ...");
+                               parser.parse (Path.build_filename (cache_dir, "actors.list.gz"), person_parser);
+                               person_parser.reset ();
+                               description_changed ("Parsing actresses ...");
+                               parser.parse (Path.build_filename (cache_dir, "actresses.list.gz"), person_parser);
+                       }
                } catch (Error e2) {
                        if (e2 is IOError.CANCELLED)
                                stdout.printf ("Download cancelled.\n");
index 8b95f36..c073428 100644 (file)
@@ -74,6 +74,7 @@ class IMDbDownloadServer : Object, IMDbDownloader {
                        var rating_parser = new RatingLineParser (sqlite);
                        var aka_parser = new AkaLineParser (sqlite);
                        var plot_parser = new PlotLineParser (sqlite);
+                       var person_parser = new PersonParser (sqlite);
 
                        var downloader = new FtpDownloader (cancellable);
                        downloader.progress.connect (on_progress);
@@ -105,6 +106,25 @@ class IMDbDownloadServer : Object, IMDbDownloader {
                                description_changed ("Downloading plots ...");
                                downloader.download (url + "plot.list.gz", Path.build_filename (cache_dir, "plot.list.gz"));
                        }
+                       if (ACTORS in flags) {
+                               description_changed ("Downloading actors ...");
+                               downloader.download (url + "actors.list.gz", Path.build_filename (cache_dir, "actors.list.gz"));
+                               description_changed ("Downloading actresses ...");
+                               downloader.download (url + "actresses.list.gz", Path.build_filename (cache_dir, "actresses.list.gz"));
+                       }
+                       // composers
+                       // costume-designers
+                       if (DIRECTORS in flags) {
+                               description_changed ("Downloading directors ...");
+                               downloader.download (url + "directors.list.gz", Path.build_filename (cache_dir, "directors.list.gz"));
+                       }
+                       // editors
+                       // producers
+                       // production-designers
+                       if (WRITERS in flags) {
+                               description_changed ("Downloading writers ...");
+                               downloader.download (url + "writers.list.gz", Path.build_filename (cache_dir, "writers.list.gz"));
+                       }
 
                        percent_finished = 50;
                        if (MOVIES in flags) {
@@ -131,6 +151,13 @@ class IMDbDownloadServer : Object, IMDbDownloader {
                                description_changed ("Parsing plots ...");
                                parser.parse (Path.build_filename (cache_dir, "plot.list.gz"), plot_parser);
                        }
+                       if (ACTORS in flags) {
+                               description_changed ("Parsing actors ...");
+                               parser.parse (Path.build_filename (cache_dir, "actors.list.gz"), person_parser);
+                               person_parser.reset ();
+                               description_changed ("Parsing actresses ...");
+                               parser.parse (Path.build_filename (cache_dir, "actresses.list.gz"), person_parser);
+                       }
                } catch (Error e2) {
                        if (e2 is IOError.CANCELLED)
                                stdout.printf ("Download cancelled.\n");
index af7eae3..2522440 100644 (file)
@@ -15,6 +15,9 @@ public interface IMDbDownloader {
        public const int VIDEO = 0x400;
        public const int GAME = 0x800;
        public const int ADULT = 0x1000;
+       public const int ACTORS = 0x10000;
+       public const int DIRECTORS = 0x20000;
+       public const int WRITERS = 0x40000;
 
        public abstract void download (string mirror, int flags) throws DBus.Error;
        public abstract void cancel () throws DBus.Error;