/// <summary>
        /// Gets details for movie files from a given path from the TMDb database.
        /// </summary>
        /// <param name="easy">An instance to a TMdbEasy.EasyClient class instance.</param>
        /// <param name="path">A path to enumerate the files from. Do note that these files names should only contain the original title of the movie.</param>
        /// <param name="posterSize">The size of the poster to get the URL for.</param>
        /// <returns>A collection of TMDbDetail class instances containing the movie information from the TMDb database.</returns>
        public static async Task <IEnumerable <TMDbDetail> > GetMoviesAsync(EasyClient easy, string path, string posterSize = "original")
        {
            var movieApi = easy.GetApi <IMovieApi>().Value; // create a IMovieApi..

            // List files of known video formats from the given path..
            IEnumerable <FileEnumeratorFileEntry> fileEntries =
                await FileEnumerator.RecurseFilesAsync(path, FileEnumerator.FiltersVideoVlcNoBinNoIso).ConfigureAwait(false);

            // initialize the result..
            List <TMDbDetail> result = new List <TMDbDetail>();

            // loop through the files and try to get a details for them..
            foreach (FileEnumeratorFileEntry entry in fileEntries)
            {
                // query the movie from the TMDb database..
                MovieList list = await movieApi.SearchMoviesAsync(entry.FileNameNoExtension).ConfigureAwait(false);

                // if something was found..
                if (list != null && list.Total_results > 0)
                {
                    result.Add(new TMDbDetail()                 // return the details of the movie..
                    {
                        ID          = list.Results[0].Id,       // the first result is only taken into account..
                        Title       = list.Results[0].Title,    // set the title..
                        Description = list.Results[0].Overview, // set the overview..
                        FileName    = entry.FileName,           // set the file name..

                        // create an Uri for the poster path..
                        PosterOrStillURL = new Uri("https://image.tmdb.org/t/p/" + posterSize + list.Results[0].Poster_path)
                    });
                }
                else // nothing was found..
                {
                    result.Add(new TMDbDetail()
                    {
                        Title       = entry.FileNameNoExtension, // the title can be the file name without path or extension..
                        Description = entry.FileNameNoExtension, // the description can be the file name without path or extension..
                        FileName    = entry.FileName             // set the file name..
                    });
                }
            }
            return(result);
        }
        /// <summary>
        /// Searches the TMDb database for a TV season based on a given path using a TMdbEasy.EasyClient class instance.
        /// </summary>
        /// <param name="easy">A TMdbEasy.EasyClient class instance to use for the search.</param>
        /// <param name="path">A path to enumerate files from.</param>
        /// <param name="stillSize">The size of the still image to get the URL for.</param>
        /// <param name="excludeFileNames">File names to be left out of the search.</param>
        /// <returns>A collection of TMDbDetail class instances containing the TV show season information from the TMDb database.</returns>
        public static async Task <IEnumerable <TMDbDetail> > GetSeasonAsync(EasyClient easy, string path, string stillSize = "original", List <string> excludeFileNames = null)
        {
            var televisionApi = easy.GetApi <ITelevisionApi>().Value; // create a ITelevisionApi..

            // avoid the null value..
            excludeFileNames = excludeFileNames ?? new List <string>();

            string fileName = string.Empty;

            if (File.Exists(path))
            {
                fileName = path;
                path     = Path.GetDirectoryName(path);
            }

            // List files of known video formats from the given path..
            IEnumerable <FileEnumeratorFileEntry> fileEntries =
                await FileEnumerator.RecurseFilesAsync(path, FileEnumerator.FiltersVideoVlcNoBinNoIso).ConfigureAwait(false);

            // remove the "useless" files from the list..
            List <FileEnumeratorFileEntry> tmpFilesList = new List <FileEnumeratorFileEntry>();

            // not in the include list..
            if (fileName != string.Empty)
            {
                fileEntries = fileEntries.Where(f => f.FileNameWithPath == fileName);
            }

            foreach (FileEnumeratorFileEntry entry in fileEntries.ToList())
            {
                // excluded from the list..
                if (excludeFileNames.Contains(entry.FileName))
                {
                    continue;            // ..so do continue..
                }
                tmpFilesList.Add(entry); // ..else add to the list..
            }

            fileEntries = tmpFilesList; // re-assign the list back to the source..

            // don't start searching if the directory is empty - we don't want to cause excess stress for the TMDb database..
            if (fileEntries.ToList().Count == 0)
            {
                // ..so just throw an exception..
                throw new Exception("No files were found from the given path string.");
            }

            // construct a search string of the given path..
            string searchString = GetTVShowSearchString(path);
            int    season       = GetTVShowSeason(path); // extract a season number from the given path..

            if (season == -1)                            // if no season number was in the given path..
            {
                // ..just throw an exception..
                throw new Exception("The TV season number wasn't found of the given path string.");
            }

            // initialize the result..
            List <TMDbDetail> result = new List <TMDbDetail>();

            // search for TV shows base on the search string build from the given directory name..
            TVShowList list = await televisionApi.SearchTVShowsAsync(searchString).ConfigureAwait(false);

            // if something was found..
            if (list != null && list.Total_results > 0)   // ..deepen the search..
            {
                string seriesName = list.Results[0].Name; // save the name of the TV show..
                int    seriesID   = list.Results[0].Id;   // save the ID of the TV show..

                // find the TV show season from the TMDb database with an ID and a season number..
                TvSeason tvSeason = await televisionApi.GetSeasonDetailsAsync(seriesID, season).ConfigureAwait(false);

                // if something was found..
                if (tvSeason != null && tvSeason.Episodes != null)
                {
                    foreach (Episode episode in tvSeason.Episodes) // return the details of the TV show season..
                    {
                        // don't return a file-less TMDbDetail class instance..
                        if (GetFileNameMatchingTVSeasonEpisode(fileEntries, season, episode.Episode_number) == null)
                        {
                            continue; // ..so just continue the loop..
                        }

                        result.Add(new TMDbDetail
                        {
                            ID        = seriesID,    // the TMDb id for the TV show..
                            SeasonID  = tvSeason.Id, // the TMDb id for the TV show season..
                            EpisodeID = episode.Id,  // the TMDb id for the TV show season episode..

                            // formulate the title base on the TVEpisodeFormat or the "overriding" TVEpisodeFormatCustom property value..
                            Title = TVEpisodeFormatCustom != string.Empty ?
                                    TVEpisodeFormatCustom.
                                    Replace("#SNUM#", tvSeason.Season_number.ToString()).                 // the season number as one digit..
                                    Replace("#ENUM#", episode.Episode_number.ToString()).                 // the episode number as one digit..
                                    Replace("#EPISODE_NAME#", episode.Name).                              // the name of the episode..
                                    Replace("#SERIES_NAME#", seriesName).                                 // the name of the series..
                                    Replace("#SEASON_NAME#", tvSeason.Name).                              // the name of the TV show season..
                                    Replace("#SNUM2#", string.Format("{0:00}", tvSeason.Season_number)).  // the season number as two digits..
                                    Replace("#ENUM2#", string.Format("{0:00}", episode.Episode_number)) : // the episode number as two digits..
                                    string.Format(TVEpisodeFormat, seriesName, tvSeason.Name, episode.Episode_number, episode.Name),

                            // set the description..
                            Description       = string.IsNullOrEmpty(tvSeason.Overview) ? episode.Overview : tvSeason.Overview,
                            DetailDescription = episode.Overview, // set the detailed description if any..

                            // find the file name for the TV show episode..
                            FileName = GetFileNameMatchingTVSeasonEpisode(fileEntries, season, episode.Episode_number).FileName,

                            // create an URL for the still using the TV season's poster path as a "fail safe"..
                            PosterOrStillURL = new Uri("https://image.tmdb.org/t/p/" + stillSize +
                                                       (string.IsNullOrEmpty(episode.Still_path) ? tvSeason.Poster_path : episode.Still_path)),
                            Season  = season,                // set the season number..
                            Episode = episode.Episode_number // set the episode number..
                        });
                    }
                }
                else // nothing was found..
                {
                    // loop through the found files..
                    foreach (FileEnumeratorFileEntry entry in fileEntries)
                    {
                        result.Add(new TMDbDetail
                        {
                            Title    = entry.FileNameNoExtension,             // the title can be the file name without path or extension..
                            FileName = entry.FileName,                        // set the file name..
                            Season   = season,                                // set the season number..
                            Episode  = GetTVShowEpisodeNumber(entry.FileName) // set the episode number..
                        });
                    }
                }
            }
            return(result);
        }