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 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); private static final Pattern ANIME_PATTERN = Pattern.compile("Anime", CASE_INSENSITIVE);
public boolean isMusic(File f) { public boolean isMusic(File f) {
@ -103,7 +103,7 @@ public class AutoDetection {
} }
public boolean anyMatch(File file, Pattern pattern) { 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()) { if (pattern.matcher(f.getName()).matches()) {
return true; return true;
} }
@ -135,7 +135,7 @@ public class AutoDetection {
if (isMusic(f)) if (isMusic(f))
return group.music(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)); return group.movie(getMovieMatches(f, false));
if (isEpisode(f)) if (isEpisode(f))
return group.series(getSeriesMatches(f, false)); return group.series(getSeriesMatches(f, false));

View File

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

View File

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