mirror of
https://github.com/mitb-archive/filebot
synced 2025-01-11 05:48:01 -05:00
* easy access to the structure relative path, might be useful for scripting latter to exclude home folders and the likes from any kind of checking
This commit is contained in:
parent
06a47a3375
commit
0438e4756f
@ -330,6 +330,10 @@ public class ScriptShellMethods {
|
||||
return JsonReader.jsonToJava(self);
|
||||
}
|
||||
|
||||
public static File getStructurePathTail(File self) throws IOException {
|
||||
return MediaDetection.getStructurePathTail(self);
|
||||
}
|
||||
|
||||
public static FolderWatchService watch(File self, final Closure<?> callback) throws IOException {
|
||||
FolderWatchService watchService = new FolderWatchService(true) {
|
||||
|
||||
|
@ -57,6 +57,7 @@ import net.filebot.similarity.SeriesNameMatcher;
|
||||
import net.filebot.similarity.SimilarityComparator;
|
||||
import net.filebot.similarity.SimilarityMetric;
|
||||
import net.filebot.similarity.StringEqualsMetric;
|
||||
import net.filebot.util.StringUtilities;
|
||||
import net.filebot.vfs.FileInfo;
|
||||
import net.filebot.web.Episode;
|
||||
import net.filebot.web.Movie;
|
||||
@ -999,6 +1000,20 @@ public class MediaDetection {
|
||||
return releaseInfo.getStructureRootPattern().matcher(folder.getName()).matches();
|
||||
}
|
||||
|
||||
public static File getStructurePathTail(File file) throws IOException {
|
||||
LinkedList<String> relativePath = new LinkedList<String>();
|
||||
|
||||
// iterate path in reverse
|
||||
for (File it : listPathTail(file, Integer.MAX_VALUE, true)) {
|
||||
if (isStructureRoot(it))
|
||||
break;
|
||||
|
||||
relativePath.addFirst(it.getName());
|
||||
}
|
||||
|
||||
return relativePath.isEmpty() ? null : new File(StringUtilities.join(relativePath, File.separator));
|
||||
}
|
||||
|
||||
public static Map<File, List<File>> mapByMediaFolder(Collection<File> files) {
|
||||
Map<File, List<File>> mediaFolders = new HashMap<File, List<File>>();
|
||||
for (File f : files) {
|
||||
|
Loading…
Reference in New Issue
Block a user