Exemplo n.º 1
0
        public void successful_search(string title)
        {
            var result = tvDbProvider.SearchSeries(title);

            result.Should().NotBeEmpty();
            result[0].SeriesName.Should().Be(title);
        }
        public ActionResult ExistingSeries()
        {
            var result = new ExistingSeriesModel();

            var unmappedList = new List <String>();

            foreach (var folder in _rootFolderProvider.GetAll())
            {
                unmappedList.AddRange(_rootFolderProvider.GetUnmappedFolders(folder.Path));
            }

            result.ExistingSeries = new List <Tuple <string, string, int> >();

            foreach (var folder in unmappedList)
            {
                var foldername = new DirectoryInfo(folder).Name;

                try
                {
                    var tvdbResult = _tvDbProvider.SearchSeries(foldername).FirstOrDefault();

                    var title    = String.Empty;
                    var seriesId = 0;
                    if (tvdbResult != null)
                    {
                        title    = tvdbResult.SeriesName;
                        seriesId = tvdbResult.Id;
                    }

                    result.ExistingSeries.Add(new Tuple <string, string, int>(folder, title, seriesId));
                }
                catch (Exception ex)
                {
                    logger.WarnException("Failed to connect to TheTVDB to search for: " + foldername, ex);
                    return(View());
                }
            }

            var defaultQuality = Convert.ToInt32(_configProvider.DefaultQualityProfile);

            result.Quality = new SelectList(_qualityProvider.All(), "QualityProfileId", "Name", defaultQuality);

            return(View(result));
        }