private MovieInfoScraperActionContext PreMovieInfoScraperAction( MovieInfoScraperActionContext context) { if (log.IsDebugEnabled) log.Debug("PreMovieInfoScraperAction[Dummy]"); return context; }
/// <summary> /// Fixes the title and year before scraping movie info. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> private MovieInfoScraperActionContext PreMovieInfoScraperAction( MovieInfoScraperActionContext context) { // Check for titles that end with the, a or an that should be at the // start of the title. string title = context.DBMovie.Movie.Title; string lTitle = title.ToLower(); if (lTitle.EndsWith(", the")) title = string.Format("The {0}", title.Substring(0, title.LastIndexOf(','))); else if (lTitle.EndsWith(", a")) title = string.Format("A {0}", title.Substring(0, title.LastIndexOf(','))); else if (lTitle.EndsWith(", an")) title = string.Format("An {0}", title.Substring(0, title.LastIndexOf(','))); context.DBMovie.Movie.Title = title; // if year is unset try and scrape it from the file name. if (string.IsNullOrEmpty(context.DBMovie.Movie.Year)) { if (yearRegex == null) yearRegex = new Regex(@"[\(\[](19|20[0-9]{2})[\]\)]"); string filename = context.DBMovie.Filename; Match match = yearRegex.Match(filename); if (match.Success) context.DBMovie.Movie.Year = match.Groups[1].Value; } return context; }
/// <summary> /// Scrapes the movie info. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public PluginActionResult ScrapeMovieInfo(MovieInfoScraperActionContext context) { if (context == null) { throw new ArgumentNullException("context"); } if (manager.Plugins.Count == 0) { return(new PluginActionResult()); } if (PreMovieInfoScrape != null) { context = PreMovieInfoScrape(context); } PluginActionResult result = null; foreach (IMovieInfoScraper plugin in manager.Plugins .Where(p => p.Enabled && p.Plugin is IMovieInfoScraper) .OrderBy(p => p.Order) .Select(p => p.Plugin)) { result = plugin.ScrapeMovieInfo(context); if (result != null && result.BreakChain) { break; } } if (result == null) { result = new PluginActionResult(); } if (PostMovieInfoScrape != null) { result = PostMovieInfoScrape(result); } return(result); }
/// <summary> /// Scrapes the movie info. /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public PluginActionResult ScrapeMovieInfo(MovieInfoScraperActionContext context) { if (context == null) throw new ArgumentNullException("context"); if (manager.Plugins.Count == 0) return new PluginActionResult(); if (PreMovieInfoScrape != null) context = PreMovieInfoScrape(context); PluginActionResult result = null; foreach (IMovieInfoScraper plugin in manager.Plugins .Where(p => p.Enabled && p.Plugin is IMovieInfoScraper) .OrderBy(p => p.Order) .Select(p => p.Plugin)) { result = plugin.ScrapeMovieInfo(context); if (result != null && result.BreakChain) break; } if (result == null) result = new PluginActionResult(); if (PostMovieInfoScrape != null) result = PostMovieInfoScrape(result); return result; }