mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-02 00:15:02 -04:00
CASE_INSENSITIVE_PATH_ORDER
HUMAN_NAME_ORDER
This commit is contained in:
parent
56316af826
commit
e3fe2fd094
@ -458,7 +458,7 @@ public abstract class ScriptShellBaseClass extends Script {
|
|||||||
|
|
||||||
Object folder = parameters.get("folder");
|
Object folder = parameters.get("folder");
|
||||||
if (folder != null) {
|
if (folder != null) {
|
||||||
return listFiles(asFileList(folder), 0, FILES, HUMAN_ORDER);
|
return listFiles(asFileList(folder), 0, FILES, HUMAN_NAME_ORDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
return emptyList();
|
return emptyList();
|
||||||
|
@ -118,7 +118,7 @@ public class ScriptShellMethods {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<File> listTree(File self, int maxDepth) {
|
public static List<File> listTree(File self, int maxDepth) {
|
||||||
return FileUtilities.listFiles(singleton(self), maxDepth, FILES, HUMAN_ORDER);
|
return FileUtilities.listFiles(singleton(self), maxDepth, FILES, HUMAN_NAME_ORDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<File> getFiles(File self) {
|
public static List<File> getFiles(File self) {
|
||||||
@ -136,7 +136,7 @@ public class ScriptShellMethods {
|
|||||||
public static List<File> getFiles(Collection<?> self, Closure<?> closure) {
|
public static List<File> getFiles(Collection<?> self, Closure<?> closure) {
|
||||||
List<File> roots = FileUtilities.asFileList(self.toArray());
|
List<File> roots = FileUtilities.asFileList(self.toArray());
|
||||||
|
|
||||||
List<File> files = FileUtilities.listFiles(roots, FILES, HUMAN_ORDER);
|
List<File> files = FileUtilities.listFiles(roots, FILES, HUMAN_NAME_ORDER);
|
||||||
if (closure != null) {
|
if (closure != null) {
|
||||||
files = DefaultGroovyMethods.findAll(files, closure);
|
files = DefaultGroovyMethods.findAll(files, closure);
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ public class ScriptShellMethods {
|
|||||||
public static List<File> getFolders(Collection<?> self, Closure<?> closure) {
|
public static List<File> getFolders(Collection<?> self, Closure<?> closure) {
|
||||||
List<File> roots = FileUtilities.asFileList(self.toArray());
|
List<File> roots = FileUtilities.asFileList(self.toArray());
|
||||||
|
|
||||||
List<File> folders = FileUtilities.listFolders(roots, HUMAN_ORDER);
|
List<File> folders = FileUtilities.listFolders(roots, HUMAN_NAME_ORDER);
|
||||||
if (closure != null) {
|
if (closure != null) {
|
||||||
folders = DefaultGroovyMethods.findAll(folders, closure);
|
folders = DefaultGroovyMethods.findAll(folders, closure);
|
||||||
}
|
}
|
||||||
|
@ -990,7 +990,7 @@ public class MediaBindingBean {
|
|||||||
public File getInferredMediaFile() {
|
public File getInferredMediaFile() {
|
||||||
if (getMediaFile().isDirectory()) {
|
if (getMediaFile().isDirectory()) {
|
||||||
// just select the first video file in the folder as media sample
|
// just select the first video file in the folder as media sample
|
||||||
List<File> videos = listFiles(getMediaFile(), VIDEO_FILES, CASE_INSENSITIVE_ORDER);
|
List<File> videos = listFiles(getMediaFile(), VIDEO_FILES, CASE_INSENSITIVE_PATH_ORDER);
|
||||||
if (videos.size() > 0) {
|
if (videos.size() > 0) {
|
||||||
return videos.get(0);
|
return videos.get(0);
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,7 @@ public class AutoDetection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean commonNumberPattern() {
|
public boolean commonNumberPattern() {
|
||||||
return getChildren(f.getParentFile(), VIDEO_FILES, HUMAN_ORDER).stream().filter(it -> {
|
return getChildren(f.getParentFile(), VIDEO_FILES, HUMAN_NAME_ORDER).stream().filter(it -> {
|
||||||
return find(dn, snm) || find(normalize(it.getName()), snm);
|
return find(dn, snm) || find(normalize(it.getName()), snm);
|
||||||
}).map(it -> {
|
}).map(it -> {
|
||||||
return streamMatches(it.getName(), EPISODE_NUMBERS).map(Integer::new).collect(toSet());
|
return streamMatches(it.getName(), EPISODE_NUMBERS).map(Integer::new).collect(toSet());
|
||||||
|
@ -55,7 +55,7 @@ class AttributeTool extends Tool<TableModel> {
|
|||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<File> files = listFiles(root, filter(VIDEO_FILES, SUBTITLE_FILES), HUMAN_ORDER);
|
List<File> files = listFiles(root, filter(VIDEO_FILES, SUBTITLE_FILES), HUMAN_NAME_ORDER);
|
||||||
|
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
Object metaObject = xattr.getMetaInfo(file);
|
Object metaObject = xattr.getMetaInfo(file);
|
||||||
|
@ -82,7 +82,7 @@ class ExtractTool extends Tool<TableModel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ignore non-archives files and trailing multi-volume parts
|
// ignore non-archives files and trailing multi-volume parts
|
||||||
List<File> files = listFiles(root, Archive.VOLUME_ONE_FILTER, HUMAN_ORDER);
|
List<File> files = listFiles(root, Archive.VOLUME_ONE_FILTER, HUMAN_NAME_ORDER);
|
||||||
List<ArchiveEntry> entries = new ArrayList<ArchiveEntry>();
|
List<ArchiveEntry> entries = new ArrayList<ArchiveEntry>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -87,7 +87,7 @@ class FileTreeTransferablePolicy extends BackgroundFileTransferablePolicy<TreeNo
|
|||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
LinkedList<TreeNode> children = new LinkedList<TreeNode>();
|
LinkedList<TreeNode> children = new LinkedList<TreeNode>();
|
||||||
|
|
||||||
for (File f : getChildren(file, NOT_HIDDEN, HUMAN_ORDER)) {
|
for (File f : getChildren(file, NOT_HIDDEN, HUMAN_NAME_ORDER)) {
|
||||||
if (f.isDirectory()) {
|
if (f.isDirectory()) {
|
||||||
children.addFirst(getTreeNode(f));
|
children.addFirst(getTreeNode(f));
|
||||||
} else {
|
} else {
|
||||||
|
@ -58,7 +58,7 @@ class MediaInfoTool extends Tool<TableModel> {
|
|||||||
return new MediaInfoTableModel();
|
return new MediaInfoTableModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<File> files = listFiles(root, filter(VIDEO_FILES, AUDIO_FILES), HUMAN_ORDER);
|
List<File> files = listFiles(root, filter(VIDEO_FILES, AUDIO_FILES), HUMAN_NAME_ORDER);
|
||||||
Map<MediaInfoKey, String[]> data = new TreeMap<MediaInfoKey, String[]>();
|
Map<MediaInfoKey, String[]> data = new TreeMap<MediaInfoKey, String[]>();
|
||||||
|
|
||||||
try (MediaInfo mi = new MediaInfo()) {
|
try (MediaInfo mi = new MediaInfo()) {
|
||||||
|
@ -76,7 +76,7 @@ class SplitTool extends Tool<TreeModel> {
|
|||||||
int nextPart = 1;
|
int nextPart = 1;
|
||||||
long splitSize = getSplitSize();
|
long splitSize = getSplitSize();
|
||||||
|
|
||||||
List<File> files = listFiles(root, FILES, HUMAN_ORDER);
|
List<File> files = listFiles(root, FILES, HUMAN_NAME_ORDER);
|
||||||
|
|
||||||
List<TreeNode> rootGroup = new ArrayList<TreeNode>();
|
List<TreeNode> rootGroup = new ArrayList<TreeNode>();
|
||||||
List<File> currentPart = new ArrayList<File>();
|
List<File> currentPart = new ArrayList<File>();
|
||||||
|
@ -49,7 +49,7 @@ class TypeTool extends Tool<TreeModel> {
|
|||||||
return new DefaultTreeModel(new FolderNode("Types", emptyList()));
|
return new DefaultTreeModel(new FolderNode("Types", emptyList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<File> filesAndFolders = listFiles(root, NOT_HIDDEN, HUMAN_ORDER);
|
List<File> filesAndFolders = listFiles(root, NOT_HIDDEN, HUMAN_NAME_ORDER);
|
||||||
List<TreeNode> groups = new ArrayList<TreeNode>();
|
List<TreeNode> groups = new ArrayList<TreeNode>();
|
||||||
|
|
||||||
for (Entry<String, FileFilter> it : getMetaTypes().entrySet()) {
|
for (Entry<String, FileFilter> it : getMetaTypes().entrySet()) {
|
||||||
|
@ -84,7 +84,7 @@ class FileListTransferablePolicy extends FileTransferablePolicy {
|
|||||||
|
|
||||||
// load all files from the given folders recursively up do a depth of 32
|
// load all files from the given folders recursively up do a depth of 32
|
||||||
format.accept(ListPanel.DEFAULT_FILE_FORMAT);
|
format.accept(ListPanel.DEFAULT_FILE_FORMAT);
|
||||||
model.accept(listFiles(files, FILES, HUMAN_ORDER));
|
model.accept(listFiles(files, FILES, HUMAN_NAME_ORDER));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected String getQueryInputMessage(String header, String message, Collection<File> files) throws Exception {
|
protected String getQueryInputMessage(String header, String message, Collection<File> files) throws Exception {
|
||||||
List<File> selection = files.stream().sorted(comparing(File::length).reversed()).limit(5).sorted(HUMAN_ORDER).collect(toList());
|
List<File> selection = files.stream().sorted(comparing(File::length).reversed()).limit(5).sorted(HUMAN_NAME_ORDER).collect(toList());
|
||||||
if (selection.isEmpty()) {
|
if (selection.isEmpty()) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ class FilesListTransferablePolicy extends BackgroundFileTransferablePolicy<File>
|
|||||||
|
|
||||||
// load folders recursively
|
// load folders recursively
|
||||||
else if (f.isDirectory()) {
|
else if (f.isDirectory()) {
|
||||||
load(getChildren(f, NOT_HIDDEN, HUMAN_ORDER), true, sink); // FORCE NATURAL FILE ORDER
|
load(getChildren(f, NOT_HIDDEN, HUMAN_NAME_ORDER), true, sink); // FORCE NATURAL FILE ORDER
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ class NamesListTransferablePolicy extends FileTransferablePolicy {
|
|||||||
loadTorrentFiles(files, values);
|
loadTorrentFiles(files, values);
|
||||||
} else {
|
} else {
|
||||||
// load all files from the given folders recursively up do a depth of 32
|
// load all files from the given folders recursively up do a depth of 32
|
||||||
listFiles(files, FILES, HUMAN_ORDER).stream().map(FastFile::new).forEach(values::add);
|
listFiles(files, FILES, HUMAN_NAME_ORDER).stream().map(FastFile::new).forEach(values::add);
|
||||||
}
|
}
|
||||||
|
|
||||||
model.addAll(values);
|
model.addAll(values);
|
||||||
|
@ -84,7 +84,7 @@ public class Preset {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return listFiles(getInputFolder(), f -> f.isFile() && filter.accept(f), HUMAN_ORDER);
|
return listFiles(getInputFolder(), f -> f.isFile() && filter.accept(f), HUMAN_NAME_ORDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AutoCompleteMatcher getAutoCompleteMatcher() {
|
public AutoCompleteMatcher getAutoCompleteMatcher() {
|
||||||
|
@ -96,7 +96,7 @@ class ChecksumTableTransferablePolicy extends BackgroundFileTransferablePolicy<C
|
|||||||
// handle single folder drop
|
// handle single folder drop
|
||||||
if (files.size() == 1 && containsOnly(files, FOLDERS)) {
|
if (files.size() == 1 && containsOnly(files, FOLDERS)) {
|
||||||
for (File folder : files) {
|
for (File folder : files) {
|
||||||
for (File file : getChildren(folder, NOT_HIDDEN, HUMAN_ORDER)) {
|
for (File file : getChildren(folder, NOT_HIDDEN, HUMAN_NAME_ORDER)) {
|
||||||
load(file, null, folder);
|
load(file, null, folder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -179,7 +179,7 @@ class ChecksumTableTransferablePolicy extends BackgroundFileTransferablePolicy<C
|
|||||||
|
|
||||||
if (absoluteFile.isDirectory()) {
|
if (absoluteFile.isDirectory()) {
|
||||||
// load all files in the file tree
|
// load all files in the file tree
|
||||||
for (File child : getChildren(absoluteFile, NOT_HIDDEN, HUMAN_ORDER)) {
|
for (File child : getChildren(absoluteFile, NOT_HIDDEN, HUMAN_NAME_ORDER)) {
|
||||||
load(child, relativeFile, root);
|
load(child, relativeFile, root);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -175,7 +175,7 @@ abstract class SubtitleDropTarget extends JButton {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<File> files = listFiles(selection, VIDEO_FILES, HUMAN_ORDER);
|
List<File> files = listFiles(selection, VIDEO_FILES, HUMAN_NAME_ORDER);
|
||||||
|
|
||||||
if (files.size() > 0) {
|
if (files.size() > 0) {
|
||||||
handleDownload(files);
|
handleDownload(files);
|
||||||
@ -249,7 +249,7 @@ abstract class SubtitleDropTarget extends JButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// perform a drop action depending on the given files
|
// perform a drop action depending on the given files
|
||||||
List<File> files = listFiles(selection, FILES, HUMAN_ORDER);
|
List<File> files = listFiles(selection, FILES, HUMAN_NAME_ORDER);
|
||||||
|
|
||||||
List<File> videos = filter(files, VIDEO_FILES);
|
List<File> videos = filter(files, VIDEO_FILES);
|
||||||
List<File> subtitles = filter(files, SUBTITLE_FILES);
|
List<File> subtitles = filter(files, SUBTITLE_FILES);
|
||||||
|
@ -365,7 +365,7 @@ public final class FileUtilities {
|
|||||||
|
|
||||||
public static List<File> sortByUniquePath(Collection<File> files) {
|
public static List<File> sortByUniquePath(Collection<File> files) {
|
||||||
// sort by unique lower-case paths
|
// sort by unique lower-case paths
|
||||||
TreeSet<File> sortedSet = new TreeSet<File>(CASE_INSENSITIVE_ORDER);
|
TreeSet<File> sortedSet = new TreeSet<File>(CASE_INSENSITIVE_PATH_ORDER);
|
||||||
sortedSet.addAll(files);
|
sortedSet.addAll(files);
|
||||||
|
|
||||||
return new ArrayList<File>(sortedSet);
|
return new ArrayList<File>(sortedSet);
|
||||||
@ -787,9 +787,9 @@ public final class FileUtilities {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Comparator<File> CASE_INSENSITIVE_ORDER = comparing(File::getPath, String.CASE_INSENSITIVE_ORDER);
|
public static final Comparator<File> CASE_INSENSITIVE_PATH_ORDER = comparing(File::getPath, String.CASE_INSENSITIVE_ORDER);
|
||||||
|
|
||||||
public static final Comparator<File> HUMAN_ORDER = comparing(File::getName, new AlphanumComparator(Locale.ENGLISH));
|
public static final Comparator<File> HUMAN_NAME_ORDER = comparing(File::getName, new AlphanumComparator(Locale.ENGLISH));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dummy constructor to prevent instantiation.
|
* Dummy constructor to prevent instantiation.
|
||||||
|
Loading…
Reference in New Issue
Block a user