private void GenerateOpenMenu([NotNull] ProcessedSeason seas, ICollection <string> added) { Dictionary <int, SafeList <string> > afl = show.AllExistngFolderLocations(); if (!afl.ContainsKey(seas.SeasonNumber)) { return; } bool first = true; foreach (string folder in afl[seas.SeasonNumber].OrderBy(s => s)) { if (!string.IsNullOrEmpty(folder) && Directory.Exists(folder) && !added.Contains(folder)) { added.Add(folder); // don't show the same folder more than once if (first) { GenerateSeparator(gridSummary.showRightClickMenu); first = false; } AddRcMenuItem(gridSummary.showRightClickMenu, "Open: " + folder, (sender, args) => { Helpers.OpenFolder(folder); }); } } }
private void GenerateRightClickWatchMenu([NotNull] ProcessedSeason seas) { // for each episode in season, find it on disk bool first = true; DirFilesCache dfc = new DirFilesCache(); foreach (ProcessedEpisode epds in show.SeasonEpisodes[seas.SeasonNumber]) { List <FileInfo> fl = dfc.FindEpOnDisk(epds, false); if (fl.Count > 0) { if (first) { GenerateSeparator(gridSummary.showRightClickMenu); first = false; } foreach (FileInfo fi in fl) { ToolStripMenuItem tsi = new ToolStripMenuItem("Watch: " + fi.FullName); tsi.Click += (sender, args) => { Helpers.OpenFile(fi.FullName); }; gridSummary.showRightClickMenu.Items.Add(tsi); } } } }
public ShowSummarySeasonData(int seasonNumber, int episodeCount, int episodeAiredCount, int episodeGotCount, ProcessedSeason processedSeason) { SeasonNumber = seasonNumber; this.episodeCount = episodeCount; this.episodeAiredCount = episodeAiredCount; this.episodeGotCount = episodeGotCount; ProcessedSeason = processedSeason; }
public bool Filter(ShowConfiguration si, [NotNull] ProcessedSeason sea) { if (sea.SeasonNumber == 0 && TVSettings.Instance.IgnoreAllSpecials) { return(true); } return(!HideIgnoredSeasons || !si.IgnoreSeasons.Contains(sea.SeasonNumber)); }
public void AddEpisode([NotNull] Episode e) { ProcessedSeason airedProcessedSeason = GetOrAddAiredSeason(e.AiredSeasonNumber, e.SeasonId); airedProcessedSeason.AddUpdateEpisode(e); ProcessedSeason dvdProcessedSeason = GetOrAddDvdSeason(e.DvdSeasonNumber, e.SeasonId); dvdProcessedSeason.AddUpdateEpisode(e); }
public override void OnMouseDown(CellContext sender, [NotNull] MouseEventArgs e) { if (e.Button != MouseButtons.Right) { return; } gridSummary.showRightClickMenu.Items.Clear(); ProcessedSeason seas = processedSeason; if (seas is null) { AddRcMenuItem(gridSummary.showRightClickMenu, "Force Refresh", (o, args) => { gridSummary.MainWindow.ForceRefresh(show, false); }); GenerateSeparator(gridSummary.showRightClickMenu); } AddRcMenuItem(gridSummary.showRightClickMenu, "Visit thetvdb.com", (o, args) => { if (seas is null) { TvdbFor(show); } else { TvdbFor(processedSeason); } } ); List <string> added = new List <string>(); if (seas != null) { GenerateOpenMenu(seas, added); } GenerateRightClickOpenMenu(added); if (seas != null) { GenerateRightClickWatchMenu(seas); } Point pt = new Point(e.X, e.Y); gridSummary.showRightClickMenu.Show(sender.Grid.PointToScreen(pt)); }
public ProcessedEpisode([NotNull] ProcessedEpisode o) : base(o) { NextToAir = o.NextToAir; EpNum2 = o.EpNum2; Ignore = o.Ignore; Show = o.Show; OverallNumber = o.OverallNumber; Type = o.Type; TheAiredProcessedSeason = o.TheAiredProcessedSeason; TheDvdProcessedSeason = o.TheDvdProcessedSeason; SourceEpisodes = new List <Episode>(); }
public ProcessedSeason GetOrAddDvdSeason(int num, int seasonId) { if (dvdSeasons.ContainsKey(num)) { return(dvdSeasons[num]); } ProcessedSeason s = new ProcessedSeason(this, num, seasonId, ProcessedSeason.SeasonType.dvd); dvdSeasons[num] = s; return(s); }
public ProcessedEpisode([NotNull] Episode e, [NotNull] ShowConfiguration si) : base(e) { OverallNumber = -1; NextToAir = false; Ignore = false; Show = si; EpNum2 = Show.Order == ProcessedSeason.SeasonType.dvd ? DvdEpNum : AiredEpNum; Type = ProcessedEpisodeType.single; TheAiredProcessedSeason = si.GetOrAddAiredSeason(e.AiredSeasonNumber, e.SeasonId); TheDvdProcessedSeason = si.GetOrAddDvdSeason(e.DvdSeasonNumber, e.SeasonId); SourceEpisodes = new List <Episode>(); }
public ProcessedEpisode([NotNull] ProcessedEpisode e, [NotNull] ShowConfiguration si, List <Episode> episodes) : base(e) { OverallNumber = -1; NextToAir = false; Show = si; EpNum2 = Show.Order == ProcessedSeason.SeasonType.dvd ? DvdEpNum : AiredEpNum; Ignore = false; SourceEpisodes = episodes; Type = ProcessedEpisodeType.merged; TheAiredProcessedSeason = e.TheAiredProcessedSeason; TheDvdProcessedSeason = e.TheDvdProcessedSeason; }
public static List <ProcessedEpisode>?GenerateEpisodes([NotNull] ShowConfiguration si, int snum, bool applyRules) { if (!si.AppropriateSeasons().ContainsKey(snum)) { Logger.Error($"Asked to update season {snum} of {si.ShowName}, but it does not exist"); return(null); } ProcessedSeason seas = si.AppropriateSeasons()[snum]; if (seas is null) { Logger.Error($"Asked to update season {snum} of {si.ShowName}, whilst it exists, it has no contents"); return(null); } List <ProcessedEpisode> eis = seas.Episodes.Values.Select(e => new ProcessedEpisode(e, si)).ToList(); switch (si.Order) { case ProcessedSeason.SeasonType.dvd: eis.Sort(ProcessedEpisode.DVDOrderSorter); AutoMerge(eis, si); Renumber(eis); break; case ProcessedSeason.SeasonType.aired: eis.Sort(ProcessedEpisode.EpNumberSorter); break; default: throw new ArgumentOutOfRangeException(); } if (si.CountSpecials && si.AppropriateSeasons().ContainsKey(0) && !TVSettings.Instance.IgnoreAllSpecials) { // merge specials in MergeSpecialsIn(si, snum, eis); } if (applyRules) { List <ShowRule> rules = si.RulesForSeason(snum); if (rules != null) { ApplyRules(eis, rules, si); } } return(eis); }
public ProcessedEpisode([NotNull] ProcessedEpisode pe, ShowConfiguration si, [NotNull] string name, int airedEpNum, int dvdEpNum, int epNum2) : base(pe) { //This is used when a new episode is inserted EpisodeId = -1; SrvLastUpdated = 0; Overview = string.Empty; Runtime = null; LinkUrl = null; EpisodeRating = null; EpisodeGuestStars = null; EpisodeDirector = null; Writer = null; Dirty = false; DvdChapter = null; DvdDiscId = null; AirsBeforeEpisode = null; AirsBeforeSeason = null; AirsAfterSeason = null; SiteRatingCount = null; AbsoluteNumber = null; ProductionCode = null; ImdbCode = null; Filename = null; AirStamp = null; AirTime = null; NextToAir = false; OverallNumber = -1; Ignore = false; Name = name; AiredEpNum = airedEpNum; DvdEpNum = dvdEpNum; EpNum2 = epNum2; Show = si; Type = ProcessedEpisodeType.single; TheAiredProcessedSeason = pe.TheAiredProcessedSeason; TheDvdProcessedSeason = pe.TheDvdProcessedSeason; SourceEpisodes = new List <Episode>(); }
public override ItemList?ProcessSeason(ShowConfiguration si, string folder, int snum, bool forceRefresh) { ProcessedSeason processedSeason = si.GetSeason(snum) ?? throw new ArgumentException($"ProcessSeason called for {si.ShowName} invalid season ({snum}), show has ({si.AppropriateSeasons().Keys.Select(i => i.ToString() ).ToCsv()})"); DateTime? updateTime = processedSeason.LastAiredDate(); if (!TVSettings.Instance.CorrectFileDates || !updateTime.HasValue) { return(null); } if (si.AutoAddType == ShowConfiguration.AutomaticFolderType.baseOnly && folder.Equals(si.AutoAddFolderBase)) { //We do not need to look at the season folder - there is no such thing as it'll be covered by the show folder return(null); } DateTime newUpdateTime = Helpers.GetMinWindowsTime(updateTime.Value); DirectoryInfo di = new DirectoryInfo(folder); try { if (di.LastWriteTimeUtc != newUpdateTime && !doneFilesAndFolders.Contains(di.FullName)) { doneFilesAndFolders.Add(di.FullName); return(new ItemList { new ActionDateTouchSeason(di, processedSeason, newUpdateTime) }); } } catch (Exception) { doneFilesAndFolders.Add(di.FullName); return(new ItemList { new ActionDateTouchSeason(di, processedSeason, newUpdateTime) }); } return(null); }
private static ShowSummaryData.ShowSummarySeasonData?GetSeasonDetails([NotNull] ShowConfiguration si, int snum) { int epCount = 0; int epGotCount = 0; int epAiredCount = 0; DirFilesCache dfc = new DirFilesCache(); ProcessedSeason processedSeason = null; if (snum >= 0 && si.AppropriateSeasons().TryGetValue(snum, out processedSeason)) { List <ProcessedEpisode> eis = si.SeasonEpisodes[snum]; foreach (ProcessedEpisode ei in eis) { epCount++; // if has air date and has been aired in the past if (ei.FirstAired != null && ei.FirstAired < DateTime.Now) { epAiredCount++; } List <FileInfo> fl = dfc.FindEpOnDisk(ei, false); if (fl.Count != 0) { epGotCount++; } } } if (processedSeason != null) { return(new ShowSummaryData.ShowSummarySeasonData(snum, epCount, epAiredCount, epGotCount, processedSeason, si.IgnoreSeasons.Contains(snum))); } return(null); }
private readonly ProcessedSeason processedSeason; // if for an entire show, rather than specific episode public ActionDateTouchSeason(DirectoryInfo dir, ProcessedSeason sn, DateTime date) : base(dir, date) { processedSeason = sn; }
public ShowClickEvent(ShowSummary gridSummary, ShowConfiguration show, ProcessedSeason processedSeason) { this.show = show; this.processedSeason = processedSeason; this.gridSummary = gridSummary; }
public static string NameFor(ProcessedSeason s, string styleString) => NameFor(s, styleString, false);
public static List <string> ExamplePresets(ProcessedSeason s) { return(Presets.Select(example => NameFor(s, example)).ToList()); }
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()); }
private void PopulateGrid() { if (grid1.IsDisposed) { return; } Cell colTitleModel = new Cell { ElementText = new ActorsGrid.RotatedText(-90.0f), BackColor = Color.SteelBlue, ForeColor = Color.White, TextAlignment = ContentAlignment.BottomCenter }; Cell topleftTitleModel = new Cell { BackColor = Color.SteelBlue, ForeColor = Color.White, TextAlignment = ContentAlignment.BottomLeft }; grid1.Columns.Clear(); grid1.Rows.Clear(); int maxSeason = GetMaxSeason(showList); int cols = maxSeason + 3; int rows = showList.Count + 1; // Draw Header grid1.ColumnsCount = cols; grid1.RowsCount = rows; grid1.FixedColumns = 2; grid1.FixedRows = 1; grid1.Selection.EnableMultiSelection = false; grid1.Rows[0].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize; grid1.Rows[0].Height = 65; ColumnHeader h = new ColumnHeader("Show") { AutomaticSortEnabled = false, ResizeEnabled = false }; grid1[0, 0] = h; grid1[0, 0].View = topleftTitleModel; ColumnHeader h2 = new ColumnHeader("Status") { AutomaticSortEnabled = false, ResizeEnabled = false }; grid1[0, 1] = h2; grid1[0, 1].View = topleftTitleModel; // Draw season for (int c = chkHideSpecials.Checked?1:0; c < maxSeason + 1; c++) { h = new ColumnHeader(ProcessedSeason.UIFullSeasonWord(c)) { AutomaticSortEnabled = false, ResizeEnabled = false }; grid1[0, c + 2] = h; grid1[0, c + 2].View = colTitleModel; grid1.Columns[c + 2].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; } grid1.Columns[0].Width = 150; // Draw Shows int r = 0; foreach (ShowSummaryData show in showList) { //Ignore shows with no missing episodes if (chkHideComplete.Checked && !show.HasMssingEpisodes(chkHideSpecials.Checked, chkHideIgnored.Checked)) { continue; } //Ignore shows with no missing aired episodes if (chkHideUnaired.Checked && !show.HasAiredMssingEpisodes(chkHideSpecials.Checked, chkHideIgnored.Checked)) { continue; } //Ignore shows which do not have the missing check if (chkHideNotScanned.Checked && !show.ShowConfiguration.DoMissingCheck) { continue; } if (chkOnlyShowEnded.Checked && !show.ShowConfiguration.ShowStatus.Equals("Ended", StringComparison.OrdinalIgnoreCase)) { continue; } if (chkHideDiskEps.Checked && show.HasEpisodesOnDisk()) { continue; } RowHeader rh = new RowHeader(show.ShowName) { ResizeEnabled = false, View = new Cell { ForeColor = show.ShowConfiguration.DoMissingCheck ? Color.Black : Color.Gray } }; //Gray if the show is not checked for missing episodes in the scan grid1[r + 1, 0] = rh; grid1[r + 1, 0].AddController(new ShowClickEvent(this, show.ShowConfiguration)); RowHeader rh2 = new RowHeader(show.ShowConfiguration.ShowStatus) { ResizeEnabled = false, View = new Cell { ForeColor = show.ShowConfiguration.DoMissingCheck ? Color.Black : Color.Gray } }; //Gray if the show is not checked for missing episodes in the scan grid1[r + 1, 1] = rh2; foreach (ShowSummaryData.ShowSummarySeasonData seasonData in show.SeasonDataList) { ShowSummaryData.SummaryOutput output = seasonData.GetOuput(); //Ignore Season if checkbox is checked if (chkHideSpecials.Checked && output.Special) { continue; } //Ignore Season if checkbox is checked if (chkHideIgnored.Checked && output.Ignored) { continue; } grid1[r + 1, seasonData.SeasonNumber + 2] = new SourceGrid.Cells.Cell(output.Details, typeof(string)) { View = new Cell { BackColor = output.Color, ForeColor = Color.White, TextAlignment = ContentAlignment.BottomRight }, Editor = { EditableMode = EditableMode.None } }; grid1[r + 1, seasonData.SeasonNumber + 2].AddController(new ShowClickEvent(this, show.ShowConfiguration, seasonData.ProcessedSeason)); } r++; } grid1.AutoSizeCells(); }