Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: utilities/Config.java
- ===================================================================
- --- utilities/Config.java (revision 8)
- +++ utilities/Config.java (working copy)
- @@ -146,10 +146,10 @@
- //populate charactes that we do not allow in file names
- - char[] specialChars = {'<', '>', ':', '"', '/', '\\', '|', '?', '*', '*', '~', '’'};
- + char[] specialChars = {'<', '>', ':', '"', '/', '\\', '|', '?', '*', '*', '~', '٧};
- for(char c : specialChars) ILLEGAL_FILENAME_CHARS.put(new Integer((int) c), "illegal");
- - char[] uncommonChars = {'<', '>', ':', '"', '/', '\\', '|', '?', '*', '#', '$', '%', '^', '*', '!', '~','\'', '’', '=', '[' ,']', '(', ')', ';', '\\' ,',', '_'};
- + char[] uncommonChars = {'<', '>', ':', '"', '/', '\\', '|', '?', '*', '#', '$', '%', '^', '*', '!', '~','\'', '٧, '=', '[' ,']', '(', ')', ';', '\\' ,',', '_'};
- for(char c : uncommonChars) UNCOMMON_CHARS.put(new Integer((int) c), "illegal");
- //set up logs
- Index: utilities/Constants.java
- ===================================================================
- --- utilities/Constants.java (revision 8)
- +++ utilities/Constants.java (working copy)
- @@ -33,6 +33,9 @@
- public final static String MOVIE_SET = "MOVIE_SET";
- public final static String PREFIX = "PREFIX";
- public final static String SUFFIX = "SUFFIX";
- +
- + //AngryCamel - 20120805 2351
- + public final static String RUNTIME = "runtime";
- public final static String FOLDERS_ONLY = "FOLDERS_ONLY";
- public final static String FILES_ONLY = "FILES_ONLY";
- Index: utilities/Filter.java
- ===================================================================
- --- utilities/Filter.java (revision 8)
- +++ utilities/Filter.java (working copy)
- @@ -7,7 +7,7 @@
- public class Filter
- {
- - public static boolean FilterMatch(String path, Map<String, List<String>> filters)
- + public static boolean FilterMatch(String path, int runtime, Map<String, List<String>> filters)
- {
- if(filters == null || filters.isEmpty()) return true;//no filters to exclude on
- @@ -32,6 +32,127 @@
- if(!path.toLowerCase().contains(filterString.toLowerCase()))
- return false;//this path does not contains this string, return false because all filters must match
- }
- + //AngryCamel - 20120805 2351
- + // <runtime> - Matches if the runtime of the file fits the criteria specified in seconds along with the
- + // relational operator value. The format is "<relational_operator>|<runtime_seconds>". Posible relational
- + // operators are: EQ:Equal to, GT:Greater than, LT:Less than, NE:Not equal to, GE:Greater than or equal to,
- + // LE:Less than or equal to. Matches only on files and not directories.
- + // Example:
- + // <!-- (Recursive) Modern Marvels Episodes over 20 minutes long -->
- + // <subfolder name="History Channel/Modern Marvels" type="episodes" >
- + // <filter>
- + // <runtime>GT|1200</runtime>
- + // </filter>
- + // </subfolder>
- + else if(type.equalsIgnoreCase(Constants.RUNTIME))
- + {
- + String[] splitFilterStr;
- + int runtimeFilter = 0;
- + String operator = "";
- +
- + Config.log(Config.DEBUG, "Checking runtime filter: "+ filterString);
- +
- + splitFilterStr = filterString.split(Pattern.quote("|"));
- + if(splitFilterStr.length < 2)
- + return false;//filter string format invalid
- +
- + operator = splitFilterStr[0];
- +
- + try{
- + runtimeFilter = Integer.parseInt(splitFilterStr[1]);
- + }catch (NumberFormatException e){
- + Config.log(Config.DEBUG, "Failed parsing the runtime filter time to an integer: "+ splitFilterStr[1]);
- + return false;//filter string format invalid
- + }
- +
- + Config.log(Config.DEBUG, " Runtime Filter - operator: "+ operator);
- + Config.log(Config.DEBUG, " Runtime Filter - runtime: "+ runtimeFilter);
- + Config.log(Config.DEBUG, " Actual Runtime: "+ runtime);
- +
- + if(operator.equals("EQ"))
- + {
- + //Handle Equal To check here
- + if(runtime == runtimeFilter)
- + {
- + return true;
- + }
- + else
- + {
- + Config.log(Config.DEBUG, " Failed: actual runtime is not equal to the filter runtime");
- + return false;
- + }
- + }
- + else if(operator.equals("GT"))
- + {
- + //Handle Greater Than check here
- + if(runtime > runtimeFilter)
- + {
- + return true;
- + }
- + else
- + {
- + Config.log(Config.DEBUG, " Failed: actual runtime is not greater than the filter runtime");
- + return false;
- + }
- + }
- + else if(operator.equals("LT"))
- + {
- + //Handle Less Than check here
- + if(runtime < runtimeFilter)
- + {
- + return true;
- + }
- + else
- + {
- + Config.log(Config.DEBUG, " Failed: actual runtime is not less than the filter runtime");
- + return false;
- + }
- + }
- + else if(operator.equals("NE"))
- + {
- + //Handle Not Equal To check here
- + if(runtime != runtimeFilter)
- + {
- + return true;
- + }
- + else
- + {
- + Config.log(Config.DEBUG, " Failed: actual runtime is equal to the filter runtime");
- + return false;
- + }
- + }
- + else if(operator.equals("GE"))
- + {
- + //Handle Greater than or equal to check here
- + if(runtime >= runtimeFilter)
- + {
- + return true;
- + }
- + else
- + {
- + Config.log(Config.DEBUG, " Failed: actual runtime is not greater than or equal to the filter runtime");
- + return false;
- + }
- + }
- + else if(operator.equals("LE"))
- + {
- + //Handle Less than or equal to check here
- + if(runtime <= runtimeFilter)
- + {
- + return true;
- + }
- + else
- + {
- + Config.log(Config.DEBUG, " Failed: actual runtime is not less than or equal to the filter runtime");
- + return false;
- + }
- + }
- + else
- + {
- + Config.log(Config.DEBUG, " Failed: unkown relational operator");
- + return false;//unknown relational operator
- + }
- + }
- else
- {
- Config.log(Config.WARNING, "Unknown filter type: \""+type+"\"");
- Index: utilities/Subfolder.java
- ===================================================================
- --- utilities/Subfolder.java (revision 8)
- +++ utilities/Subfolder.java (working copy)
- @@ -341,14 +341,16 @@
- * Returns true if it is allowed by ALL filters or filter matching is not used
- * Returns false if this path should be skipped
- */
- - public boolean isAllowedByFilters(String path)
- + //AngryCamel - 20120805 2351
- + // public boolean isAllowedByFilters(String path)
- + public boolean isAllowedByFilters(String path, int runtime)
- {
- path = Config.escapePath(path);
- //check against filters
- boolean shouldFilter = shouldFilter();
- boolean filterMatch = true;//default
- if(shouldFilter)
- - filterMatch = Filter.FilterMatch(path, filters);
- + filterMatch = Filter.FilterMatch(path, runtime, filters); //AngryCamel - 20120805 2351
- if(!filterMatch)
- {
- Config.log(DEBUG, "Skipping this path because it doesn't match any filters: "+ path);
- Index: utilities/XBMCFile.java
- ===================================================================
- --- utilities/XBMCFile.java (revision 8)
- +++ utilities/XBMCFile.java (working copy)
- @@ -30,6 +30,9 @@
- boolean hasBeenLookedUpOnTVDB = false;
- String fileOrDir;
- private boolean skippedBecauseAlreadyArchived = false;
- +
- + //AngryCamel - 20120805 2351
- + int runtime=0;
- ///for multi-file vidoes
- @@ -58,24 +61,36 @@
- dest.setTVDBId(source.getTVDBId());
- dest.setYear(source.getYear());
- }
- - public XBMCFile(String fileOrDir, String fanart, String file, String fileLabel, String thumbnail, String parentPath, Subfolder matchingSubfolder)
- +
- + //AngryCamel - 20120805 2351
- + //public XBMCFile(String fileOrDir, String fanart, String file, String fileLabel, String thumbnail, String parentPath, Subfolder matchingSubfolder)
- + public XBMCFile(String fileOrDir, String fanart, String file, String fileLabel, String thumbnail, int runtime, String parentPath, Subfolder matchingSubfolder)
- {
- this.fileOrDir = fileOrDir;
- this.fanart = fanart;
- this.file = file;
- this.fileLabel = fileLabel;// == null ? null : fileLabel.replace("/", "-");
- this.thumbnail = thumbnail;
- +
- + //AngryCamel - 20120805 2351
- + this.runtime = runtime;
- +
- this.parentPath = parentPath;
- this.subfolder = matchingSubfolder;
- }
- - public XBMCFile(String fileOrDir, String fanart, String file, String fileLabel, String thumbnail)
- + //AngryCamel - 20120805 2351
- + //public XBMCFile(String fileOrDir, String fanart, String file, String fileLabel, String thumbnail)
- + public XBMCFile(String fileOrDir, String fanart, String file, String fileLabel, String thumbnail, int runtime)
- {
- this.fileOrDir = fileOrDir;
- this.fanart = fanart;
- this.file = file;
- this.fileLabel = fileLabel;// == null ? null : fileLabel.replace("/", "-");
- this.thumbnail = thumbnail;
- +
- + //AngryCamel - 20120805 2351
- + this.runtime = runtime;
- }
- //limited constructor used in manual archiving
- @@ -266,6 +281,13 @@
- {
- this.episodeNumber = episodeNumber;
- }
- +
- + //AngryCamel - 20120805 2351
- + public void setRuntime(int runtime)
- + {
- + this.runtime = runtime;
- + }
- +
- public int getSeasonNumber()
- {
- return seasonNumber;
- @@ -378,6 +400,12 @@
- {
- return parentPath;
- }
- +
- + //AngryCamel - 20120805 2351
- + public int getRuntime()
- + {
- + return runtime;
- + }
- public String stripExtras(String source)
- {
- Index: utilities/XbmcJsonRpc.java
- ===================================================================
- --- utilities/XbmcJsonRpc.java (revision 8)
- +++ utilities/XbmcJsonRpc.java (working copy)
- @@ -343,9 +343,10 @@
- XBMCFile xbmcFile = new XBMCFile(
- fileOrDir,
- json.has("fanart") ? json.getString("fanart") : null,
- - json.has("file") ? json.getString("file") : null,
- + json.has("file") ? json.getString("file") : null,
- json.has("label") ? json.getString("label") : null,
- - json.has("thumbnail") ? json.getString("thumbnail") : null
- + json.has("thumbnail") ? json.getString("thumbnail") : null,
- + json.has("runtime") ? json.getInt("runtime") : 0 //AngryCamel - 20120805 2351
- );
- return xbmcFile;
- }
- @@ -416,8 +417,15 @@
- params.put("directory",dir);
- final String mediaType = "files";//files should return everything after fix here: http://forum.xbmc.org/showthread.php?t=114921
- - params.put("media", mediaType);
- + params.put("media", mediaType);
- + //AngryCamel - 20120805 2351
- + // -Added runtime for the runtime filter.
- + // -You were referencing label (returned when title is specified in properties), thumbnail, and fanart when creating XBMCFile but
- + // they were not coming back in the JSON reponse, so I added those while I was at it.
- + final String[] properties = {"runtime", "title", "thumbnail", "fanart"};//files should return everything after fix here: http://forum.xbmc.org/showthread.php?t=114921
- + params.put("properties", properties);
- +
- /*Sort testing
- *
- boolean sort = true;
- @@ -477,10 +485,11 @@
- file.getString("file"), //required
- file.getString("label"), //required
- file.has("thumbnail") ? file.getString("thumbnail") : null,
- + file.has("runtime") ? file.getInt("runtime") : 0, //AngryCamel - 20120805 2351
- fullPathLabel,
- subf);
- - boolean allowed = subf.isAllowedByFilters(xbmcFile.getFullPathEscaped());
- + boolean allowed = subf.isAllowedByFilters(xbmcFile.getFullPathEscaped(), xbmcFile.getRuntime()); //AngryCamel - 20120805 2351
- if(!allowed) continue;
- boolean excluded = subf.isExcluded(xbmcFile.getFullPathEscaped());
- @@ -521,6 +530,7 @@
- file, //required
- label, //required
- directory.has("thumbnail") ? directory.getString("thumbnail") : null,
- + 0, //AngryCamel - 20120805 2351
- fullPathLabel,
- subf);
- filesAndDirsFound.put(xbmcFile);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement