Наследование: ImageResource
Пример #1
0
        public static Cover FromUrl(DBMovieInfo movie, string url, bool ignoreRestrictions, out ImageLoadResults status)
        {
            ImageSize minSize = null;
            ImageSize maxSize = new ImageSize();

            if (!ignoreRestrictions) {
                minSize = new ImageSize();
                minSize.Width = MovingPicturesCore.Settings.MinimumCoverWidth;
                minSize.Height = MovingPicturesCore.Settings.MinimumCoverHeight;
            }

            maxSize.Width = MovingPicturesCore.Settings.MaximumCoverWidth;
            maxSize.Height = MovingPicturesCore.Settings.MaximumCoverHeight;

            bool redownload = MovingPicturesCore.Settings.RedownloadCoverArtwork;

            Cover newCover = new Cover();
            newCover.Filename = GenerateFilename(movie, url);
            status = newCover.FromUrl(url, ignoreRestrictions, minSize, maxSize, redownload);

            switch (status) {
                case ImageLoadResults.SUCCESS:
                    logger.Info("Added cover art for \"{0}\" from: {1}", movie.Title, url);
                    break;
                case ImageLoadResults.SUCCESS_REDUCED_SIZE:
                    logger.Info("Added resized cover art for \"{0}\" from: {1}", movie.Title, url);
                    break;
                case ImageLoadResults.FAILED_ALREADY_LOADED:
                    logger.Debug("Cover art for \"{0}\" from the following URL is already loaded: {1}", movie.Title, url);
                    return null;
                case ImageLoadResults.FAILED_TOO_SMALL:
                    logger.Debug("Downloaded cover art for \"{0}\" failed minimum resolution requirements: {1}", movie.Title, url);
                    return null;
                case ImageLoadResults.FAILED:
                    logger.Error("Failed downloading cover art for \"{0}\": {1}", movie.Title, url);
                    return null;
            }

            return newCover;
        }