mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-23 08:18:52 -05:00
+ Support --filter (file filter expression) in filebot -mediainfo calls
This commit is contained in:
parent
bf858e54bc
commit
8d19863283
@ -46,8 +46,8 @@ public class ArgumentProcessor {
|
||||
|
||||
// print media info
|
||||
if (args.mediaInfo) {
|
||||
for (File file : args.getFiles(true)) {
|
||||
System.out.println(cli.getMediaInfo(file, args.format));
|
||||
for (String line : cli.getMediaInfo(args.getFiles(true), args.format, args.filter)) {
|
||||
System.out.println(line);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public interface CmdlineInterface {
|
||||
|
||||
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;
|
||||
List<String> getMediaInfo(Collection<File> files, String format, String filter) throws Exception;
|
||||
|
||||
List<File> extract(Collection<File> files, String output, String conflict, FileFilter filter, boolean forceExtractAll) throws Exception;
|
||||
|
||||
|
@ -43,6 +43,7 @@ import net.filebot.RenameAction;
|
||||
import net.filebot.StandardRenameAction;
|
||||
import net.filebot.archive.Archive;
|
||||
import net.filebot.archive.FileMapper;
|
||||
import net.filebot.format.ExpressionFileFilter;
|
||||
import net.filebot.format.ExpressionFilter;
|
||||
import net.filebot.format.ExpressionFormat;
|
||||
import net.filebot.format.MediaBindingBean;
|
||||
@ -1115,9 +1116,23 @@ public class CmdlineOperations implements CmdlineInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMediaInfo(File file, String expression) throws Exception {
|
||||
ExpressionFormat format = new ExpressionFormat(expression != null ? expression : "{fn} [{resolution} {af} {vc} {ac}]");
|
||||
return format.format(new MediaBindingBean(readMetaInfo(file), file, null));
|
||||
public List<String> getMediaInfo(Collection<File> files, String format, String filter) throws Exception {
|
||||
if (filter != null && filter.length() > 0) {
|
||||
ExpressionFileFilter includes = new ExpressionFileFilter(new ExpressionFilter(filter), false);
|
||||
files = filter(files, includes);
|
||||
|
||||
if (files.isEmpty()) {
|
||||
throw new CmdlineException("No files: " + files);
|
||||
}
|
||||
}
|
||||
|
||||
ExpressionFormat formatter = new ExpressionFormat(format != null && format.length() > 0 ? format : "{fn} [{resolution} {af} {vc} {ac}]");
|
||||
List<String> output = new ArrayList<String>();
|
||||
for (File file : files) {
|
||||
String line = formatter.format(new MediaBindingBean(readMetaInfo(file), file, null));
|
||||
output.add(line);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -420,10 +420,15 @@ public abstract class ScriptShellBaseClass extends Script {
|
||||
|
||||
public String getMediaInfo(Map<String, ?> parameters) throws Exception {
|
||||
List<File> input = getInputFileList(parameters);
|
||||
if (input == null || input.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Map<Option, Object> option = getDefaultOptions(parameters);
|
||||
synchronized (cli) {
|
||||
try {
|
||||
return cli.getMediaInfo(input.get(0), asString(option.get(Option.format)));
|
||||
List<String> lines = cli.getMediaInfo(singleton(input.get(0)), asString(option.get(Option.format)), asString(option.get(Option.filter)));
|
||||
return lines.get(0);
|
||||
} catch (Exception e) {
|
||||
printException(e, false);
|
||||
return null;
|
||||
|
@ -1,13 +1,10 @@
|
||||
package net.filebot.ui.rename;
|
||||
package net.filebot.format;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.filebot.format.ExpressionFilter;
|
||||
import net.filebot.format.MediaBindingBean;
|
||||
|
||||
public class ExpressionFileFilter implements FileFilter {
|
||||
|
||||
private final ExpressionFilter filter;
|
@ -12,6 +12,7 @@ import net.filebot.Language;
|
||||
import net.filebot.Settings;
|
||||
import net.filebot.StandardRenameAction;
|
||||
import net.filebot.WebServices;
|
||||
import net.filebot.format.ExpressionFileFilter;
|
||||
import net.filebot.format.ExpressionFilter;
|
||||
import net.filebot.format.ExpressionFormat;
|
||||
import net.filebot.mac.MacAppUtilities;
|
||||
|
@ -16,10 +16,10 @@ NCIS: New Orleans NCIS NO
|
||||
Proof (2015) Proof (US)
|
||||
Resurrection Resurrection (US)
|
||||
Revolution Revolution (2012)
|
||||
Scream Scream The TV Series
|
||||
The Big Bang Theory TBBT
|
||||
The Bridge (2013) The Bridge (US)
|
||||
The Code (2014) The Code (AU)
|
||||
The Late Late Show with Craig Ferguson Craig Ferguson
|
||||
The Walking Dead TWD
|
||||
World Series of Poker WSOP
|
||||
Scream Scream The TV Series
|
||||
World Series of Poker WSOP
|
Loading…
Reference in New Issue
Block a user