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


C# BaseItem.SetImage方法代码示例

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


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

示例1: SetImagePath

        /// <summary>
        /// Sets the image path.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="type">The type.</param>
        /// <param name="imageIndex">Index of the image.</param>
        /// <param name="path">The path.</param>
        /// <param name="sourceUrl">The source URL.</param>
        /// <exception cref="System.ArgumentNullException">imageIndex
        /// or
        /// imageIndex</exception>
        private void SetImagePath(BaseItem item, ImageType type, int? imageIndex, string path, string sourceUrl)
        {
            switch (type)
            {
                case ImageType.Screenshot:

                    if (!imageIndex.HasValue)
                    {
                        throw new ArgumentNullException("imageIndex");
                    }

                    if (item.ScreenshotImagePaths.Count > imageIndex.Value)
                    {
                        item.ScreenshotImagePaths[imageIndex.Value] = path;
                    }
                    else if (!item.ScreenshotImagePaths.Contains(path, StringComparer.OrdinalIgnoreCase))
                    {
                        item.ScreenshotImagePaths.Add(path);
                    }
                    break;
                case ImageType.Backdrop:
                    if (!imageIndex.HasValue)
                    {
                        throw new ArgumentNullException("imageIndex");
                    }
                    if (item.BackdropImagePaths.Count > imageIndex.Value)
                    {
                        item.BackdropImagePaths[imageIndex.Value] = path;
                    }
                    else if (!item.BackdropImagePaths.Contains(path, StringComparer.OrdinalIgnoreCase))
                    {
                        item.BackdropImagePaths.Add(path);
                    }

                    if (string.IsNullOrEmpty(sourceUrl))
                    {
                        item.RemoveImageSourceForPath(path);
                    }
                    else
                    {
                        item.AddImageSource(path, sourceUrl);
                    }
                    break;
                default:
                    item.SetImage(type, path);
                    break;
            }
        }
开发者ID:Jon-theHTPC,项目名称:MediaBrowser,代码行数:59,代码来源:ImageSaver.cs

示例2: SetImagePath

        private void SetImagePath(BaseItem item, ImageType type, int? imageIndex, string path)
        {
            switch (type)
            {
                case ImageType.Screenshot:

                    if (!imageIndex.HasValue)
                    {
                        throw new ArgumentNullException("imageIndex");
                    }

                    if (item.ScreenshotImagePaths.Count > imageIndex.Value)
                    {
                        item.ScreenshotImagePaths[imageIndex.Value] = path;
                    }
                    else
                    {
                        item.ScreenshotImagePaths.Add(path);
                    }
                    break;
                case ImageType.Backdrop:
                    if (!imageIndex.HasValue)
                    {
                        throw new ArgumentNullException("imageIndex");
                    }
                    if (item.BackdropImagePaths.Count > imageIndex.Value)
                    {
                        item.BackdropImagePaths[imageIndex.Value] = path;
                    }
                    else
                    {
                        item.BackdropImagePaths.Add(path);
                    }
                    break;
                default:
                    item.SetImage(type, path);
                    break;
            }
        }
开发者ID:0sm0,项目名称:MediaBrowser,代码行数:39,代码来源:ImageSaver.cs

示例3: PopulateBaseItemImages

        /// <summary>
        /// Fills in image paths based on files win the folder
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="args">The args.</param>
        private void PopulateBaseItemImages(BaseItem item, ItemResolveArgs args)
        {
            // Primary Image
            var image = GetImage(item, args, "folder") ??
                GetImage(item, args, "poster") ??
                GetImage(item, args, "cover") ??
                GetImage(item, args, "default");

            // Support plex/xbmc convention
            if (image == null && item is Series)
            {
                image = GetImage(item, args, "show");
            }

            // Support plex/xbmc convention
            if (image == null && item is Season && item.IndexNumber.HasValue)
            {
                var num = item.IndexNumber.Value.ToString(_usCulture);

                image = GetImage(item, args, string.Format("season-{0}", num));
            }
            
            // Support plex/xbmc convention
            if (image == null && (item is Movie || item is MusicVideo || item is AdultVideo))
            {
                image = GetImage(item, args, "movie");
            }
            
            // Look for a file with the same name as the item
            if (image == null)
            {
                var name = Path.GetFileNameWithoutExtension(item.Path);

                if (!string.IsNullOrEmpty(name))
                {
                    image = GetImage(item, args, name);
                }
            }

            if (image != null)
            {
                item.SetImage(ImageType.Primary, image.FullName);
            }

            // Logo Image
            image = GetImage(item, args, "logo");

            if (image != null)
            {
                item.SetImage(ImageType.Logo, image.FullName);
            }

            // Banner Image
            image = GetImage(item, args, "banner");

            // Support plex/xbmc convention
            if (image == null && item is Season && item.IndexNumber.HasValue)
            {
                var num = item.IndexNumber.Value.ToString(_usCulture);

                image = GetImage(item, args, string.Format("season-{0}-banner", num));
            }
            
            if (image != null)
            {
                item.SetImage(ImageType.Banner, image.FullName);
            }

            // Clearart
            image = GetImage(item, args, "clearart");

            if (image != null)
            {
                item.SetImage(ImageType.Art, image.FullName);
            }

            // Disc
            image = GetImage(item, args, "disc") ??
                GetImage(item, args, "cdart");

            if (image != null)
            {
                item.SetImage(ImageType.Disc, image.FullName);
            }

            // Thumbnail Image
            image = GetImage(item, args, "thumb");

            if (image != null)
            {
                item.SetImage(ImageType.Thumb, image.FullName);
            }

            // Box Image
            image = GetImage(item, args, "box");
//.........这里部分代码省略.........
开发者ID:Kampari,项目名称:MediaBrowser,代码行数:101,代码来源:ImageFromMediaLocationProvider.cs

示例4: PopulatePrimaryImage

        private void PopulatePrimaryImage(BaseItem item, ItemResolveArgs args)
        {
            // Primary Image
            var image = GetImage(item, args, "folder") ??
                GetImage(item, args, "poster") ??
                GetImage(item, args, "cover") ??
                GetImage(item, args, "default");

            // Support plex/xbmc convention
            if (image == null && item is Series)
            {
                image = GetImage(item, args, "show");
            }

            var isFileSystemItem = item.LocationType == LocationType.FileSystem;

            // Support plex/xbmc convention
            if (image == null && item is Season && item.IndexNumber.HasValue && isFileSystemItem)
            {
                var seasonMarker = item.IndexNumber.Value == 0
                                       ? "-specials"
                                       : item.IndexNumber.Value.ToString("00", _usCulture);

                // Get this one directly from the file system since we have to go up a level
                var filename = "season" + seasonMarker + "-poster";

                var path = Path.GetDirectoryName(item.Path);

                path = Path.Combine(path, filename);

                image = new FileInfo(path);

                if (!image.Exists)
                {
                    image = null;
                }
            }

            // Support plex/xbmc convention
            if (image == null && (item is Movie || item is MusicVideo || item is AdultVideo))
            {
                image = GetImage(item, args, "movie");
            }

            // Look for a file with the same name as the item
            if (image == null && isFileSystemItem)
            {
                var name = Path.GetFileNameWithoutExtension(item.Path);

                if (!string.IsNullOrEmpty(name))
                {
                    image = GetImage(item, args, name) ??
                        GetImage(item, args, name + "-poster");
                }
            }

            if (image != null)
            {
                item.SetImage(ImageType.Primary, image.FullName);
            }
        }
开发者ID:kreeturez,项目名称:MediaBrowser,代码行数:61,代码来源:ImageFromMediaLocationProvider.cs

示例5: PopulateThumb

        /// <summary>
        /// Populates the thumb.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="args">The args.</param>
        private void PopulateThumb(BaseItem item, ItemResolveArgs args)
        {
            // Thumbnail Image
            var image = GetImage(item, args, "thumb");

            if (image == null)
            {
                // Supprt xbmc conventions
                if (item is Season && item.IndexNumber.HasValue && item.LocationType == LocationType.FileSystem)
                {
                    var seasonMarker = item.IndexNumber.Value == 0
                                           ? "-specials"
                                           : item.IndexNumber.Value.ToString("00", _usCulture);

                    // Get this one directly from the file system since we have to go up a level
                    var filename = "season" + seasonMarker + "-landscape";

                    var path = Path.GetDirectoryName(item.Path);

                    path = Path.Combine(path, filename);

                    image = new FileInfo(path);

                    if (!image.Exists)
                    {
                        image = null;
                    }
                }
            }

            if (image != null)
            {
                item.SetImage(ImageType.Thumb, image.FullName);
            }

        }
开发者ID:kreeturez,项目名称:MediaBrowser,代码行数:41,代码来源:ImageFromMediaLocationProvider.cs

示例6: FetchAsync

        /// <summary>
        /// Fetches metadata and returns true or false indicating if any work that requires persistence was done
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="force">if set to <c>true</c> [force].</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task{System.Boolean}.</returns>
        public override async Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var artistMusicBrainzId = item.Parent.GetProviderId(MetadataProviders.Musicbrainz);

            BaseProviderInfo data;

            if (!item.ProviderData.TryGetValue(Id, out data))
            {
                data = new BaseProviderInfo();
                item.ProviderData[Id] = data;
            }

            var comparisonData = Guid.Empty;

            if (!string.IsNullOrEmpty(artistMusicBrainzId))
            {
                var artistXmlPath = FanArtArtistProvider.GetArtistDataPath(ConfigurationManager.CommonApplicationPaths, artistMusicBrainzId);
                artistXmlPath = Path.Combine(artistXmlPath, "fanart.xml");

                var artistXmlFileInfo = new FileInfo(artistXmlPath);

                comparisonData = GetComparisonData(artistXmlFileInfo);

                if (artistXmlFileInfo.Exists)
                {
                    var album = (MusicAlbum)item;

                    var releaseEntryId = item.GetProviderId(MetadataProviders.Musicbrainz);

                    // Fanart uses the release group id so we'll have to get that now using the release entry id
                    if (string.IsNullOrEmpty(album.MusicBrainzReleaseGroupId))
                    {
                        album.MusicBrainzReleaseGroupId = await GetReleaseGroupId(releaseEntryId, cancellationToken).ConfigureAwait(false);
                    }

                    var doc = new XmlDocument();

                    doc.Load(artistXmlPath);

                    cancellationToken.ThrowIfCancellationRequested();

                    if (ConfigurationManager.Configuration.DownloadMusicAlbumImages.Disc && !item.HasImage(ImageType.Disc))
                    {
                        // Try try with the release entry Id, if that doesn't produce anything try the release group id
                        var node = doc.SelectSingleNode("//fanart/music/albums/album[@id=\"" + releaseEntryId + "\"]/cdart/@url");

                        if (node == null && !string.IsNullOrEmpty(album.MusicBrainzReleaseGroupId))
                        {
                            node = doc.SelectSingleNode("//fanart/music/albums/album[@id=\"" + album.MusicBrainzReleaseGroupId + "\"]/cdart/@url");
                        }

                        var path = node != null ? node.Value : null;

                        if (!string.IsNullOrEmpty(path))
                        {
                            item.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(item, path, DiscFile, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
                        }
                    }

                    if (ConfigurationManager.Configuration.DownloadMusicAlbumImages.Primary && !item.HasImage(ImageType.Primary))
                    {
                        // Try try with the release entry Id, if that doesn't produce anything try the release group id
                        var node = doc.SelectSingleNode("//fanart/music/albums/album[@id=\"" + releaseEntryId + "\"]/albumcover/@url");

                        if (node == null && !string.IsNullOrEmpty(album.MusicBrainzReleaseGroupId))
                        {
                            node = doc.SelectSingleNode("//fanart/music/albums/album[@id=\"" + album.MusicBrainzReleaseGroupId + "\"]/albumcover/@url");
                        }

                        var path = node != null ? node.Value : null;

                        if (!string.IsNullOrEmpty(path))
                        {
                            item.SetImage(ImageType.Primary, await _providerManager.DownloadAndSaveImage(item, path, PrimaryFile, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
                        }
                    }
                }

            }

            data.Data = comparisonData;
            SetLastRefreshed(item, DateTime.UtcNow);

            return true;
        }
开发者ID:snap608,项目名称:MediaBrowser,代码行数:94,代码来源:FanArtAlbumProvider.cs

示例7: PopulateBaseItemImages

        /// <summary>
        /// Fills in image paths based on files win the folder
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="args">The args.</param>
        private void PopulateBaseItemImages(BaseItem item, ItemResolveArgs args)
        {
            PopulatePrimaryImage(item, args);

            // Logo Image
            var image = GetImage(item, args, "logo");

            if (image != null)
            {
                item.SetImage(ImageType.Logo, image.FullName);
            }

            // Clearart
            image = GetImage(item, args, "clearart");

            if (image != null)
            {
                item.SetImage(ImageType.Art, image.FullName);
            }

            // Disc
            image = GetImage(item, args, "disc") ??
                GetImage(item, args, "cdart");

            if (image != null)
            {
                item.SetImage(ImageType.Disc, image.FullName);
            }

            // Box Image
            image = GetImage(item, args, "box");

            if (image != null)
            {
                item.SetImage(ImageType.Box, image.FullName);
            }

            // BoxRear Image
            image = GetImage(item, args, "boxrear");

            if (image != null)
            {
                item.SetImage(ImageType.BoxRear, image.FullName);
            }

            // Thumbnail Image
            image = GetImage(item, args, "menu");

            if (image != null)
            {
                item.SetImage(ImageType.Menu, image.FullName);
            }

            PopulateBanner(item, args);
            PopulateThumb(item, args);

            // Backdrop Image
            PopulateBackdrops(item, args);
            PopulateScreenshots(item, args);
        }
开发者ID:kreeturez,项目名称:MediaBrowser,代码行数:65,代码来源:ImageFromMediaLocationProvider.cs

示例8: PopulatePrimaryImage

        private void PopulatePrimaryImage(BaseItem item, ItemResolveArgs args)
        {
            // Primary Image
            var image = GetImage(item, args, "folder") ??
                GetImage(item, args, "poster") ??
                GetImage(item, args, "cover") ??
                GetImage(item, args, "default");

            // Support plex/xbmc convention
            if (image == null && item is Series)
            {
                image = GetImage(item, args, "show");
            }

            var isFileSystemItem = item.LocationType == LocationType.FileSystem;

            // Support plex/xbmc convention
            if (image == null)
            {
                // Supprt xbmc conventions
                var season = item as Season;
                if (season != null && item.IndexNumber.HasValue && isFileSystemItem)
                {
                    image = GetSeasonImageFromSeriesFolder(season, "-poster");
                }
            }

            // Support plex/xbmc convention
            if (image == null && (item is Movie || item is MusicVideo || item is AdultVideo))
            {
                image = GetImage(item, args, "movie");
            }

            // Look for a file with the same name as the item
            if (image == null && isFileSystemItem)
            {
                var name = Path.GetFileNameWithoutExtension(item.Path);

                if (!string.IsNullOrEmpty(name))
                {
                    image = GetImage(item, args, name) ??
                        GetImage(item, args, name + "-poster");
                }
            }

            if (image != null)
            {
                item.SetImage(ImageType.Primary, image.FullName);
            }
        }
开发者ID:RomanDengin,项目名称:MediaBrowser,代码行数:50,代码来源:ImageFromMediaLocationProvider.cs

示例9: PopulateThumb

        /// <summary>
        /// Populates the thumb.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="args">The args.</param>
        private void PopulateThumb(BaseItem item, ItemResolveArgs args)
        {
            // Thumbnail Image
            var image = GetImage(item, args, "thumb");

            if (image == null)
            {
                var isFileSystemItem = item.LocationType == LocationType.FileSystem;

                // Supprt xbmc conventions
                var season = item as Season;
                if (season != null && item.IndexNumber.HasValue && isFileSystemItem)
                {
                    image = GetSeasonImageFromSeriesFolder(season, "-landscape");
                }
            }

            if (image != null)
            {
                item.SetImage(ImageType.Thumb, image.FullName);
            }

        }
开发者ID:RomanDengin,项目名称:MediaBrowser,代码行数:28,代码来源:ImageFromMediaLocationProvider.cs

示例10: FetchFromXml

        /// <summary>
        /// Fetches from XML.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="xmlFilePath">The XML file path.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task.</returns>
        private async Task FetchFromXml(BaseItem item, string xmlFilePath, CancellationToken cancellationToken)
        {
            var doc = new XmlDocument();
            doc.Load(xmlFilePath);
            
            var language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower();
            
            cancellationToken.ThrowIfCancellationRequested();

            var saveLocal = ConfigurationManager.Configuration.SaveLocalMeta &&
                            item.LocationType == LocationType.FileSystem;

            string path;
            var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : "";

            if (ConfigurationManager.Configuration.DownloadMovieImages.Logo && !item.HasImage(ImageType.Logo))
            {
                var node =
                    doc.SelectSingleNode("//fanart/movie/movielogos/" + hd + "movielogo[@lang = \"" + language + "\"]/@url") ??
                    doc.SelectSingleNode("//fanart/movie/movielogos/movielogo[@lang = \"" + language + "\"]/@url");
                if (node == null && language != "en")
                {
                    //maybe just couldn't find language - try just first one
                    node = doc.SelectSingleNode("//fanart/movie/movielogos/" + hd + "movielogo/@url");
                }
                path = node != null ? node.Value : null;
                if (!string.IsNullOrEmpty(path))
                {
                    item.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(item, path, LogoFile, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
                }
            }
            cancellationToken.ThrowIfCancellationRequested();

            if (ConfigurationManager.Configuration.DownloadMovieImages.Art && !item.HasImage(ImageType.Art))
            {
                var node =
                    doc.SelectSingleNode("//fanart/movie/moviearts/" + hd + "movieart[@lang = \"" + language + "\"]/@url") ??
                    doc.SelectSingleNode("//fanart/movie/moviearts/" + hd + "movieart/@url") ??
                    doc.SelectSingleNode("//fanart/movie/moviearts/movieart[@lang = \"" + language + "\"]/@url") ??
                    doc.SelectSingleNode("//fanart/movie/moviearts/movieart/@url");
                path = node != null ? node.Value : null;
                if (!string.IsNullOrEmpty(path))
                {
                    item.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(item, path, ArtFile, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
                }
            }
            cancellationToken.ThrowIfCancellationRequested();

            if (ConfigurationManager.Configuration.DownloadMovieImages.Disc && !item.HasImage(ImageType.Disc))
            {
                var node = doc.SelectSingleNode("//fanart/movie/moviediscs/moviedisc[@lang = \"" + language + "\"]/@url") ??
                           doc.SelectSingleNode("//fanart/movie/moviediscs/moviedisc/@url");
                path = node != null ? node.Value : null;
                if (!string.IsNullOrEmpty(path))
                {
                    item.SetImage(ImageType.Disc, await _providerManager.DownloadAndSaveImage(item, path, DiscFile, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
                }
            }

            cancellationToken.ThrowIfCancellationRequested();

            if (ConfigurationManager.Configuration.DownloadMovieImages.Banner && !item.HasImage(ImageType.Banner))
            {
                var node = doc.SelectSingleNode("//fanart/movie/moviebanners/moviebanner[@lang = \"" + language + "\"]/@url") ??
                           doc.SelectSingleNode("//fanart/movie/moviebanners/moviebanner/@url");
                path = node != null ? node.Value : null;
                if (!string.IsNullOrEmpty(path))
                {
                    item.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(item, path, BannerFile, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
                }
            }

            cancellationToken.ThrowIfCancellationRequested();

            if (ConfigurationManager.Configuration.DownloadMovieImages.Thumb && !item.HasImage(ImageType.Thumb))
            {
                var node = doc.SelectSingleNode("//fanart/movie/moviethumbs/moviethumb[@lang = \"" + language + "\"]/@url") ??
                           doc.SelectSingleNode("//fanart/movie/moviethumbs/moviethumb/@url");
                path = node != null ? node.Value : null;
                if (!string.IsNullOrEmpty(path))
                {
                    item.SetImage(ImageType.Thumb, await _providerManager.DownloadAndSaveImage(item, path, ThumbFile, saveLocal, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
                }
            }

            if (ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && item.BackdropImagePaths.Count == 0)
            {
                var nodes = doc.SelectNodes("//fanart/movie/moviebackgrounds//@url");

                if (nodes != null)
                {
                    var numBackdrops = item.BackdropImagePaths.Count;

//.........这里部分代码省略.........
开发者ID:snap608,项目名称:MediaBrowser,代码行数:101,代码来源:FanArtMovieProvider.cs

示例11: PopulateBaseItemImages

        /// <summary>
        /// Fills in image paths based on files win the folder
        /// </summary>
        /// <param name="item">The item.</param>
        private void PopulateBaseItemImages(BaseItem item)
        {
            // Primary Image
            var image = GetImage(item, "folder") ??
                GetImage(item, "poster") ??
                GetImage(item, "cover") ??
                GetImage(item, "default");

            if (image != null)
            {
                item.SetImage(ImageType.Primary, image.FullName);
            }

            // Logo Image
            image = GetImage(item, "logo");

            if (image != null)
            {
                item.SetImage(ImageType.Logo, image.FullName);
            }

            // Banner Image
            image = GetImage(item, "banner");

            if (image != null)
            {
                item.SetImage(ImageType.Banner, image.FullName);
            }

            // Clearart
            image = GetImage(item, "clearart");

            if (image != null)
            {
                item.SetImage(ImageType.Art, image.FullName);
            }

            // Thumbnail Image
            image = GetImage(item, "thumb");

            if (image != null)
            {
                item.SetImage(ImageType.Thumb, image.FullName);
            }

            // Box Image
            image = GetImage(item, "box");

            if (image != null)
            {
                item.SetImage(ImageType.Box, image.FullName);
            }

            // BoxRear Image
            image = GetImage(item, "boxrear");

            if (image != null)
            {
                item.SetImage(ImageType.BoxRear, image.FullName);
            }

            // Thumbnail Image
            image = GetImage(item, "menu");

            if (image != null)
            {
                item.SetImage(ImageType.Menu, image.FullName);
            }

            // Backdrop Image
            PopulateBackdrops(item);

            // Screenshot Image
            image = GetImage(item, "screenshot");

            var screenshotFiles = new List<string>();

            if (image != null)
            {
                screenshotFiles.Add(image.FullName);
            }

            var unfound = 0;
            for (var i = 1; i <= 20; i++)
            {
                // Screenshot Image
                image = GetImage(item, "screenshot" + i);

                if (image != null)
                {
                    screenshotFiles.Add(image.FullName);
                }
                else
                {
                    unfound++;

//.........这里部分代码省略.........
开发者ID:snap608,项目名称:MediaBrowser,代码行数:101,代码来源:ImageFromMediaLocationProvider.cs

示例12: FetchFromXml

        /// <summary>
        /// Fetches from XML.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="xmlFilePath">The XML file path.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task.</returns>
        private async Task FetchFromXml(BaseItem item, string xmlFilePath, CancellationToken cancellationToken)
        {
            var doc = new XmlDocument();
            doc.Load(xmlFilePath);

            cancellationToken.ThrowIfCancellationRequested();

            string path;
            var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : "";
            if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo && !item.HasImage(ImageType.Logo))
            {
                var node =
                    doc.SelectSingleNode("//fanart/music/musiclogos/" + hd + "musiclogo/@url") ??
                    doc.SelectSingleNode("//fanart/music/musiclogos/musiclogo/@url");
                path = node != null ? node.Value : null;
                if (!string.IsNullOrEmpty(path))
                {
                    item.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(item, path, LogoFile, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
                }
            }
            cancellationToken.ThrowIfCancellationRequested();

            if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Backdrops && item.BackdropImagePaths.Count == 0)
            {
                var nodes = doc.SelectNodes("//fanart/music/artistbackgrounds//@url");
                if (nodes != null)
                {
                    var numBackdrops = 0;
                    item.BackdropImagePaths = new List<string>();
                    foreach (XmlNode node in nodes)
                    {
                        path = node.Value;
                        if (!string.IsNullOrEmpty(path))
                        {
                            item.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(item, path, ("Backdrop" + (numBackdrops > 0 ? numBackdrops.ToString(UsCulture) : "") + ".jpg"), SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
                            numBackdrops++;
                            if (numBackdrops >= ConfigurationManager.Configuration.MaxBackdrops) break;
                        }
                    }

                }

            }

            cancellationToken.ThrowIfCancellationRequested();

            if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Art && !item.HasImage(ImageType.Art))
            {
                var node =
                    doc.SelectSingleNode("//fanart/music/musicarts/" + hd + "musicart/@url") ??
                    doc.SelectSingleNode("//fanart/music/musicarts/musicart/@url");
                path = node != null ? node.Value : null;
                if (!string.IsNullOrEmpty(path))
                {
                    item.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(item, path, ArtFile, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
                }
            }
            cancellationToken.ThrowIfCancellationRequested();

            if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Banner && !item.HasImage(ImageType.Banner))
            {
                var node = doc.SelectSingleNode("//fanart/music/musicbanners/" + hd + "musicbanner/@url") ??
                           doc.SelectSingleNode("//fanart/music/musicbanners/musicbanner/@url");
                path = node != null ? node.Value : null;
                if (!string.IsNullOrEmpty(path))
                {
                    item.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(item, path, BannerFile, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
                }
            }

            cancellationToken.ThrowIfCancellationRequested();

            // Artist thumbs are actually primary images (they are square/portrait)
            if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Primary && !item.HasImage(ImageType.Primary))
            {
                var node = doc.SelectSingleNode("//fanart/music/artistthumbs/artistthumb/@url");
                path = node != null ? node.Value : null;
                if (!string.IsNullOrEmpty(path))
                {
                    item.SetImage(ImageType.Primary, await _providerManager.DownloadAndSaveImage(item, path, PrimaryFile, SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
                }
            }
        }
开发者ID:snap608,项目名称:MediaBrowser,代码行数:90,代码来源:FanArtArtistProvider.cs

示例13: PopulateBaseItemImages

        /// <summary>
        /// Fills in image paths based on files win the folder
        /// </summary>
        /// <param name="item">The item.</param>
        private void PopulateBaseItemImages(BaseItem item)
        {
            // Primary Image
            var image = GetImage(item, "folder") ??
                GetImage(item, "poster") ??
                GetImage(item, "cover") ??
                GetImage(item, "default");

            // Look for a file with the same name as the item
            if (image == null)
            {
                var name = Path.GetFileNameWithoutExtension(item.Path);

                if (!string.IsNullOrEmpty(name))
                {
                    image = GetImage(item, name);
                }
            }

            if (image != null)
            {
                item.SetImage(ImageType.Primary, image.FullName);
            }

            // Logo Image
            image = GetImage(item, "logo");

            if (image != null)
            {
                item.SetImage(ImageType.Logo, image.FullName);
            }

            // Banner Image
            image = GetImage(item, "banner");

            if (image != null)
            {
                item.SetImage(ImageType.Banner, image.FullName);
            }

            // Clearart
            image = GetImage(item, "clearart");

            if (image != null)
            {
                item.SetImage(ImageType.Art, image.FullName);
            }

            // Disc
            image = GetImage(item, "disc");

            if (image != null)
            {
                item.SetImage(ImageType.Disc, image.FullName);
            }

            // Thumbnail Image
            image = GetImage(item, "thumb");

            if (image != null)
            {
                item.SetImage(ImageType.Thumb, image.FullName);
            }

            // Box Image
            image = GetImage(item, "box");

            if (image != null)
            {
                item.SetImage(ImageType.Box, image.FullName);
            }

            // BoxRear Image
            image = GetImage(item, "boxrear");

            if (image != null)
            {
                item.SetImage(ImageType.BoxRear, image.FullName);
            }

            // Thumbnail Image
            image = GetImage(item, "menu");

            if (image != null)
            {
                item.SetImage(ImageType.Menu, image.FullName);
            }

            // Backdrop Image
            PopulateBackdrops(item);

            // Screenshot Image
            image = GetImage(item, "screenshot");

            var screenshotFiles = new List<string>();

//.........这里部分代码省略.........
开发者ID:rrb008,项目名称:MediaBrowser,代码行数:101,代码来源:ImageFromMediaLocationProvider.cs

示例14: FetchFromXml

        /// <summary>
        /// Fetches from XML.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="xmlFilePath">The XML file path.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task.</returns>
        private async Task FetchFromXml(BaseItem item, string xmlFilePath, CancellationToken cancellationToken)
        {
            var doc = new XmlDocument();
            doc.Load(xmlFilePath);

            cancellationToken.ThrowIfCancellationRequested();

            var language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower();
            
            var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hdtv" : "clear";
            if (ConfigurationManager.Configuration.DownloadSeriesImages.Logo && !item.HasImage(ImageType.Logo))
            {
                var node = doc.SelectSingleNode("//fanart/series/" + hd + "logos/" + hd + "logo[@lang = \"" + language + "\"]/@url") ??
                            doc.SelectSingleNode("//fanart/series/clearlogos/clearlogo[@lang = \"" + language + "\"]/@url") ??
                            doc.SelectSingleNode("//fanart/series/" + hd + "logos/" + hd + "logo/@url") ??
                            doc.SelectSingleNode("//fanart/series/clearlogos/clearlogo/@url");
                var path = node != null ? node.Value : null;
                if (!string.IsNullOrEmpty(path))
                {
                    item.SetImage(ImageType.Logo, await _providerManager.DownloadAndSaveImage(item, path, LogoFile, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
                }
            }

            cancellationToken.ThrowIfCancellationRequested();

            hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : "";
            if (ConfigurationManager.Configuration.DownloadSeriesImages.Art && !item.HasImage(ImageType.Art))
            {
                var node = doc.SelectSingleNode("//fanart/series/" + hd + "cleararts/" + hd + "clearart[@lang = \"" + language + "\"]/@url") ??
                           doc.SelectSingleNode("//fanart/series/cleararts/clearart[@lang = \"" + language + "\"]/@url") ??
                           doc.SelectSingleNode("//fanart/series/" + hd + "cleararts/" + hd + "clearart/@url") ??
                           doc.SelectSingleNode("//fanart/series/cleararts/clearart/@url");
                var path = node != null ? node.Value : null;
                if (!string.IsNullOrEmpty(path))
                {
                    item.SetImage(ImageType.Art, await _providerManager.DownloadAndSaveImage(item, path, ArtFile, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
                }
            }

            cancellationToken.ThrowIfCancellationRequested();

            if (ConfigurationManager.Configuration.DownloadSeriesImages.Thumb && !item.HasImage(ImageType.Thumb))
            {
                var node = doc.SelectSingleNode("//fanart/series/tvthumbs/tvthumb[@lang = \"" + language + "\"]/@url") ??
                           doc.SelectSingleNode("//fanart/series/tvthumbs/tvthumb/@url");
                var path = node != null ? node.Value : null;
                if (!string.IsNullOrEmpty(path))
                {
                    item.SetImage(ImageType.Thumb, await _providerManager.DownloadAndSaveImage(item, path, ThumbFile, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
                }
            }

            if (ConfigurationManager.Configuration.DownloadSeriesImages.Banner && !item.HasImage(ImageType.Banner))
            {
                var node = doc.SelectSingleNode("//fanart/series/tbbanners/tvbanner[@lang = \"" + language + "\"]/@url") ??
                           doc.SelectSingleNode("//fanart/series/tbbanners/tvbanner/@url");
                var path = node != null ? node.Value : null;
                if (!string.IsNullOrEmpty(path))
                {
                    item.SetImage(ImageType.Banner, await _providerManager.DownloadAndSaveImage(item, path, BannerFile, ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));
                }
            }

            if (ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && item.BackdropImagePaths.Count == 0)
            {
                var nodes = doc.SelectNodes("//fanart/series/showbackgrounds//@url");

                if (nodes != null)
                {
                    var numBackdrops = item.BackdropImagePaths.Count;

                    foreach (XmlNode node in nodes)
                    {
                        var path = node.Value;

                        if (!string.IsNullOrEmpty(path))
                        {
                            item.BackdropImagePaths.Add(await _providerManager.DownloadAndSaveImage(item, path, ("backdrop" + (numBackdrops > 0 ? numBackdrops.ToString(UsCulture) : "") + ".jpg"), ConfigurationManager.Configuration.SaveLocalMeta, FanArtResourcePool, cancellationToken).ConfigureAwait(false));

                            numBackdrops++;

                            if (item.BackdropImagePaths.Count >= ConfigurationManager.Configuration.MaxBackdrops) break;
                        }
                    }

                }
            }

        }
开发者ID:snap608,项目名称:MediaBrowser,代码行数:96,代码来源:FanArtTVProvider.cs


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