Exemplo n.º 1
0
        public void no_result_title_lookup()
        {
            //setup
            var tvdbProvider = new TvDbProvider();

            //act
            var result = tvdbProvider.GetSeries("clone high");

            //assert
            Assert.IsNull(result);
        }
Exemplo n.º 2
0
        public virtual Series UpdateSeriesInfo(int seriesId)
        {
            var tvDbSeries = _tvDbProvider.GetSeries(seriesId, false, true);
            var series     = GetSeries(seriesId);

            series.SeriesId      = tvDbSeries.Id;
            series.Title         = tvDbSeries.SeriesName;
            series.AirTimes      = CleanAirsTime(tvDbSeries.AirsTime);
            series.AirsDayOfWeek = tvDbSeries.AirsDayOfWeek;
            series.Overview      = tvDbSeries.Overview;
            series.Status        = tvDbSeries.Status;
            series.Language      = tvDbSeries.Language != null ? tvDbSeries.Language.Abbriviation : string.Empty;
            series.CleanTitle    = Parser.NormalizeTitle(tvDbSeries.SeriesName);
            series.LastInfoSync  = DateTime.Now;
            series.Runtime       = (int)tvDbSeries.Runtime;
            series.BannerUrl     = tvDbSeries.BannerPath;
            series.Network       = tvDbSeries.Network;

            if (tvDbSeries.FirstAired.Year > 1900)
            {
                series.FirstAired = tvDbSeries.FirstAired.Date;
            }
            else
            {
                series.FirstAired = null;
            }

            try
            {
                if (series.TvRageId == 0)
                {
                    series = _tvRageMappingProvider.FindMatchingTvRageSeries(series);
                }
            }

            catch (Exception ex)
            {
                logger.ErrorException("Error getting TvRage information for series: " + series.Title, ex);
            }

            UpdateSeries(series);
            _metadataProvider.CreateForSeries(series, tvDbSeries);

            return(series);
        }
Exemplo n.º 3
0
        public virtual void RefreshEpisodeInfo(Series series)
        {
            logger.Trace("Starting episode info refresh for series: {0}", series.Title.WithDefault(series.SeriesId));
            var successCount = 0;
            var failCount = 0;

            var tvdbEpisodes = _tvDbProvider.GetSeries(series.SeriesId, true)
                                        .Episodes
                                        .Where(episode => !string.IsNullOrWhiteSpace(episode.EpisodeName) ||
                                              (episode.FirstAired < DateTime.Now.AddDays(2) && episode.FirstAired.Year > 1900))
                                                .ToList();

            var seriesEpisodes = GetEpisodeBySeries(series.SeriesId);
            var updateList = new List<Episode>();
            var newList = new List<Episode>();

            _seasonProvider.EnsureSeasons(series.SeriesId, tvdbEpisodes.Select(c => c.SeasonNumber).Distinct());
            
            foreach (var episode in tvdbEpisodes.OrderBy(e => e.SeasonNumber).ThenBy(e => e.EpisodeNumber))
            {
                try
                {
                    logger.Trace("Updating info for [{0}] - S{1:00}E{2:00}", series.Title, episode.SeasonNumber, episode.EpisodeNumber);

                    //first check using tvdbId, this should cover cases when and episode number in a season is changed
                    var episodeToUpdate = seriesEpisodes.SingleOrDefault(e => e.TvDbEpisodeId == episode.Id);

                    //not found, try using season/episode number
                    if (episodeToUpdate == null)
                    {
                        episodeToUpdate = seriesEpisodes.SingleOrDefault(e => e.SeasonNumber == episode.SeasonNumber && e.EpisodeNumber == episode.EpisodeNumber);
                    }

                    if (episodeToUpdate == null)
                    {
                        episodeToUpdate = new Episode();
                        newList.Add(episodeToUpdate);

                        //If it is Episode Zero Ignore it (specials, sneak peeks.)
                        if (episode.EpisodeNumber == 0 && episode.SeasonNumber != 1)
                        {
                            episodeToUpdate.Ignored = true;
                        }
                        else
                        {
                            episodeToUpdate.Ignored = _seasonProvider.IsIgnored(series.SeriesId, episode.SeasonNumber);
                        }
                    }
                    else
                    {
                        updateList.Add(episodeToUpdate);
                    }

                    if ((episodeToUpdate.EpisodeNumber != episode.EpisodeNumber || 
                        episodeToUpdate.SeasonNumber != episode.SeasonNumber) && 
                        episodeToUpdate.EpisodeFileId > 0)
                    {
                        logger.Info("Unlinking episode file because TheTVDB changed the epsiode number...");

                        _database.Delete<EpisodeFile>(episodeToUpdate.EpisodeFileId);
                        episodeToUpdate.EpisodeFileId = 0;
                    }

                    episodeToUpdate.SeriesId = series.SeriesId;
                    episodeToUpdate.TvDbEpisodeId = episode.Id;
                    episodeToUpdate.EpisodeNumber = episode.EpisodeNumber;
                    episodeToUpdate.SeasonNumber = episode.SeasonNumber;
                    episodeToUpdate.AbsoluteEpisodeNumber = episode.AbsoluteNumber;
                    episodeToUpdate.Title = episode.EpisodeName;

                    episodeToUpdate.Overview = episode.Overview.Truncate(3500);

                    if (episode.FirstAired.Year > 1900)
                        episodeToUpdate.AirDate = episode.FirstAired.Date;
                    else
                        episodeToUpdate.AirDate = null;

                    successCount++;
                }
                catch (Exception e)
                {
                    logger.FatalException(String.Format("An error has occurred while updating episode info for series {0}", series.Title), e);
                    failCount++;
                }
            }

            _database.InsertMany(newList);
            _database.UpdateMany(updateList);

            if (failCount != 0)
            {
                logger.Info("Finished episode refresh for series: {0}. Successful: {1} - Failed: {2} ",
                            series.Title, successCount, failCount);
            }
            else
            {
                logger.Info("Finished episode refresh for series: {0}.", series.Title);
            }

            DeleteEpisodesNotInTvdb(series, tvdbEpisodes);
        }
Exemplo n.º 4
0
        public void successful_title_lookup(string title)
        {
            var tvCont = new TvDbProvider();
            var result = tvCont.GetSeries(title);

            Assert.AreEqual(title, result.SeriesName, StringComparison.InvariantCultureIgnoreCase);
        }
Exemplo n.º 5
0
        public virtual void CreateForSeries(Series series)
        {
            var tvDbSeries = _tvDbProvider.GetSeries(series.SeriesId, false, true);

            CreateForSeries(series, tvDbSeries);
        }