Пример #1
0
        static bool ParseSeries(Match ma, EpisodeInfo episodeInfo)
        {
            if (!ma.Success)
            {
                return(false);
            }

            Group group = ma.Groups[GROUP_SERIES];

            if (group.Length > 0)
            {
                episodeInfo.HasChanged |= MetadataUpdater.SetOrUpdateString(ref episodeInfo.SeriesName, EpisodeInfo.CleanupWhiteSpaces(group.Value), true);
            }

            group = ma.Groups[GROUP_EPISODE];
            if (group.Length > 0)
            {
                episodeInfo.HasChanged |= MetadataUpdater.SetOrUpdateString(ref episodeInfo.EpisodeName, EpisodeInfo.CleanupWhiteSpaces(group.Value), true);
            }

            group = ma.Groups[GROUP_SEASONNUM];
            int tmpInt;

            if (group.Length > 0 && int.TryParse(group.Value, out tmpInt))
            {
                episodeInfo.SeasonNumber = tmpInt;
            }

            // There can be multiple episode numbers in one file
            group = ma.Groups[GROUP_EPISODENUM];
            if (group.Length > 0)
            {
                List <int> episodeNums = new List <int>();
                if (group.Captures.Count > 1)
                {
                    foreach (Capture capture in group.Captures)
                    {
                        int episodeNum;
                        if (int.TryParse(capture.Value, out episodeNum))
                        {
                            episodeNums.Add(episodeNum);
                        }
                    }
                }
                else if (ma.Groups[GROUP_ENDEPISODENUM].Length > 0)
                {
                    int start;
                    if (int.TryParse(group.Value, out start))
                    {
                        int end;
                        group = ma.Groups[GROUP_ENDEPISODENUM];
                        if (group.Length > 0 && int.TryParse(group.Value, out end))
                        {
                            for (int episode = start; episode <= end; episode++)
                            {
                                episodeNums.Add(episode);
                            }
                        }
                    }
                }
                else
                {
                    foreach (Capture capture in group.Captures)
                    {
                        int episodeNum;
                        if (int.TryParse(capture.Value, out episodeNum))
                        {
                            episodeNums.Add(episodeNum);
                        }
                    }
                }
                if (episodeNums.Count > 0 && !episodeInfo.EpisodeNumbers.SequenceEqual(episodeNums))
                {
                    episodeInfo.HasChanged     = true;
                    episodeInfo.EpisodeNumbers = new List <int>(episodeNums);
                }
            }
            return(true);
        }