コード例 #1
0
        public async Task <Episode> FindAsync(Series series, string fileName)
        {
            var noExtension = Path.GetFileNameWithoutExtension(fileName);

            int episodeNumber = FindEpisodeNumber(noExtension);
            int seasonNumber  = FindSeasonNumber(series, noExtension);

            // check the database!
            Episode result = await _repo.FindAsync(episodeNumber, seasonNumber, series.Id);

            if (result != null)
            {
                return(result);
            }

            // check api
            result = await FindWithApi(series, seasonNumber, episodeNumber);

            if (result != null)
            {
                result.Id = await _repo.AddAsync(result);

                return(result);
            }

            return(null);
        }