public IList <FanArtImage> GetFanArt(FanArtConstants.FanArtMediaType mediaType, FanArtConstants.FanArtType fanArtType, string name, int maxWidth, int maxHeight, bool singleRandom) { string baseFolder = GetBaseFolder(mediaType, name); // No known series if (baseFolder == null || !Directory.Exists(baseFolder)) { return(null); } string pattern = GetPattern(mediaType, fanArtType); if (string.IsNullOrEmpty(pattern)) { return(null); } DirectoryInfo directoryInfo = new DirectoryInfo(baseFolder); try { List <string> files = directoryInfo.GetFiles(pattern).Select(file => file.FullName).ToList(); List <FanArtImage> fanArtImages = files.Select(f => FanArtImage.FromFile(f, maxWidth, maxHeight)).Where(fanArtImage => fanArtImage != null).ToList(); if (fanArtImages.Count == 0) { return(null); } return(singleRandom ? GetSingleRandom(fanArtImages) : fanArtImages); } catch (DirectoryNotFoundException) { return(null); } }
public IList <FanArtImage> GetFanArt(FanArtConstants.FanArtMediaType mediaType, FanArtConstants.FanArtType fanArtType, string name, int maxWidth, int maxHeight, bool singleRandom) { InitProviders(); foreach (IFanArtProvider fanArtProvider in _providerList) { IList <string> fanArtImages; if (fanArtProvider.TryGetFanArt(mediaType, fanArtType, name, maxWidth, maxHeight, singleRandom, out fanArtImages)) { IList <string> result = singleRandom ? GetSingleRandom(fanArtImages) : fanArtImages; return(result.Select(f => FanArtImage.FromFile(f, maxWidth, maxHeight)).Where(fanArtImage => fanArtImage != null).ToList()); } } return(null); }