private static boolean addNetflixTVSeriesAndTitle(MyLibraryFile video) { try { // find series and title String series = null, title = null; try // this method must be tried first (even though it matches less files); try using the // filename spit at ":"... catches things line Bob the Builder: Call in the Crew { if (video .getFileLabel() .contains(": ")) // somethign like /Bob the Builder: Call in the Crew { String[] sa = video.getFileLabel().split(": "); if (sa.length != 2) throw new Exception("File label contains more than one ':'. Cannot parse."); series = sa[0]; title = sa[1].trim(); boolean is24 = (series.trim().equals("24") || video.getFullPathEscaped().contains("/24/")) && (title.toLowerCase().contains("a.m") || title.toLowerCase().contains("p.m")); if (!is24) // exclude 24 becuase the series should be an integer { series = "24"; if (isInt(series)) // this is actually the episode number, not the series. { series = null; throw new Exception("Incorrect series (Integer found as series name)"); } } } else throw new Exception("No colon in file label, try secondary method"); } catch ( Exception x) // try secondary method, getting series as the parent folder and the file label // being the title { series = null; // Netflix/Instant Queue/#/30 Days/30 Days: Season 3/S03E03 - Animal Rights String[] folders = video.getFullPath().split(com.bradvido.xbmc.util.Constants.DELIM); if (folders.length > 1) { String parentFolder = folders[folders.length - 2]; // 30 Days: Season 3 if (valid(parentFolder) && parentFolder.contains(": ")) { series = parentFolder.substring(0, parentFolder.indexOf(": ")); } } // try looking in the folder(s) above this show for the series if (series == null) { // couldn't find it the conventional way if (Archiver.getSeriesFromParentFolder(video)) { series = video .getSeries(); // series was set in getSeriesFromParentFolder(). get it back // here for further checks } else { // didn't work try secondary method String[] serieses = video.getFullPath().split(com.bradvido.xbmc.util.Constants.DELIM); series = serieses[serieses.length - 2]; // the folder above the file name if (series.contains( ":")) // catches folders named like so: /Busytown Mysteries: Series 2/ series = series.substring(0, series.indexOf(":")); } } // get title (usually split from SxxExx by one of these) title = video.getFileLabel(); // S03E01 - Working in a Coal Mine String[] splitters = new String[] {" - ", ":"}; for (String splitter : splitters) { if (title.contains(splitter)) { title = title.substring(title.indexOf(splitter) + splitter.length(), title.length()); break; } } } if (!valid(series)) throw new Exception("Series cannot be parsed..."); video.setSeries(series.trim()); if (!valid(title)) throw new Exception("Title cannot be parsed..."); video.setTitle(title.trim()); return true; // successfully got the series and title // Logger.INFO( "Netflix episode meta data: series="+file.getSeries()+"; // title="+file.getTitle()+", season="+file.getSeasonNumber()+", // episode="+file.getEpidoseNumber()); } catch (Exception x) { if (!valid(video.getSeries()) || !valid(video.getTitle())) { Logger.WARN( "Cannot parse, and cannot lookup Netflix TV show (series=" + video.getSeries() + ", title=" + video.getTitle() + ")" + LINE_BRK + video.getFullPathEscaped() + LINE_BRK + x.getMessage()); return false; } else { Logger.INFO( "Cannot parse, but can lookup Netflix TV show (series=" + video.getSeries() + ", title=" + video.getTitle() + ")" + LINE_BRK + video.getFullPathEscaped() + LINE_BRK + x.getMessage()); Logger.INFO("Attempting to find metadata on TheTVDB.com"); return TVDB.lookupTVShow(video); } } }