Example #1
0
        /// <summary>
        /// Tests if a media file is a valid tv file.
        /// </summary>
        /// <returns>If a file is a tv file.</returns>
        public override bool Test()
        {
            if (_testGaurentee)
            {
                return(true);
            }

            if (Episode.Count == 0 || ((Season == 0 || Episode.Contains(0)) && Name == UnknownString && string.IsNullOrWhiteSpace(Title)))
            {
                return(false);
            }

            if (Season == 0 && (Name == UnknownString || (Episode.Count == 1 && Episode[0] > 20 && string.IsNullOrWhiteSpace(Title))))
            {
                return(false);
            }

            var earliest = SectorList.TakeWhile(sector => !Regex.Match(sector, "^([0-9]+)|(SP)$").Success).Count();

            if (SectorList.Count > earliest && earliest >= 0 && Name == UnknownString &&
                !(SectorList[earliest + 1] == "-" || SectorList[earliest + 1] == ":" || SectorList[earliest + 1] == "."))
            {
                return(false);
            }

            if (Season == 0 && string.IsNullOrWhiteSpace(Title) && Name.Split(' ').Length < 2)
            {
                return(false);
            }

            return(true);
        }
Example #2
0
        /// <summary>
        /// Sets the fields of this TVFile based on a returned TVDB episode.
        /// </summary>
        private void SetTvdbFields()
        {
            var episode = GetTvdbEpisode();

            Title = episode.EpisodeName;
            try { Year = episode.FirstAiredDate.Year; } catch { Debug.WriteLine("Failed to set Year from TVDB"); }
            if (Season != episode.SeasonNumber)
            {
                Season = episode.SeasonNumber;
            }
            if (!Episode.Contains(episode.EpisodeNumber))
            {
                Episode.Add(episode.EpisodeNumber);
            }
        }