* add cli support for outputting episode list info

This commit is contained in:
Reinhard Pointner 2011-10-14 17:48:17 +00:00
parent 55db3e62bc
commit 90f5993e10
2 changed files with 24 additions and 1 deletions

View File

@ -27,6 +27,9 @@ public class ArgumentBean {
@Option(name = "-rename", usage = "Rename episode/movie files", metaVar = "fileset") @Option(name = "-rename", usage = "Rename episode/movie files", metaVar = "fileset")
public boolean rename = false; 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]") @Option(name = "--db", usage = "Episode/Movie database", metaVar = "[TVRage, AniDB, TheTVDB] or [OpenSubtitles, TheMovieDB]")
public String db; public String db;
@ -74,7 +77,7 @@ public class ArgumentBean {
public boolean runCLI() { public boolean runCLI() {
return rename || getSubtitles || check; return rename || getSubtitles || check || list;
} }

View File

@ -64,6 +64,13 @@ public class ArgumentProcessor {
Analytics.trackView(ArgumentProcessor.class, "FileBot CLI"); Analytics.trackView(ArgumentProcessor.class, "FileBot CLI");
CLILogger.setLevel(args.getLogLevel()); CLILogger.setLevel(args.getLogLevel());
// print operations
if (args.list) {
printEpisodeList(args.query, args.getEpisodeFormat(), args.db, args.getLanguage().toLocale());
return 0;
}
// file operations
try { try {
Set<File> files = new LinkedHashSet<File>(args.getFiles(true)); Set<File> files = new LinkedHashSet<File>(args.getFiles(true));
@ -599,4 +606,17 @@ public class ArgumentProcessor {
out.close(); 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);
}
}
} }