public static boolean doHuluCBS(MyLibraryFile video, boolean isHulu, boolean isCBS) { String matchingPattern = null; if (!video.knownType() || video.isTvShow()) { Pattern seasonEpisodePattern = Pattern.compile("s[0-9]+e[0-9]+", Pattern.CASE_INSENSITIVE); Matcher seasonEpisodeMatcher = seasonEpisodePattern.matcher(video.getFullPath()); boolean match = seasonEpisodeMatcher.find(); if (match) { matchingPattern = seasonEpisodeMatcher.group(); video.setType(TV_SHOW); } else if (!video.isTvShow()) // dont over-ride config param video.setType(MOVIE); } boolean success; if (video.isTvShow()) success = addHuluOrCBSTvEpisodeMetaData(video, matchingPattern); else if (video.isMovie()) { video.setTitle(video.getFileLabel()); success = valid(video.getTitle()); } else // do hulu/cbs have music videos? { Logger.WARN( "Cannot Archive: Type of content cannot be auto-determined for Hulu video: " + video.getFullPathEscaped()); success = false; } Logger.DEBUG( (isCBS ? "CBS" : "Hulu") + ": success=" + success + "; " + (video.isTvShow() ? "TV: series=" + video.getSeries() + "; title=" + video.getTitle() + ", " + "season=" + video.getSeasonNumber() + ", episode=" + video.getEpisodeNumber() : "Movie: " + video.getTitle()) + " --- " + video.getFullPathEscaped()); return success; }
public static boolean doNetflix(MyLibraryFile video) { // pattern one, matches most normal TV season/episode patterns for netflix Pattern seasonEpisodePattern = Pattern.compile( "^S[0-9]+E[0-9]+", Pattern .CASE_INSENSITIVE); // Netflix/Instant Queue/#/30 Days/30 Days: Season 3/S03E01 - // Working in a Coal Mine Matcher seasonEpisodeMatcher = seasonEpisodePattern.matcher(video.getFileLabel()); // S03E01 - Working in a Coal Mine // another pattern to find when no season/series word is specified Pattern seasonEpisodePattern2 = Pattern.compile( "/[0-9]+/S?[0-9]+E?[0-9]+"); // Netflix/Instant Queue/Alphabetical/B/Blue's Clues/5/28: // Our Neighborhood Festival Matcher seasonEpisodeMatcher2 = seasonEpisodePattern2.matcher(video.getFullPathEscaped()); // pattern that matches absolutely numbered TV shows (no season) Pattern absoluteEpisodePattern = Pattern.compile( "^[0-9][0-9]:"); // Netflix/Instant Queue/Alphabetical/B/The Blue Planet: Tidal Seas/01: // Tidal Seas Matcher absoluteEpisodeMatcher = absoluteEpisodePattern.matcher( video .getFileLabel()); // only chck the file name because we are using the ^ start of // string regex identifier if (!video.knownType() || video.isTvShow()) { // get season and episode numbers try { if (seasonEpisodeMatcher.find()) // looks like "S03E01" { video.setType(TV_SHOW); String SxxExx = seasonEpisodeMatcher.group(); Archiver.addTVMetaDataFromSxxExx(video, SxxExx); } else if (seasonEpisodeMatcher2.find()) { video.setType(TV_SHOW); String match = seasonEpisodeMatcher2.group(); // "/5/28:" String[] parts = (match.substring(1, match.indexOf(":"))).split("/"); // "5/28" int seasonNum = Integer.parseInt(parts[0]); int episodeNum = Integer.parseInt(parts[1]); video.setSeasonNumber(seasonNum); video.setEpisodeNumber(episodeNum); } else if (absoluteEpisodeMatcher.find()) { // catch something like this, which is really TV, but has no season number Logger.INFO( "This appears to be a TV episode with no Season info. Will attempt TVDB lookup, and if it fails, default to season zero: " + video.getFullPathEscaped()); video.setType(TV_SHOW); addNetflixTVSeriesAndTitle(video); // need series/title before lookup if (!TVDB.lookupTVShow(video)) { video.setSeasonNumber(0); // TODO: generate info for this automatically since it will not be scraped successfully String match = absoluteEpisodeMatcher.group(); // "01:" video.setEpisodeNumber( Integer.parseInt( match.substring( 0, match.indexOf(":")))); // parse the number from something like "01:" } } else { Logger.DEBUG( "This netflix source does not match any known TV patterns. assuming it is a movie: " + video.getFullPathEscaped()); video.setType(MOVIE); } } catch ( Exception x) // Netflix/Instant Queue/H/Heroes/Heroes: Season 4/S04E01 - Orientation/S04E11 - // Thanksgiving { Logger.WARN( "Cannot parse season/episode numbers for netflix TV source: " + video.getFullPathEscaped(), x); } } // netflix doesn't have music videos afaik Logger.DEBUG( "Found PlayOn Netflix: " + (video.isTvShow() ? "TV " : "Movie") + ": " + video.getFullPathEscaped()); if (video.isTvShow()) return addNetflixTVSeriesAndTitle(video); // parse netflix info from label/path else if (video.isMovie()) { video.setTitle(video.getFileLabel()); // just use the label as the title return valid(video.getFileLabel()); } else { Logger.WARN( "Cannot Arvhive Playon Netflix video: Type of content cannot be auto-determined for: " + video.getFullPathEscaped()); return false; } }