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()); }
private string GetTargetEpisodeName([NotNull] ShowItem show, [NotNull] Episode ep, DateTimeZone tz, bool dvdOrder, 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); if (dvdOrder) { name = name.ReplaceInsensitive("{Season}", ep.DvdSeasonNumber.ToString()); name = name.ReplaceInsensitive("{Season:2}", ep.DvdSeasonNumber.ToString("00")); name = name.ReplaceInsensitive("{SeasonNumber}", ep.DvdSeasonIndex.ToString()); name = name.ReplaceInsensitive("{SeasonNumber:2}", ep.DvdSeasonIndex.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")); } else { name = name.ReplaceInsensitive("{Season}", ep.AiredSeasonNumber.ToString()); name = name.ReplaceInsensitive("{Season:2}", ep.AiredSeasonNumber.ToString("00")); name = name.ReplaceInsensitive("{SeasonNumber}", ep.AiredSeasonIndex.ToString()); name = name.ReplaceInsensitive("{SeasonNumber:2}", ep.AiredSeasonIndex.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")); } 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(dvdOrder ? ep.DvdSeasonNumber : ep.AiredSeasonNumber); name = name.ReplaceInsensitive("{SeasonYear}", selectedSeason != null ? selectedSeason.MinYear().ToString() : string.Empty); name = ReplaceDates(urlEncode, name, ep.GetAirDateDt(tz)); name = Regex.Replace(name, "([^\\\\])\\[.*?[^\\\\]\\]", "$1"); // remove optional parts name = name.Replace("\\[", "["); name = name.Replace("\\]", "]"); return(name.Trim()); }
private string GetTargetEpisodeName([NotNull] ShowConfiguration 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); name = name.ReplaceInsensitive("{ShowNameLower}", show.ShowName.ToLower().Replace(' ', '-').RemoveCharactersFrom("()[]{}&$:")); name = name.ReplaceInsensitive("{ShowNameInitial}", show.ShowName.Initial().ToLower()); int seasonNumber; int episodeNumber; switch (show.Order) { case ProcessedSeason.SeasonType.dvd: seasonNumber = ep.DvdSeasonNumber; episodeNumber = ep.DvdEpNum; break; case ProcessedSeason.SeasonType.aired: seasonNumber = ep.AiredSeasonNumber; episodeNumber = ep.AiredEpNum; break; default: throw new ArgumentOutOfRangeException(); } string seasonName = show.CachedShow?.Season(seasonNumber)?.SeasonName; name = name.ReplaceInsensitive("{Season}", seasonNumber.ToString()); name = name.ReplaceInsensitive("{Season:2}", seasonNumber.ToString("00")); name = name.ReplaceInsensitiveLazy("{SeasonNumber}", new Lazy <string?>(() => show.GetSeasonIndex(seasonNumber).ToString()), StringComparison.CurrentCultureIgnoreCase); name = name.ReplaceInsensitiveLazy("{SeasonNumber:2}", new Lazy <string?>(() => show.GetSeasonIndex(seasonNumber).ToString("00")), StringComparison.CurrentCultureIgnoreCase); name = name.ReplaceInsensitive("{Episode}", episodeNumber.ToString("00")); name = name.ReplaceInsensitive("{Episode2}", episodeNumber.ToString("00")); name = Regex.Replace(name, "{AllEpisodes}", episodeNumber.ToString("00")); name = name.ReplaceInsensitive("{SeasonName}", seasonName ?? string.Empty); 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 ?? string.Empty); CachedSeriesInfo si = show.CachedShow; name = name.ReplaceInsensitive("{ShowImdb}", si?.Imdb ?? string.Empty); name = name.ReplaceInsensitiveLazy("{Year}", new Lazy <string?>(() => si?.MinYear.ToString() ?? string.Empty), StringComparison.CurrentCultureIgnoreCase); ProcessedSeason selectedProcessedSeason = show.GetSeason(ep.GetSeasonNumber(show.Order)); name = name.ReplaceInsensitive("{SeasonYear}", selectedProcessedSeason != null ? selectedProcessedSeason.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()); }