mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-16 14:25:02 -05:00
Refactor
This commit is contained in:
parent
e3fe2fd094
commit
5b290cf0ae
@ -21,6 +21,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import org.codehaus.groovy.runtime.DefaultGroovyMethods;
|
import org.codehaus.groovy.runtime.DefaultGroovyMethods;
|
||||||
|
|
||||||
@ -168,7 +170,7 @@ public class ScriptShellMethods {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<File> getMediaFolders(File self) throws IOException {
|
public static List<File> getMediaFolders(File self) throws IOException {
|
||||||
final List<File> mediaFolders = new ArrayList<File>();
|
SortedSet<File> folders = new TreeSet<File>(CASE_INSENSITIVE_PATH_ORDER);
|
||||||
|
|
||||||
Files.walkFileTree(self.toPath(), new SimpleFileVisitor<Path>() {
|
Files.walkFileTree(self.toPath(), new SimpleFileVisitor<Path>() {
|
||||||
|
|
||||||
@ -181,7 +183,7 @@ public class ScriptShellMethods {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (FileUtilities.getChildren(folder, VIDEO_FILES).size() > 0 || MediaDetection.isDiskFolder(folder)) {
|
if (FileUtilities.getChildren(folder, VIDEO_FILES).size() > 0 || MediaDetection.isDiskFolder(folder)) {
|
||||||
mediaFolders.add(folder);
|
folders.add(folder);
|
||||||
return FileVisitResult.SKIP_SUBTREE;
|
return FileVisitResult.SKIP_SUBTREE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,19 +191,13 @@ public class ScriptShellMethods {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return FileUtilities.sortByUniquePath(mediaFolders);
|
return new ArrayList<File>(folders);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Iterable<File> eachMediaFolder(Collection<?> folders, Closure<?> closure) throws IOException {
|
public static void eachMediaFolder(Collection<?> self, Closure<?> closure) throws IOException {
|
||||||
List<File> mediaFolders = new ArrayList<File>();
|
for (File it : FileUtilities.asFileList(self)) {
|
||||||
for (File root : FileUtilities.asFileList(folders)) {
|
DefaultGroovyMethods.each(getMediaFolders(it), closure);
|
||||||
mediaFolders.addAll(getMediaFolders(root));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove duplicates
|
|
||||||
mediaFolders = FileUtilities.sortByUniquePath(mediaFolders);
|
|
||||||
|
|
||||||
return DefaultGroovyMethods.each(mediaFolders, closure);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getNameWithoutExtension(File self) {
|
public static String getNameWithoutExtension(File self) {
|
||||||
|
Loading…
Reference in New Issue
Block a user