* support --filter when using -list
This commit is contained in:
parent
26d3b51a84
commit
44e69dfe9c
|
@ -38,7 +38,8 @@ public class ArgumentProcessor {
|
||||||
try {
|
try {
|
||||||
// print episode info
|
// print episode info
|
||||||
if (args.list) {
|
if (args.list) {
|
||||||
for (String eps : cli.fetchEpisodeList(args.query, args.format, args.db, args.order, args.lang)) {
|
CLILogger.setLevel(Level.WARNING); // make sure to disable any logging on standard output
|
||||||
|
for (String eps : cli.fetchEpisodeList(args.query, args.format, args.db, args.order, args.filter, args.lang)) {
|
||||||
System.out.println(eps);
|
System.out.println(eps);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -22,7 +22,7 @@ public interface CmdlineInterface {
|
||||||
|
|
||||||
File compute(Collection<File> files, String output, String encoding) throws Exception;
|
File compute(Collection<File> files, String output, String encoding) throws Exception;
|
||||||
|
|
||||||
List<String> fetchEpisodeList(String query, String format, String db, String sortOrder, String lang) throws Exception;
|
List<String> fetchEpisodeList(String query, String format, String db, String sortOrder, String filter, String lang) throws Exception;
|
||||||
|
|
||||||
String getMediaInfo(File file, String format) throws Exception;
|
String getMediaInfo(File file, String format) throws Exception;
|
||||||
|
|
||||||
|
|
|
@ -1033,25 +1033,30 @@ public class CmdlineOperations implements CmdlineInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> fetchEpisodeList(String query, String expression, String db, String sortOrderName, String languageName) throws Exception {
|
public List<String> fetchEpisodeList(String query, String expression, String db, String sortOrderName, String filterExpression, String languageName) throws Exception {
|
||||||
if (query == null || query.isEmpty())
|
if (query == null || query.isEmpty())
|
||||||
throw new IllegalArgumentException("query is not defined");
|
throw new IllegalArgumentException("query is not defined");
|
||||||
|
|
||||||
// find series on the web and fetch episode list
|
// find series on the web and fetch episode list
|
||||||
ExpressionFormat format = (expression != null) ? new ExpressionFormat(expression) : null;
|
ExpressionFormat format = (expression != null) ? new ExpressionFormat(expression) : null;
|
||||||
|
ExpressionFilter filter = (filterExpression != null) ? new ExpressionFilter(filterExpression) : null;
|
||||||
EpisodeListProvider service = (db == null) ? TheTVDB : getEpisodeListProvider(db);
|
EpisodeListProvider service = (db == null) ? TheTVDB : getEpisodeListProvider(db);
|
||||||
SortOrder sortOrder = SortOrder.forName(sortOrderName);
|
SortOrder sortOrder = SortOrder.forName(sortOrderName);
|
||||||
Locale locale = getLanguage(languageName).getLocale();
|
Locale locale = getLanguage(languageName).getLocale();
|
||||||
|
|
||||||
|
// fetch episode data
|
||||||
SearchResult hit = selectSearchResult(query, service.search(query, locale), false).get(0);
|
SearchResult hit = selectSearchResult(query, service.search(query, locale), false).get(0);
|
||||||
List<String> episodes = new ArrayList<String>();
|
List<Episode> episodes = service.getEpisodeList(hit, sortOrder, locale);
|
||||||
|
|
||||||
for (Episode it : service.getEpisodeList(hit, sortOrder, locale)) {
|
// apply filter
|
||||||
|
episodes = applyExpressionFilter(episodes, filter);
|
||||||
|
|
||||||
|
List<String> names = new ArrayList<String>();
|
||||||
|
for (Episode it : episodes) {
|
||||||
String name = (format != null) ? format.format(new MediaBindingBean(it, null, null)) : EpisodeFormat.SeasonEpisode.format(it);
|
String name = (format != null) ? format.format(new MediaBindingBean(it, null, null)) : EpisodeFormat.SeasonEpisode.format(it);
|
||||||
episodes.add(name);
|
names.add(name);
|
||||||
}
|
}
|
||||||
|
return names;
|
||||||
return episodes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -389,7 +389,7 @@ public abstract class ScriptShellBaseClass extends Script {
|
||||||
|
|
||||||
synchronized (cli) {
|
synchronized (cli) {
|
||||||
try {
|
try {
|
||||||
return cli.fetchEpisodeList(asString(option.get(Option.query)), asString(option.get(Option.format)), asString(option.get(Option.db)), asString(option.get(Option.order)), asString(option.get(Option.lang)));
|
return cli.fetchEpisodeList(asString(option.get(Option.query)), asString(option.get(Option.format)), asString(option.get(Option.db)), asString(option.get(Option.order)), asString(option.get(Option.filter)), asString(option.get(Option.lang)));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
printException(e);
|
printException(e);
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue