/// <summary>
 /// Asynchronously saves all images contained in the specified <see cref="FanArtPathCollection"/> to the <see cref="IFanArtCache"/> service.
 /// </summary>
 /// <param name="nativeSystemId">The native system id of the paths contained in the <see cref="FanArtPathCollection"/>.</param>
 /// <param name="paths">Collection of image paths to save.</param>
 /// <param name="mediaItemId">The id of the media item to which the images belong.</param>
 /// <param name="title">The title of the media item to which the images belong.</param>
 /// <returns>A <see cref="Task"/> that completes when the images have been saved to the <see cref="IFanArtCache"/> service.</returns>
 protected async Task SaveFolderImagesToCache(string nativeSystemId, FanArtPathCollection paths, Guid mediaItemId, string title)
 {
     foreach (var typePaths in paths)
     {
         await SaveFolderImagesToCache(nativeSystemId, typePaths.Value, typePaths.Key, mediaItemId, title).ConfigureAwait(false);
     }
 }
        /// <summary>
        /// Gets a <see cref="FanArtPathCollection"/> containing all matching person fanart paths in the specified <see cref="ResourcePath"/>.
        /// </summary>
        /// <param name="potentialFanArtFiles">Enumeration of potential fanart paths..</param>
        /// <param name="personName">Name of the person to find fanart for..</param>
        /// <returns><see cref="FanArtPathCollection"/> containing all matching paths.</returns>
        protected FanArtPathCollection GetPersonFolderImages(IEnumerable <ResourcePath> potentialFanArtFiles, string personName)
        {
            FanArtPathCollection paths = new FanArtPathCollection();

            paths.AddRange(FanArtTypes.Thumbnail, LocalFanartHelper.FilterPotentialFanArtFilesByPrefix(potentialFanArtFiles, personName.Replace(" ", "_").ToLowerInvariant()));
            return(paths);
        }
 public void AddRange(FanArtPathCollection collection)
 {
     if (collection == null)
     {
         return;
     }
     foreach (var fanArtPath in collection.Paths)
     {
         string fanArtType             = fanArtPath.Key;
         List <ResourcePath> typePaths = GetOrAddPathList(fanArtType);
         typePaths.AddRange(fanArtPath.Value);
     }
 }
 /// <summary>
 /// Gets all actor folder images and caches them in the <see cref="IFanArtCache"/> service.
 /// </summary>
 /// <param name="mediaItemLocator"><see cref="IResourceLocator>"/> that points to the file.</param>
 /// <param name="nativeResourcePath">Path to the actor fanart directory.</param>
 /// <param name="persons">Collection of actor ids and names.</param>
 /// <returns><see cref="Task"/> that completes when the images have been cached.</returns>
 protected async Task SavePersonFolderImages(string nativeSystemId, ICollection <ResourcePath> potentialFanArtFiles, IList <Tuple <Guid, string> > persons)
 {
     if (persons == null || persons.Count == 0 ||
         potentialFanArtFiles == null || potentialFanArtFiles.Count == 0)
     {
         return;
     }
     foreach (var person in persons)
     {
         FanArtPathCollection paths = GetPersonFolderImages(potentialFanArtFiles, person.Item2);
         await SaveFolderImagesToCache(nativeSystemId, paths, person.Item1, person.Item2).ConfigureAwait(false);
     }
 }
        /// <summary>
        /// Populates the <paramref name="paths"/> with all matching image paths in <paramref name="potentialFanArtFiles"/>
        /// including only image paths that start with the specified <paramref name="prefix"/>.
        /// </summary>
        /// <param name="potentialFanArtFiles"><see cref="ResourcePath"/> collection containing potential fanart paths.</param>
        /// <param name="paths"><see cref="FanArtPathCollection"/> to populate</param>
        /// <param name="prefix">The filename prefix of the media item.</param>
        protected void ExtractAllFanArtImagesByPrefix(ICollection <ResourcePath> potentialFanArtFiles, FanArtPathCollection paths, string prefix)
        {
            if (potentialFanArtFiles == null && potentialFanArtFiles.Count == 0)
            {
                return;
            }

            prefix = prefix.ToLowerInvariant();

            paths.AddRange(FanArtTypes.Thumbnail, LocalFanartHelper.FilterPotentialFanArtFilesByNameOrPrefix(potentialFanArtFiles,
                                                                                                             null, LocalFanartHelper.THUMB_FILENAMES.Select(f => prefix + "-" + f)));

            paths.AddRange(FanArtTypes.Poster, LocalFanartHelper.FilterPotentialFanArtFilesByNameOrPrefix(potentialFanArtFiles,
                                                                                                          null, LocalFanartHelper.POSTER_FILENAMES.Select(f => prefix + "-" + f)));

            paths.AddRange(FanArtTypes.Logo, LocalFanartHelper.FilterPotentialFanArtFilesByNameOrPrefix(potentialFanArtFiles,
                                                                                                        null, LocalFanartHelper.LOGO_FILENAMES.Select(f => prefix + "-" + f)));

            paths.AddRange(FanArtTypes.ClearArt, LocalFanartHelper.FilterPotentialFanArtFilesByNameOrPrefix(potentialFanArtFiles,
                                                                                                            null, LocalFanartHelper.CLEARART_FILENAMES.Select(f => prefix + "-" + f)));

            paths.AddRange(FanArtTypes.DiscArt, LocalFanartHelper.FilterPotentialFanArtFilesByNameOrPrefix(potentialFanArtFiles,
                                                                                                           null, LocalFanartHelper.DISCART_FILENAMES.Select(f => prefix + "-" + f)));

            paths.AddRange(FanArtTypes.Banner, LocalFanartHelper.FilterPotentialFanArtFilesByNameOrPrefix(potentialFanArtFiles,
                                                                                                          null, LocalFanartHelper.BANNER_FILENAMES.Select(f => prefix + "-" + f)));

            paths.AddRange(FanArtTypes.FanArt, LocalFanartHelper.FilterPotentialFanArtFilesByNameOrPrefix(potentialFanArtFiles,
                                                                                                          null, LocalFanartHelper.BACKDROP_FILENAMES.Select(f => prefix + "-" + f)));
        }
 /// <summary>
 /// Populates the <paramref name="paths"/> with all matching image paths in <paramref name="potentialFanArtFiles"/>.
 /// </summary>
 /// <param name="potentialFanArtFiles"><see cref="ResourcePath"/> collection containing potential fanart paths.</param>
 /// <param name="paths"><see cref="FanArtPathCollection"/> to populate</param>
 protected void ExtractAllFanArtImages(ICollection <ResourcePath> potentialFanArtFiles, FanArtPathCollection paths)
 {
     if (potentialFanArtFiles == null && potentialFanArtFiles.Count == 0)
     {
         return;
     }
     paths.AddRange(FanArtTypes.Thumbnail, LocalFanartHelper.FilterPotentialFanArtFilesByName(potentialFanArtFiles, LocalFanartHelper.THUMB_FILENAMES));
     paths.AddRange(FanArtTypes.Poster, LocalFanartHelper.FilterPotentialFanArtFilesByName(potentialFanArtFiles, LocalFanartHelper.POSTER_FILENAMES));
     paths.AddRange(FanArtTypes.Logo, LocalFanartHelper.FilterPotentialFanArtFilesByName(potentialFanArtFiles, LocalFanartHelper.LOGO_FILENAMES));
     paths.AddRange(FanArtTypes.ClearArt, LocalFanartHelper.FilterPotentialFanArtFilesByName(potentialFanArtFiles, LocalFanartHelper.CLEARART_FILENAMES));
     paths.AddRange(FanArtTypes.DiscArt, LocalFanartHelper.FilterPotentialFanArtFilesByName(potentialFanArtFiles, LocalFanartHelper.DISCART_FILENAMES));
     paths.AddRange(FanArtTypes.Banner, LocalFanartHelper.FilterPotentialFanArtFilesByName(potentialFanArtFiles, LocalFanartHelper.BANNER_FILENAMES));
     paths.AddRange(FanArtTypes.FanArt, LocalFanartHelper.FilterPotentialFanArtFilesByPrefix(potentialFanArtFiles, LocalFanartHelper.BACKDROP_FILENAMES));
 }