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