Inheritance: ImageResource
Beispiel #1
0
        public static Backdrop 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.MinimumBackdropWidth;
                minSize.Height = MovingPicturesCore.Settings.MinimumBackdropHeight;
            }

            maxSize.Width  = MovingPicturesCore.Settings.MaximumBackdropWidth;
            maxSize.Height = MovingPicturesCore.Settings.MaximumBackdropHeight;

            bool redownload = MovingPicturesCore.Settings.RedownloadBackdrops;

            Backdrop newBackdrop = new Backdrop();

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

            switch (status)
            {
            case ImageLoadResults.SUCCESS:
                logger.Info("Added backdrop for \"{0}\" from: {1}", movie.Title, url);
                break;

            case ImageLoadResults.SUCCESS_REDUCED_SIZE:
                logger.Info("Added resized backdrop for \"{0}\" from: {1}", movie.Title, url);
                break;

            case ImageLoadResults.FAILED_ALREADY_LOADED:
                logger.Debug("Backdrop for \"{0}\" from the following URL is already loaded: {1}", movie.Title, url);
                return(null);

            case ImageLoadResults.FAILED_TOO_SMALL:
                logger.Debug("Downloaded backdrop for \"{0}\" failed minimum resolution requirements: {1}", movie.Title, url);
                return(null);

            case ImageLoadResults.FAILED:
                logger.Error("Failed downloading backdrop for \"{0}\": {1}", movie.Title, url);
                return(null);
            }

            return(newBackdrop);
        }
        public static Backdrop 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.MinimumBackdropWidth;
                minSize.Height = MovingPicturesCore.Settings.MinimumBackdropHeight;
            }

            maxSize.Width = MovingPicturesCore.Settings.MaximumBackdropWidth;
            maxSize.Height = MovingPicturesCore.Settings.MaximumBackdropHeight;

            bool redownload = MovingPicturesCore.Settings.RedownloadBackdrops;

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

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

            return newBackdrop;
        }