From 37a66ab2247804949a5610078c01957da0024e7e Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Tue, 13 Jul 2010 18:18:20 +0200 Subject: [PATCH] IMDb plaintext downloader: optionally download actors and actresses This is the start of people support in cinaest. --- src/imdb/imdb-downloader-cli.vala | 29 +++++++++++++++++++++++++- src/imdb/imdb-plaintext-downloader.vala | 27 ++++++++++++++++++++++++ src/imdb/plaintext-downloader-interface.vala | 3 +++ 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/src/imdb/imdb-downloader-cli.vala b/src/imdb/imdb-downloader-cli.vala index 393a21f..8576984 100644 --- a/src/imdb/imdb-downloader-cli.vala +++ b/src/imdb/imdb-downloader-cli.vala @@ -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"); diff --git a/src/imdb/imdb-plaintext-downloader.vala b/src/imdb/imdb-plaintext-downloader.vala index 8b95f36..c073428 100644 --- a/src/imdb/imdb-plaintext-downloader.vala +++ b/src/imdb/imdb-plaintext-downloader.vala @@ -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"); diff --git a/src/imdb/plaintext-downloader-interface.vala b/src/imdb/plaintext-downloader-interface.vala index af7eae3..2522440 100644 --- a/src/imdb/plaintext-downloader-interface.vala +++ b/src/imdb/plaintext-downloader-interface.vala @@ -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; -- 1.7.9.5