* include filters for Episode and Movie file types in Analyze panel
This commit is contained in:
parent
7ecb4cb146
commit
def3605db8
|
@ -18,13 +18,12 @@ public class AnalyzePanel extends JComponent {
|
|||
toolsPanel.setBorder(BorderFactory.createTitledBorder("Tools"));
|
||||
|
||||
setLayout(new MigLayout("insets dialog, gapx 50, fill"));
|
||||
|
||||
add(fileTreePanel, "grow, sizegroupx column");
|
||||
add(toolsPanel, "grow, sizegroupx column");
|
||||
|
||||
addTool(new ExtractTool());
|
||||
addTool(new SplitTool());
|
||||
addTool(new TypeTool());
|
||||
addTool(new SplitTool());
|
||||
addTool(new AttributeTool());
|
||||
|
||||
putClientProperty("transferablePolicy", fileTreePanel.getTransferablePolicy());
|
||||
|
|
|
@ -30,7 +30,7 @@ class SplitTool extends Tool<TreeModel> {
|
|||
private SpinnerNumberModel spinnerModel = new SpinnerNumberModel(4480, 0, Integer.MAX_VALUE, 100);
|
||||
|
||||
public SplitTool() {
|
||||
super("Disks");
|
||||
super("Parts");
|
||||
|
||||
JScrollPane treeScrollPane = new JScrollPane(tree);
|
||||
treeScrollPane.setBorder(new SeparatorBorder(2, new Color(0, 0, 0, 90), GradientStyle.TOP_TO_BOTTOM, SeparatorBorder.Position.BOTTOM));
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package net.filebot.ui.analyze;
|
||||
|
||||
import static java.util.Arrays.*;
|
||||
import static java.util.Collections.*;
|
||||
import static net.filebot.MediaTypes.*;
|
||||
import static net.filebot.util.FileUtilities.*;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -37,7 +39,6 @@ class TypeTool extends Tool<TreeModel> {
|
|||
super("Types");
|
||||
|
||||
setLayout(new MigLayout("insets 0, fill"));
|
||||
|
||||
JScrollPane treeScrollPane = new JScrollPane(tree);
|
||||
treeScrollPane.setBorder(BorderFactory.createEmptyBorder());
|
||||
|
||||
|
@ -49,7 +50,7 @@ class TypeTool extends Tool<TreeModel> {
|
|||
|
||||
@Override
|
||||
protected TreeModel createModelInBackground(File root) throws InterruptedException {
|
||||
List<File> filesAndFolders = (root != null) ? listFiles(singleton(root), FILE_WALK_MAX_DEPTH, false, true, true) : new ArrayList<File>();
|
||||
List<File> filesAndFolders = (root != null) ? listFiles(singleton(root), FILE_WALK_MAX_DEPTH, true, true, true) : new ArrayList<File>();
|
||||
List<TreeNode> groups = new ArrayList<TreeNode>();
|
||||
|
||||
for (Entry<String, FileFilter> it : getMetaTypes().entrySet()) {
|
||||
|
@ -74,20 +75,46 @@ class TypeTool extends Tool<TreeModel> {
|
|||
|
||||
public Map<String, FileFilter> getMetaTypes() {
|
||||
Map<String, FileFilter> types = new LinkedHashMap<String, FileFilter>();
|
||||
try {
|
||||
types.put("Episode", new EpisodeFilter());
|
||||
types.put("Movie", new MovieFilter());
|
||||
types.put("Video", MediaTypes.VIDEO_FILES);
|
||||
types.put("Disk Folder", MediaDetection.getDiskFolderFilter());
|
||||
types.put("Subtitle", MediaTypes.SUBTITLE_FILES);
|
||||
types.put("Audio", MediaTypes.AUDIO_FILES);
|
||||
types.put("Archive", MediaTypes.ARCHIVE_FILES);
|
||||
types.put("Verification", MediaTypes.VERIFICATION_FILES);
|
||||
try {
|
||||
types.put("Clutter", MediaDetection.getClutterFileFilter());
|
||||
types.put("Disk Folder", MediaDetection.getDiskFolderFilter());
|
||||
} catch (IOException e) {
|
||||
Logger.getLogger(TypeTool.class.getName()).log(Level.WARNING, e.getMessage());
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
private static class EpisodeFilter implements FileFilter {
|
||||
|
||||
private final static long MAX_SIZE = 50 * MEGA;
|
||||
|
||||
@Override
|
||||
public boolean accept(File file) {
|
||||
return file.length() > MAX_SIZE && VIDEO_FILES.accept(file) && MediaDetection.isEpisode(file.getPath(), true);
|
||||
}
|
||||
}
|
||||
|
||||
private static class MovieFilter implements FileFilter {
|
||||
|
||||
private final static long MAX_SIZE = 500 * MEGA;
|
||||
|
||||
@Override
|
||||
public boolean accept(File file) {
|
||||
try {
|
||||
return file.length() > MAX_SIZE && VIDEO_FILES.accept(file) && !MediaDetection.isEpisode(file.getPath(), true) && MediaDetection.matchMovieName(asList(file.getName(), file.getParent()), true, 0).size() > 0;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setModel(TreeModel model) {
|
||||
tree.setModel(model);
|
||||
|
|
|
@ -647,7 +647,9 @@ public final class FileUtilities {
|
|||
public static final long GIGA = 1024 * MEGA;
|
||||
|
||||
public static String formatSize(long size) {
|
||||
if (size >= MEGA)
|
||||
if (size >= GIGA)
|
||||
return String.format("%,d GB", size / GIGA);
|
||||
else if (size >= MEGA)
|
||||
return String.format("%,d MB", size / MEGA);
|
||||
else if (size >= KILO)
|
||||
return String.format("%,d KB", size / KILO);
|
||||
|
|
Loading…
Reference in New Issue