diff --git a/source/net/sourceforge/filebot/cli/ArgumentBean.java b/source/net/sourceforge/filebot/cli/ArgumentBean.java index 1fa5d382..e07ad17a 100644 --- a/source/net/sourceforge/filebot/cli/ArgumentBean.java +++ b/source/net/sourceforge/filebot/cli/ArgumentBean.java @@ -27,6 +27,9 @@ public class ArgumentBean { @Option(name = "-rename", usage = "Rename episode/movie files", metaVar = "fileset") public boolean rename = false; + @Option(name = "-list", usage = "Fetch episode list") + public boolean list = false; + @Option(name = "--db", usage = "Episode/Movie database", metaVar = "[TVRage, AniDB, TheTVDB] or [OpenSubtitles, TheMovieDB]") public String db; @@ -74,7 +77,7 @@ public class ArgumentBean { public boolean runCLI() { - return rename || getSubtitles || check; + return rename || getSubtitles || check || list; } diff --git a/source/net/sourceforge/filebot/cli/ArgumentProcessor.java b/source/net/sourceforge/filebot/cli/ArgumentProcessor.java index df4e2fb0..dac14a1a 100644 --- a/source/net/sourceforge/filebot/cli/ArgumentProcessor.java +++ b/source/net/sourceforge/filebot/cli/ArgumentProcessor.java @@ -64,6 +64,13 @@ public class ArgumentProcessor { Analytics.trackView(ArgumentProcessor.class, "FileBot CLI"); CLILogger.setLevel(args.getLogLevel()); + // print operations + if (args.list) { + printEpisodeList(args.query, args.getEpisodeFormat(), args.db, args.getLanguage().toLocale()); + return 0; + } + + // file operations try { Set files = new LinkedHashSet(args.getFiles(true)); @@ -599,4 +606,17 @@ public class ArgumentProcessor { out.close(); } } + + + private void printEpisodeList(String query, ExpressionFormat format, String db, Locale locale) throws Exception { + // find series on the web and fetch episode list + EpisodeListProvider service = db != null ? getEpisodeListProvider(db) : TVRage; + SearchResult hit = selectSearchResult(query, service.search(query, locale), false); + + Analytics.trackEvent("CLI", "PrintEpisodeList", hit.getName()); + for (Episode it : service.getEpisodeList(hit, locale)) { + String string = (format != null) ? format.format(new MediaBindingBean(it, null)) : EpisodeFormat.SeasonEpisode.format(it); + System.out.println(string); + } + } }