AddCoverFromFile() public method

public AddCoverFromFile ( string filename ) : bool
filename string
return bool
        // check for coverart in the coverfolder loaded from previous installs
        private bool getOldCovers(DBMovieInfo movie)
        {
            bool found = false;

            string coverartFolderPath = MovingPicturesCore.Settings.CoverArtFolder;
            DirectoryInfo coverFolder = new DirectoryInfo(coverartFolderPath);

            string safeName = movie.Title.Replace(' ', '.').ToValidFilename();
            Regex oldCoverRegex = new Regex("^{?" + Regex.Escape(safeName) + "}? \\[-?\\d+\\]\\.(jpg|png)");

            foreach (FileInfo currFile in coverFolder.GetFiles()) {
                if (oldCoverRegex.IsMatch(currFile.Name)) {
                    bool success = movie.AddCoverFromFile(currFile.FullName);
                    found = found || success;
                }
            }

            return found;
        }
        // if flagged, check for covers in the movie folder based on the user defined pattern
        private bool getCoversFromMovieFolder(DBMovieInfo movie)
        {
            bool found = false;

            bool useMovieFolderCovers = MovingPicturesCore.Settings.SearchMovieFolderForCoverArt;
            string pattern = MovingPicturesCore.Settings.MovieFolderCoverArtworkFilenamePattern;

            if (useMovieFolderCovers) {
                List<string> movieFolderFilenames = getPossibleNamesFromPattern(pattern, movie);
                foreach (string currFile in movieFolderFilenames) {
                    FileInfo newCover = new FileInfo(Utility.GetMovieBaseDirectory(movie.LocalMedia[0].File.Directory).FullName + "\\" + currFile);
                    if (newCover.Exists)
                        found |= movie.AddCoverFromFile(newCover.FullName);
                }
            }

            return found;
        }
        public bool GetArtwork(DBMovieInfo movie)
        {
            if (scraper == null)
                return false;

            Dictionary<string, string> paramList = new Dictionary<string, string>();
            Dictionary<string, string> results;

            // grab coverart loading settings
            int maxCovers = MovingPicturesCore.Settings.MaxCoversPerMovie;
            int maxCoversInSession = MovingPicturesCore.Settings.MaxCoversPerSession;

            // if we have already hit our limit for the number of covers to load, quit
            if (movie.AlternateCovers.Count >= maxCovers)
                return true;

            // try to load the id for the movie for this script
            DBSourceMovieInfo idObj = movie.GetSourceMovieInfo(ScriptID);
            if (idObj != null && idObj.Identifier != null)
                paramList["movie.site_id"] = idObj.Identifier;

            // load params for scraper
            foreach (DBField currField in DBField.GetFieldList(typeof(DBMovieInfo)))
                if (currField.GetValue(movie) != null)
                    paramList["movie." + currField.FieldName] = currField.GetValue(movie).ToString().Trim();

            //set higher level settings for script to use
            paramList["settings.defaultuseragent"] = MovingPicturesCore.Settings.UserAgent;
            paramList["settings.mepo_data"] = Config.GetFolder(Config.Dir.Config);

            // run the scraper
            results = scraper.Execute("get_cover_art", paramList);
            if (results == null) {
                logger.Error(Name + " scraper script failed to execute \"get_cover_art\" node.");
                return false;
            }

            int coversAdded = 0;
            int count = 0;
            while (results.ContainsKey("cover_art[" + count + "].url") || results.ContainsKey("cover_art[" + count + "].file")) {
                // if we have hit our limit quit
                if (movie.AlternateCovers.Count >= maxCovers || coversAdded >= maxCoversInSession)
                    return true;

                // get url for cover and load it via the movie object
                if (results.ContainsKey("cover_art[" + count + "].url")) {
                    string coverPath = results["cover_art[" + count + "].url"];
                    if (coverPath.Trim() != string.Empty)
                        if (movie.AddCoverFromURL(coverPath) == ImageLoadResults.SUCCESS)
                            coversAdded++;
                }

                // get file for cover and load it via the movie object
                if (results.ContainsKey("cover_art[" + count + "].file")) {
                    string coverPath = results["cover_art[" + count + "].file"];
                    if (coverPath.Trim() != string.Empty)
                        if (movie.AddCoverFromFile(coverPath))
                            coversAdded++;
                }

                count++;
            }

            if (coversAdded > 0)
                return true;

            return false;
        }
        private bool getCoversFromCoverFolder(DBMovieInfo movie)
        {
            // grab a list of possible filenames for the coverart based on the user pattern
            string pattern = MovingPicturesCore.Settings.CoverArtworkFilenamePattern;
            List<string> coverFolderFilenames = getPossibleNamesFromPattern(pattern, movie);

            // check the coverart folder for the user patterned covers
            string coverartFolderPath = MovingPicturesCore.Settings.CoverArtFolder;
            FileInfo newCover = getFirstFileFromFolder(coverartFolderPath, coverFolderFilenames);
            if (newCover != null && newCover.Exists) {
                return movie.AddCoverFromFile(newCover.FullName);
            }

            return false;
        }
        public bool GetArtwork(DBMovieInfo movie)
        {
            string myVideoCoversFolder = Config.GetFolder(Config.Dir.Thumbs) + "\\Videos\\Title";

            Regex cleaner = new Regex("[\\\\/:*?\"<>|]");
            string cleanTitle = cleaner.Replace(movie.Title, "_");
            string id = movie.GetSourceMovieInfo(SourceInfo).Identifier;
            string filename = myVideoCoversFolder + "\\" + cleanTitle + "{" + id + "}L.jpg";

            if (System.IO.File.Exists(filename))
                return movie.AddCoverFromFile(filename);

            return false;
        }