Beispiel #1
0
        // removes the current cover from the selection list and deletes it and it's thumbnail
        // from disk
        public void DeleteCurrentCover()
        {
            if (AlternateCovers.Count == 0)
            {
                return;
            }

            string coverFilePath      = CoverFullPath;
            string coverThumbFilePath = CoverThumbFullPath;

            // delete thumbnail
            if (coverThumbFilePath.Trim().Length > 0)
            {
                FileInfo thumbFile = new FileInfo(coverThumbFilePath);
                if (thumbFile.Exists)
                {
                    try {
                        thumbFile.Delete();
                    }
                    catch (Exception e) {
                        if (e.GetType() == typeof(ThreadAbortException))
                        {
                            throw e;
                        }
                    }
                }
            }

            // delete cover
            if (coverFilePath.Trim().Length > 0)
            {
                FileInfo coverFile = new FileInfo(coverFilePath);
                if (coverFile.Exists)
                {
                    try {
                        coverFile.Delete();
                    }
                    catch (Exception e) {
                        if (e.GetType() == typeof(ThreadAbortException))
                        {
                            throw e;
                        }
                    }
                }
            }

            CoverFullPath = "";
            AlternateCovers.Remove(coverFilePath);
            commitNeeded = true;
        }
Beispiel #2
0
        // Attempts to load cover art for this movie from a given URL. Optionally
        // ignores minimum resolution restrictions
        public ImageLoadResults AddCoverFromURL(string url, bool ignoreRestrictions)
        {
            ImageLoadResults status;
            Cover            newCover = Cover.FromUrl(this, url, ignoreRestrictions, out status);

            if (status != ImageLoadResults.SUCCESS && status != ImageLoadResults.SUCCESS_REDUCED_SIZE)
            {
                return(status);
            }

            AlternateCovers.Add(newCover.Filename);
            GenerateThumbnail();
            commitNeeded = true;
            return(ImageLoadResults.SUCCESS);
        }
Beispiel #3
0
        // rotates the selected cover art to the previous available cover
        public void PreviousCover()
        {
            if (AlternateCovers.Count <= 1)
            {
                return;
            }

            int index = AlternateCovers.IndexOf(CoverFullPath) - 1;

            if (index < 0)
            {
                index = AlternateCovers.Count - 1;
            }

            CoverFullPath = AlternateCovers[index];
            commitNeeded  = true;
        }
Beispiel #4
0
        // rotates the selected cover art to the next available cover
        public void NextCover()
        {
            if (AlternateCovers.Count <= 1)
            {
                return;
            }

            int index = AlternateCovers.IndexOf(CoverFullPath) + 1;

            if (index >= AlternateCovers.Count)
            {
                index = 0;
            }

            CoverFullPath = AlternateCovers[index];
            commitNeeded  = true;
        }
Beispiel #5
0
        public bool AddCoverFromFile(string filename)
        {
            int    minWidth  = MovingPicturesCore.Settings.MinimumCoverWidth;
            int    minHeight = MovingPicturesCore.Settings.MinimumCoverHeight;
            string artFolder = MovingPicturesCore.Settings.CoverArtFolder;

            Image newCover = null;

            try {
                newCover = Image.FromFile(filename);
            }
            catch (OutOfMemoryException) {
                logger.Debug("Invalid image or image format not supported: " + filename);
            }
            catch (FileNotFoundException) {
                logger.Debug("File not found: " + filename);
            }

            if (newCover == null)
            {
                logger.Error("Failed loading cover artwork for '" + Title + "' [" + ID + "] from " + filename + ".");
                return(false);
            }

            // check if the image file is already in the cover folder
            FileInfo newFile         = new FileInfo(filename);
            bool     alreadyInFolder = newFile.Directory.FullName.Equals(new DirectoryInfo(artFolder).FullName);

            // if the file isnt in the cover folder, generate a name and save it there
            if (!alreadyInFolder)
            {
                string safeName    = Title.Replace(' ', '.').ToValidFilename() + "-" + Year;
                string newFileName = artFolder + "\\{" + safeName + "} [" + filename.GetHashCode() + "].jpg";

                if (!File.Exists(newFileName) && saveImage(newFileName, newCover))
                {
                    AlternateCovers.Add(newFileName);
                    commitNeeded = true;
                }
                else
                {
                    return(false);
                }
            }

            // if it's already in the folder, just store the filename in the db
            else
            {
                if (!AlternateCovers.Contains(filename))
                {
                    AlternateCovers.Add(filename);
                    commitNeeded = true;
                }
                else
                {
                    return(false);
                }
            }

            // create a thumbnail for the cover
            newCover.Dispose();
            commitNeeded = true;
            GenerateThumbnail();
            logger.Info("Added cover art for '" + Title + "' from: " + filename);

            return(true);
        }