AddBackdropFromURL() public method

public AddBackdropFromURL ( string url ) : ImageLoadResults
url string
return ImageLoadResults
        public bool GetBackdrop(DBMovieInfo movie)
        {
            if (movie == null)
                return false;

            // if we already have a backdrop move on for now
            if (movie.BackdropFullPath.Trim().Length > 0)
                return true;

            // do we have an id?
            string movieId = getMovieId(movie);
            if (string.IsNullOrEmpty(movieId))
                return false;

            string url = apiMovieArtwork;
            if (!string.IsNullOrWhiteSpace(MovingPicturesCore.Settings.FanartTVClientKey))
                url = url + "&client_key=" + MovingPicturesCore.Settings.FanartTVClientKey;

            string response = getJson(string.Format(url, movieId));
            if (response == null)
                return false;

            // de-serialize json response
            var movieImages = response.FromJson<Artwork>();
            if (movieImages == null)
                return false;

            // check if we have any backdrops
            if (movieImages.moviebackground == null || movieImages.moviebackground.Count == 0)
                return false;

            // get the 1st (highest rated) movie backdrop
            // only single backdrops are currently supported
            string backdropUrl = movieImages.moviebackground.First().url;
            if (backdropUrl.Trim().Length > 0) {
                if (movie.AddBackdropFromURL(backdropUrl) == ImageLoadResults.SUCCESS) {
                    // store either the imdb id or tmdb id of movie for identifier
                    // there is no per movie id from fanart.tv, only per image id
                    movie.GetSourceMovieInfo(SourceInfo).Identifier = movieId;
                    return true;
                }
            }

            // if we get here we didn't manage to find a proper backdrop
            return false;
        }
        public bool GetBackdrop(DBMovieInfo movie)
        {
            if (scraper == null)
                return false;

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

            // if we already have a backdrop move on for now
            if (movie.BackdropFullPath.Trim().Length > 0)
                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_backdrop", paramList);
            if (results == null) {
                logger.Error(Name + " scraper script failed to execute \"get_backdrop\" node.");
                return false;
            }

            // Loop through all the results until a valid backdrop is found
            int count = 0;
            while (results.ContainsKey("backdrop[" + count + "].url") || results.ContainsKey("backdrop[" + count + "].file")) {

                // attempt to load via a URL
                if (results.ContainsKey("backdrop[" + count + "].url")) {
                    string backdropURL = results["backdrop[" + count + "].url"];
                    if (backdropURL.Trim().Length > 0)
                        if (movie.AddBackdropFromURL(backdropURL) == ImageLoadResults.SUCCESS)
                            return true;
                }

                // attempt to load via a file
                if (results.ContainsKey("backdrop[" + count + "].file")) {
                    string backdropFile = results["backdrop[" + count + "].file"];
                    if (backdropFile.Trim().Length > 0)
                        if (movie.AddBackdropFromFile(backdropFile))
                            return true;
                }

                count++;
            }

            // no valid backdrop found
            return false;
        }
        public bool GetBackdrop(DBMovieInfo movie)
        {
            if (movie == null)
                return false;

            // if we already have a backdrop move on for now
            if (movie.BackdropFullPath.Trim().Length > 0)
                return true;

            // do we have an id?
            string tmdbID = getTheMovieDbId(movie, true);
            if (tmdbID == null)
                return false;

            // try to get movie artwork
            var movieArtwork = TheMovieDbAPI.GetMovieImages(tmdbID);
            if (movieArtwork == null || movieArtwork.Backdrops == null || movieArtwork.Backdrops.Count == 0)
                return false;

            // filter out minimum size images
            int minWidth = MovingPicturesCore.Settings.MinimumBackdropWidth;
            int minHeight = MovingPicturesCore.Settings.MinimumBackdropHeight;

            movieArtwork.Backdrops.RemoveAll(b => b.Width < minWidth || b.Height < minHeight);
            if (movieArtwork.Backdrops.Count == 0)
                return false;

            // sort by highest rated / most popular
            var backdrops = movieArtwork.Backdrops.OrderByDescending(p => p.Score);

            // get the base url for images
            string baseImageUrl = getImageBaseUrl();
            if (string.IsNullOrEmpty(baseImageUrl))
                return false;

            // moving pics currently only supports 1 backdrop per movie
            string backdropURL = baseImageUrl + backdrops.First().FilePath;
            if (backdropURL.Trim().Length > 0) {
                if (movie.AddBackdropFromURL(backdropURL) == ImageLoadResults.SUCCESS) {
                    movie.GetSourceMovieInfo(SourceInfo).Identifier = tmdbID;
                    return true;
                }
            }

            // if we get here we didn't manage to find a proper backdrop
            // so return false
            return false;
        }
        public bool GetBackdrop(DBMovieInfo movie)
        {
            if (movie == null)
                return false;

            // if we already have a backdrop move on for now
            if (movie.BackdropFullPath.Trim().Length > 0)
                return true;

            // do we have an id?
            string tmdbID = getTheMovieDbId(movie, true);
            if (tmdbID == null) {
                return false;
            }

            // Try to get movie information
            XmlNodeList xml = getXML(apiMovieGetInfo + tmdbID);
            if (xml == null) {
                return false;
            }

            // try to grab backdrops from the resulting xml doc
            string backdropURL = string.Empty;
            XmlNodeList backdropNodes = xml.Item(0).SelectNodes("//image[@type='backdrop']");
            foreach (XmlNode currNode in backdropNodes) {
                if (currNode.Attributes["size"].Value == "original") {
                    backdropURL = currNode.Attributes["url"].Value;
                    if (backdropURL.Trim().Length > 0) {
                        if (movie.AddBackdropFromURL(backdropURL) == ImageLoadResults.SUCCESS) {
                            movie.GetSourceMovieInfo(SourceInfo).Identifier = tmdbID;
                            return true;
                        }
                    }
                }
            }

            // if we get here we didn't manage to find a proper backdrop
            // so return false
            return false;
        }