Exemplo n.º 1
0
        /// <summary>
        /// Returns detailed information for a single <see cref="OmDbSeason"/> with given <paramref name="id"/>. This method caches request
        /// to same seasons using the cache path given in <see cref="OmDbApiV1"/> constructor.
        /// </summary>
        /// <param name="id">IMDB id of series</param>
        /// <param name="season">Season number</param>
        /// <returns>Season information</returns>
        public async Task <OmDbSeason> GetSeriesSeasonAsync(string id, int season, bool cacheOnly)
        {
            string     cache       = CreateAndGetCacheName(id, string.Format("Season{0}", season));
            OmDbSeason returnValue = null;

            if (!string.IsNullOrEmpty(cache) && File.Exists(cache))
            {
                returnValue = await _downloader.ReadCacheAsync <OmDbSeason>(cache).ConfigureAwait(false);
            }
            else
            {
                if (cacheOnly)
                {
                    return(null);
                }
                string url = GetUrl(URL_GETIMDBIDSEASON, 0, true, true, id, season);
                returnValue = await _downloader.DownloadAsync <OmDbSeason>(url, cache).ConfigureAwait(false);
            }
            if (returnValue == null)
            {
                return(null);
            }
            if (returnValue.ResponseValid == false)
            {
                return(null);
            }
            if (returnValue != null)
            {
                returnValue.InitEpisodes();
            }
            return(returnValue);
        }