1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-08-13 17:03:45 -04:00

Ignore ~/Movies for auto-detection purposes

This commit is contained in:
Reinhard Pointner 2016-04-06 20:19:32 +00:00
parent a8dda17b9c
commit 036cefea51
3 changed files with 13 additions and 11 deletions

View File

@ -69,7 +69,7 @@ public class AutoDetection {
}
private static final Pattern MOVIE_PATTERN = Pattern.compile("Movies", CASE_INSENSITIVE);
private static final Pattern SERIES_PATTERN = Pattern.compile("TV.Shows|Season.[0-9]+", CASE_INSENSITIVE);
private static final Pattern SERIES_PATTERN = Pattern.compile("TV.Shows|TV.Series|Season.[0-9]+", CASE_INSENSITIVE);
private static final Pattern ANIME_PATTERN = Pattern.compile("Anime", CASE_INSENSITIVE);
public boolean isMusic(File f) {
@ -103,7 +103,7 @@ public class AutoDetection {
}
public boolean anyMatch(File file, Pattern pattern) {
for (File f = file; f != null; f = f.getParentFile()) {
for (File f = file; f != null && !MediaDetection.isVolumeRoot(f); f = f.getParentFile()) {
if (pattern.matcher(f.getName()).matches()) {
return true;
}
@ -135,7 +135,7 @@ public class AutoDetection {
if (isMusic(f))
return group.music(f);
if (isMovie(f) && !isEpisode(f)) // episode characteristics override movie characteristics (e.g. episodes in Movies folder)
if (isMovie(f)) // episode characteristics override movie characteristics (e.g. episodes in Movies folder)
return group.movie(getMovieMatches(f, false));
if (isEpisode(f))
return group.series(getSeriesMatches(f, false));

View File

@ -980,11 +980,12 @@ public class MediaDetection {
return formatInfoPattern.matcher(name).replaceAll("");
}
public static boolean isVolumeRoot(File folder) {
return folder == null || folder.getName() == null || folder.getName().isEmpty() || releaseInfo.getVolumeRoots().contains(folder);
}
public static boolean isStructureRoot(File folder) throws Exception {
if (folder == null || folder.getName() == null || folder.getName().isEmpty() || releaseInfo.getVolumeRoots().contains(folder)) {
return true;
}
return releaseInfo.getStructureRootPattern().matcher(folder.getName()).matches();
return isVolumeRoot(folder) || releaseInfo.getStructureRootPattern().matcher(folder.getName()).matches();
}
public static File getStructureRoot(File file) throws Exception {

View File

@ -231,15 +231,16 @@ public class ReleaseInfo {
}
// user-specific media roots
String username = System.getProperty("user.name", "anonymous");
for (File mediaRoot : getMediaRoots()) {
volumes.addAll(getChildren(mediaRoot, FOLDERS));
volumes.add(mediaRoot);
// add additional user roots if user.home is not set properly or listFiles doesn't work
String username = System.getProperty("user.name");
if (username != null && username.length() > 0) {
volumes.add(new File(mediaRoot, username));
}
File userRoot = new File(mediaRoot, username);
volumes.add(userRoot);
volumes.add(new File(userRoot, "Movies")); // ignore default Movie folder on Mac
}
}