当前位置: 首页>>代码示例>>C#>>正文


C# DBMovieInfo.AddCoverFromURL方法代码示例

本文整理汇总了C#中MediaPortal.Plugins.MovingPictures.Database.DBMovieInfo.AddCoverFromURL方法的典型用法代码示例。如果您正苦于以下问题:C# DBMovieInfo.AddCoverFromURL方法的具体用法?C# DBMovieInfo.AddCoverFromURL怎么用?C# DBMovieInfo.AddCoverFromURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MediaPortal.Plugins.MovingPictures.Database.DBMovieInfo的用法示例。


在下文中一共展示了DBMovieInfo.AddCoverFromURL方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetArtwork

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

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

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

            // try to get movie artwork
            string response = getJson(string.Format(apiMovieArtwork, 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 posters
            if (movieImages.movieposter == null || movieImages.movieposter.Count == 0)
                return false;

            // filter posters by language
            var langPosters = movieImages.movieposter.Where(p => p.lang == MovingPicturesCore.Settings.DataProviderLanguageCode);

            // if no localised posters available use all posters
            if (langPosters.Count() == 0) {
                langPosters = movieImages.movieposter;
            }

            // sort by highest rated / most popular
            langPosters = langPosters.OrderByDescending(p => p.likes);

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

            // download posters
            foreach (var poster in langPosters) {
                // 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
                string coverPath = poster.url;
                if (coverPath.Trim() != string.Empty) {
                    if (movie.AddCoverFromURL(coverPath) == ImageLoadResults.SUCCESS)
                        coversAdded++;
                }
            }

            if (coversAdded > 0) {
                // Update source info
                movie.GetSourceMovieInfo(SourceInfo).Identifier = movieId;
                return true;
            }

            return false;
        }
开发者ID:damienhaynes,项目名称:moving-pictures,代码行数:66,代码来源:FanartTVProvider.cs

示例2: GetArtwork

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

            // 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.Posters == null || movieArtwork.Posters.Count == 0)
                return false;

            // filter out minimum size images
            int minWidth = MovingPicturesCore.Settings.MinimumCoverWidth;
            int minHeight = MovingPicturesCore.Settings.MinimumCoverHeight;

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

            // filter posters by language
            var langPosters = movieArtwork.Posters.Where(p => p.LanguageCode == MovingPicturesCore.Settings.DataProviderLanguageCode);
            if (MovingPicturesCore.Settings.DataProviderLanguageCode == "en") {
                // include no language posters with english (sometimes language is not assigned)
                langPosters = langPosters.Union(movieArtwork.Posters.Where(p => p.LanguageCode == null));
            }
            // if no localised posters available use all posters
            if (langPosters.Count() == 0) {
                langPosters = movieArtwork.Posters;
            }

            // sort by highest rated / most popular
            langPosters = langPosters.OrderByDescending(p => p.Score);

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

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

            // download posters
            foreach (var poster in langPosters) {
                // 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
                string coverPath = baseImageUrl + poster.FilePath;
                if (coverPath.Trim() != string.Empty) {
                    if (movie.AddCoverFromURL(coverPath) == ImageLoadResults.SUCCESS)
                        coversAdded++;
                }
            }

            if (coversAdded > 0) {
                // Update source info
                movie.GetSourceMovieInfo(SourceInfo).Identifier = tmdbID;
                return true;
            }

            return false;
        }
开发者ID:damienhaynes,项目名称:moving-pictures,代码行数:69,代码来源:TheMovieDbProvider.cs

示例3: GetArtwork

        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;
        }
开发者ID:damienhaynes,项目名称:moving-pictures,代码行数:68,代码来源:ScriptableProvider.cs

示例4: GetArtwork

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

            string mmId = getMovieMeterID(movie);
            if (mmId != null) {
                FilmDetail film = Api.GetMovieDetails(mmId);
                if (film != null) {
                    if (film.thumbnail != null) {
                        string coverPath = film.thumbnail.Replace(@"/thumbs/", @"/");
                        if (movie.AddCoverFromURL(coverPath) == ImageLoadResults.SUCCESS)
                            return true;
                    }
                }
            }
            return false;
        }
开发者ID:damienhaynes,项目名称:moving-pictures,代码行数:18,代码来源:MovieMeterProvider.cs

示例5: GetArtwork

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

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

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

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

            int coversAdded = 0;
            int count = 0;

            // try to grab posters from the xml results
            XmlNodeList posterNodes = xml.Item(0).SelectNodes("//image[@type='poster']");
            foreach (XmlNode posterNode in posterNodes) {
                if (posterNode.Attributes["size"].Value == "original") {
                    // 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
                    string coverPath = posterNode.Attributes["url"].Value;
                    if (coverPath.Trim() != string.Empty)
                        if (movie.AddCoverFromURL(coverPath) == ImageLoadResults.SUCCESS)
                            coversAdded++;

                    count++;
                }
            }

            if (coversAdded > 0) {
                // Update source info
                movie.GetSourceMovieInfo(SourceInfo).Identifier = tmdbID;
                return true;
            }

            return false;
        }
开发者ID:MichelZ,项目名称:moving-pictures-michelz,代码行数:50,代码来源:TheMovieDbProvider.cs


注:本文中的MediaPortal.Plugins.MovingPictures.Database.DBMovieInfo.AddCoverFromURL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。