示例#1
0
        private string GetTargetEpisodeName([NotNull] ShowItem show, [NotNull] Episode ep, bool urlEncode)
        {
            //note this is for an Episode and not a ProcessedEpisode
            string name = StyleString;

            string epname = ep.Name;

            name = name.ReplaceInsensitive("{ShowName}", show.ShowName);
            switch (show.Order)
            {
            case Season.SeasonType.dvd:
                name = name.ReplaceInsensitive("{Season}", ep.DvdSeasonNumber.ToString());
                name = name.ReplaceInsensitive("{Season:2}", ep.DvdSeasonNumber.ToString("00"));
                name = name.ReplaceInsensitive("{SeasonNumber}", show.GetSeasonIndex(ep.DvdSeasonNumber).ToString());
                name = name.ReplaceInsensitive("{SeasonNumber:2}", show.GetSeasonIndex(ep.DvdSeasonNumber).ToString("00"));
                name = name.ReplaceInsensitive("{Episode}", ep.DvdEpNum.ToString("00"));
                name = name.ReplaceInsensitive("{Episode2}", ep.DvdEpNum.ToString("00"));
                name = Regex.Replace(name, "{AllEpisodes}", ep.DvdEpNum.ToString("00")); break;

            case Season.SeasonType.aired:
                name = name.ReplaceInsensitive("{Season}", ep.AiredSeasonNumber.ToString());
                name = name.ReplaceInsensitive("{Season:2}", ep.AiredSeasonNumber.ToString("00"));
                name = name.ReplaceInsensitive("{SeasonNumber}", show.GetSeasonIndex(ep.AiredSeasonNumber).ToString());
                name = name.ReplaceInsensitive("{SeasonNumber:2}", show.GetSeasonIndex(ep.AiredSeasonNumber).ToString("00"));
                name = name.ReplaceInsensitive("{Episode}", ep.AiredEpNum.ToString("00"));
                name = name.ReplaceInsensitive("{Episode2}", ep.AiredEpNum.ToString("00"));
                name = Regex.Replace(name, "{AllEpisodes}", ep.AiredEpNum.ToString("00"));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            name = name.ReplaceInsensitive("{EpisodeName}", epname);
            name = name.ReplaceInsensitive("{Number}", "");
            name = name.ReplaceInsensitive("{Number:2}", "");
            name = name.ReplaceInsensitive("{Number:3}", "");
            name = name.ReplaceInsensitive("{Imdb}", ep.ImdbCode);

            SeriesInfo si = show.TheSeries();

            name = name.ReplaceInsensitive("{ShowImdb}", si?.Imdb ?? string.Empty);
            name = name.ReplaceInsensitive("{Year}", si?.MinYear.ToString() ?? string.Empty);

            Season selectedSeason = show.GetSeason(ep.GetSeasonNumber(show.Order));

            name = name.ReplaceInsensitive("{SeasonYear}", selectedSeason != null ? selectedSeason.MinYear().ToString() : string.Empty);

            name = ReplaceDates(urlEncode, name, ep.GetAirDateDt(show.GetTimeZone()));

            name = Regex.Replace(name, "([^\\\\])\\[.*?[^\\\\]\\]", "$1"); // remove optional parts

            name = name.Replace("\\[", "[");
            name = name.Replace("\\]", "]");

            return(name.Trim());
        }