From a442688eda77114f3fe727982215eb28baaf7004 Mon Sep 17 00:00:00 2001 From: Mark Date: Wed, 31 May 2023 00:50:12 +0800 Subject: [PATCH] Fix #947 - New Feature to scan for shows and movies that have no folders created for them (or deleted) --- TVRename/Forms/UI.Designer.cs | 49 ++++++---- TVRename/Forms/UI.cs | 8 +- TVRename/Forms/UI.resx | 36 +++---- .../ItemsAndActions/ChangeLibraryAction.cs | 93 +++++++++++++++++++ .../RemoveShowsWithNoFolders.cs | 85 +++++++++++++++++ TVRename/TVRename/ActionEngine.cs | 1 + 6 files changed, 233 insertions(+), 39 deletions(-) create mode 100644 TVRename/ItemsAndActions/ChangeLibraryAction.cs create mode 100644 TVRename/ScanActivity/PostScanActivity/RemoveShowsWithNoFolders.cs diff --git a/TVRename/Forms/UI.Designer.cs b/TVRename/Forms/UI.Designer.cs index 52a301a00..c7166dd55 100644 --- a/TVRename/Forms/UI.Designer.cs +++ b/TVRename/Forms/UI.Designer.cs @@ -277,6 +277,7 @@ public void InitializeComponent() bwAction = new System.ComponentModel.BackgroundWorker(); tableLayoutPanel3 = new TableLayoutPanel(); panel1 = new Panel(); + removeShowsWithNoFoldersToolStripMenuItem = new ToolStripMenuItem(); menuStrip1.SuspendLayout(); tabControl1.SuspendLayout(); tbMyMovies.SuspendLayout(); @@ -462,7 +463,7 @@ public void InitializeComponent() // // toolsToolStripMenuItem // - toolsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { flushCacheToolStripMenuItem, flushImageCacheToolStripMenuItem, backgroundDownloadNowToolStripMenuItem, toolStripSeparator17, folderMonitorToolStripMenuItem, bulkAddMoviesToolStripMenuItem, toolStripSeparator3, tsmiOrphanFiles, duplicateFinderLOGToolStripMenuItem, duplicateMoviesToolStripMenuItem, toolStripSeparator18, quickRenameToolStripMenuItem, scanMovieFolderToolStripMenuItem, toolStripSeparator21, movieRecommendationsToolStripMenuItem, tvRecommendationsToolStripMenuItem, toolStripSeparator121, cleanLibraryFoldersToolStripMenuItem, forceRefreshKodiTVShowNFOFIlesToolStripMenuItem }); + toolsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { flushCacheToolStripMenuItem, flushImageCacheToolStripMenuItem, backgroundDownloadNowToolStripMenuItem, toolStripSeparator17, folderMonitorToolStripMenuItem, bulkAddMoviesToolStripMenuItem, toolStripSeparator3, tsmiOrphanFiles, duplicateFinderLOGToolStripMenuItem, duplicateMoviesToolStripMenuItem, toolStripSeparator18, quickRenameToolStripMenuItem, scanMovieFolderToolStripMenuItem, toolStripSeparator21, movieRecommendationsToolStripMenuItem, tvRecommendationsToolStripMenuItem, toolStripSeparator121, cleanLibraryFoldersToolStripMenuItem, forceRefreshKodiTVShowNFOFIlesToolStripMenuItem, removeShowsWithNoFoldersToolStripMenuItem }); toolsToolStripMenuItem.Name = "toolsToolStripMenuItem"; toolsToolStripMenuItem.Size = new System.Drawing.Size(46, 20); toolsToolStripMenuItem.Text = "&Tools"; @@ -470,14 +471,14 @@ public void InitializeComponent() // flushCacheToolStripMenuItem // flushCacheToolStripMenuItem.Name = "flushCacheToolStripMenuItem"; - flushCacheToolStripMenuItem.Size = new System.Drawing.Size(273, 22); + flushCacheToolStripMenuItem.Size = new System.Drawing.Size(277, 26); flushCacheToolStripMenuItem.Text = "&Force Refesh All"; flushCacheToolStripMenuItem.Click += flushCacheToolStripMenuItem_Click; // // flushImageCacheToolStripMenuItem // flushImageCacheToolStripMenuItem.Name = "flushImageCacheToolStripMenuItem"; - flushImageCacheToolStripMenuItem.Size = new System.Drawing.Size(273, 22); + flushImageCacheToolStripMenuItem.Size = new System.Drawing.Size(277, 26); flushImageCacheToolStripMenuItem.Text = "&Force Refesh All Images"; flushImageCacheToolStripMenuItem.Click += flushImageCacheToolStripMenuItem_Click; // @@ -486,110 +487,110 @@ public void InitializeComponent() backgroundDownloadNowToolStripMenuItem.Image = (System.Drawing.Image)resources.GetObject("backgroundDownloadNowToolStripMenuItem.Image"); backgroundDownloadNowToolStripMenuItem.Name = "backgroundDownloadNowToolStripMenuItem"; backgroundDownloadNowToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.B; - backgroundDownloadNowToolStripMenuItem.Size = new System.Drawing.Size(273, 22); + backgroundDownloadNowToolStripMenuItem.Size = new System.Drawing.Size(277, 26); backgroundDownloadNowToolStripMenuItem.Text = "&Background Download Now"; backgroundDownloadNowToolStripMenuItem.Click += backgroundDownloadNowToolStripMenuItem_Click; // // toolStripSeparator17 // toolStripSeparator17.Name = "toolStripSeparator17"; - toolStripSeparator17.Size = new System.Drawing.Size(270, 6); + toolStripSeparator17.Size = new System.Drawing.Size(274, 6); // // folderMonitorToolStripMenuItem // folderMonitorToolStripMenuItem.Image = (System.Drawing.Image)resources.GetObject("folderMonitorToolStripMenuItem.Image"); folderMonitorToolStripMenuItem.Name = "folderMonitorToolStripMenuItem"; - folderMonitorToolStripMenuItem.Size = new System.Drawing.Size(273, 22); + folderMonitorToolStripMenuItem.Size = new System.Drawing.Size(277, 26); folderMonitorToolStripMenuItem.Text = "Bulk &Add TV Shows..."; folderMonitorToolStripMenuItem.Click += folderMonitorToolStripMenuItem_Click; // // bulkAddMoviesToolStripMenuItem // bulkAddMoviesToolStripMenuItem.Name = "bulkAddMoviesToolStripMenuItem"; - bulkAddMoviesToolStripMenuItem.Size = new System.Drawing.Size(273, 22); + bulkAddMoviesToolStripMenuItem.Size = new System.Drawing.Size(277, 26); bulkAddMoviesToolStripMenuItem.Text = "Bulk Add Movies..."; bulkAddMoviesToolStripMenuItem.Click += bulkAddMoviesToolStripMenuItem_Click; // // toolStripSeparator3 // toolStripSeparator3.Name = "toolStripSeparator3"; - toolStripSeparator3.Size = new System.Drawing.Size(270, 6); + toolStripSeparator3.Size = new System.Drawing.Size(274, 6); // // tsmiOrphanFiles // tsmiOrphanFiles.Name = "tsmiOrphanFiles"; - tsmiOrphanFiles.Size = new System.Drawing.Size(273, 22); + tsmiOrphanFiles.Size = new System.Drawing.Size(277, 26); tsmiOrphanFiles.Text = "Find Orphan Media Files...."; tsmiOrphanFiles.Click += ToolStripMenuItem1_Click; // // duplicateFinderLOGToolStripMenuItem // duplicateFinderLOGToolStripMenuItem.Name = "duplicateFinderLOGToolStripMenuItem"; - duplicateFinderLOGToolStripMenuItem.Size = new System.Drawing.Size(273, 22); + duplicateFinderLOGToolStripMenuItem.Size = new System.Drawing.Size(277, 26); duplicateFinderLOGToolStripMenuItem.Text = "Find Merged Episodes..."; duplicateFinderLOGToolStripMenuItem.Click += duplicateFinderLOGToolStripMenuItem_Click; // // duplicateMoviesToolStripMenuItem // duplicateMoviesToolStripMenuItem.Name = "duplicateMoviesToolStripMenuItem"; - duplicateMoviesToolStripMenuItem.Size = new System.Drawing.Size(273, 22); + duplicateMoviesToolStripMenuItem.Size = new System.Drawing.Size(277, 26); duplicateMoviesToolStripMenuItem.Text = "Find Duplicate Movies..."; duplicateMoviesToolStripMenuItem.Click += duplicateMoviesToolStripMenuItem_Click; // // toolStripSeparator18 // toolStripSeparator18.Name = "toolStripSeparator18"; - toolStripSeparator18.Size = new System.Drawing.Size(270, 6); + toolStripSeparator18.Size = new System.Drawing.Size(274, 6); // // quickRenameToolStripMenuItem // quickRenameToolStripMenuItem.Name = "quickRenameToolStripMenuItem"; - quickRenameToolStripMenuItem.Size = new System.Drawing.Size(273, 22); + quickRenameToolStripMenuItem.Size = new System.Drawing.Size(277, 26); quickRenameToolStripMenuItem.Text = "Quick Rename TV Files..."; quickRenameToolStripMenuItem.Click += QuickRenameToolStripMenuItem_Click; // // scanMovieFolderToolStripMenuItem // scanMovieFolderToolStripMenuItem.Name = "scanMovieFolderToolStripMenuItem"; - scanMovieFolderToolStripMenuItem.Size = new System.Drawing.Size(273, 22); + scanMovieFolderToolStripMenuItem.Size = new System.Drawing.Size(277, 26); scanMovieFolderToolStripMenuItem.Text = "Move Movies From..."; scanMovieFolderToolStripMenuItem.Click += scanMovieFolderToolStripMenuItem_Click; // // toolStripSeparator21 // toolStripSeparator21.Name = "toolStripSeparator21"; - toolStripSeparator21.Size = new System.Drawing.Size(270, 6); + toolStripSeparator21.Size = new System.Drawing.Size(274, 6); // // movieRecommendationsToolStripMenuItem // movieRecommendationsToolStripMenuItem.Name = "movieRecommendationsToolStripMenuItem"; - movieRecommendationsToolStripMenuItem.Size = new System.Drawing.Size(273, 22); + movieRecommendationsToolStripMenuItem.Size = new System.Drawing.Size(277, 26); movieRecommendationsToolStripMenuItem.Text = "Movie Recommendations..."; movieRecommendationsToolStripMenuItem.Click += movieRecommendationsToolStripMenuItem_Click; // // tvRecommendationsToolStripMenuItem // tvRecommendationsToolStripMenuItem.Name = "tvRecommendationsToolStripMenuItem"; - tvRecommendationsToolStripMenuItem.Size = new System.Drawing.Size(273, 22); + tvRecommendationsToolStripMenuItem.Size = new System.Drawing.Size(277, 26); tvRecommendationsToolStripMenuItem.Text = "TV Show Recommendations..."; tvRecommendationsToolStripMenuItem.Click += recommendationsToolStripMenuItem_Click; // // toolStripSeparator121 // toolStripSeparator121.Name = "toolStripSeparator121"; - toolStripSeparator121.Size = new System.Drawing.Size(270, 6); + toolStripSeparator121.Size = new System.Drawing.Size(274, 6); // // cleanLibraryFoldersToolStripMenuItem // cleanLibraryFoldersToolStripMenuItem.Name = "cleanLibraryFoldersToolStripMenuItem"; - cleanLibraryFoldersToolStripMenuItem.Size = new System.Drawing.Size(273, 22); + cleanLibraryFoldersToolStripMenuItem.Size = new System.Drawing.Size(277, 26); cleanLibraryFoldersToolStripMenuItem.Text = "Clean Empty Library Folders..."; cleanLibraryFoldersToolStripMenuItem.Click += cleanLibraryFoldersToolStripMenuItem_Click; // // forceRefreshKodiTVShowNFOFIlesToolStripMenuItem // forceRefreshKodiTVShowNFOFIlesToolStripMenuItem.Name = "forceRefreshKodiTVShowNFOFIlesToolStripMenuItem"; - forceRefreshKodiTVShowNFOFIlesToolStripMenuItem.Size = new System.Drawing.Size(273, 22); + forceRefreshKodiTVShowNFOFIlesToolStripMenuItem.Size = new System.Drawing.Size(277, 26); forceRefreshKodiTVShowNFOFIlesToolStripMenuItem.Text = "Force Refresh Kodi TV Show NFO FIles"; forceRefreshKodiTVShowNFOFIlesToolStripMenuItem.Click += forceRefreshKodiTVShowNFOFIlesToolStripMenuItem_Click; // @@ -2322,6 +2323,13 @@ public void InitializeComponent() panel1.Size = new System.Drawing.Size(1102, 690); panel1.TabIndex = 12; // + // removeShowsWithNoFoldersToolStripMenuItem + // + removeShowsWithNoFoldersToolStripMenuItem.Name = "removeShowsWithNoFoldersToolStripMenuItem"; + removeShowsWithNoFoldersToolStripMenuItem.Size = new System.Drawing.Size(277, 26); + removeShowsWithNoFoldersToolStripMenuItem.Text = "Remove Shows With No Folders..."; + removeShowsWithNoFoldersToolStripMenuItem.Click += removeShowsWithNoFoldersToolStripMenuItem_Click; + // // UI // AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -2634,5 +2642,6 @@ public void InitializeComponent() private ToolStripMenuItem yTSMoviePreviewToolStripMenuItem; private ToolStripMenuItem yTSMovieRecommendationsToolStripMenuItem; private ToolStripMenuItem forceRefreshKodiTVShowNFOFIlesToolStripMenuItem; + private ToolStripMenuItem removeShowsWithNoFoldersToolStripMenuItem; } } diff --git a/TVRename/Forms/UI.cs b/TVRename/Forms/UI.cs index 748121739..65224ae0f 100644 --- a/TVRename/Forms/UI.cs +++ b/TVRename/Forms/UI.cs @@ -512,6 +512,7 @@ private static object GroupItemsKeyDelegate(object rowObject) "lvgActionCopy" => "C-Copy", "lvgActionMove" => "D-Move", "lvgActionUnpack" => "K-Unpack", + "lvgActionOther" => "L-Other", _ => "UNKNOWN" }; } @@ -5480,7 +5481,7 @@ public void UpdateColorControls(Control myControl, Color fore, Color back, Color BackColor = back }; - HeaderFormatStyle hfs = new () + HeaderFormatStyle hfs = new() { Hot = hss, Normal = hss, @@ -5504,6 +5505,11 @@ public void UpdateColorControls(Control myControl, Color fore, Color back, Color UpdateColorControls(subC, fore, back, highlight); } } + + private void removeShowsWithNoFoldersToolStripMenuItem_Click(Object sender, EventArgs e) + { + PartialScan(new RemoveShowsWithNoFolders(mDoc)); + } } /// diff --git a/TVRename/Forms/UI.resx b/TVRename/Forms/UI.resx index 8d95e0394..2ebc06fb3 100644 --- a/TVRename/Forms/UI.resx +++ b/TVRename/Forms/UI.resx @@ -585,7 +585,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAmU3lzdGVtLldpbmRvd3MuRm9ybXMu SW1hZ2VMaXN0U3RyZWFtZXIBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAA9CIAAAJNU0Z0AUkBTAIBAQwB - AAF0AQsBdAELARIBAAENAQAE/wEZAQAI/wFCAU0BNgcAATYDAAEoAwABSAMAATQDAAEBAQABGAUAAeAB + AAF8AQsBfAELARIBAAENAQAE/wEZAQAI/wFCAU0BNgcAATYDAAEoAwABSAMAATQDAAEBAQABGAUAAeAB K/8A/wD/AP8A/wD/AP8A/wD/AP8A/wAbAAPvAxIGMAMJBjADDwMqAzADGwPRDwABIQHWAQgBIQHWAQgB IQHWAQgBIQHWAQgwAAL4AfcB8wHoAdoB8QHTAbYB4QGzAYwB1gGcAXEB0gGUAWgB0gGUAWcB1AGaAW8B 3wGtAYYB8AHRAbMB8wHmAdUB9wH2AfUJAAH8Af4B/wH0Av8B6QH9Af4B3gH6AfsB2wH8Af0B2wH7Af0B @@ -1040,7 +1040,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAmU3lzdGVtLldpbmRvd3MuRm9ybXMu SW1hZ2VMaXN0U3RyZWFtZXIBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAA+lsAAAJNU0Z0AUkBTAIBAQYB - AAGwAQU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AndActions/ChangeLibraryAction.cs new file mode 100644 index 000000000..c74bbff81 --- /dev/null +++ b/TVRename/ItemsAndActions/ChangeLibraryAction.cs @@ -0,0 +1,93 @@ +using System.Threading; +using System; + +namespace TVRename; + +internal abstract class ChangeLibraryAction : Action +{ + protected readonly TVDoc Doc; + + protected ChangeLibraryAction(TVDoc doc) + { + Doc = doc; + } + public override string ScanListViewGroup => "lvgActionOther"; + public override long SizeOfWork => 1; + public override IgnoreItem? Ignore => null; + public override string? TargetFolder => null; + public override int IconNumber => 9; + public override string DestinationFolder => Produces; + public override string DestinationFile => Produces; + public override string ProgressText => Produces; +} + +internal class RemoveMovie : ChangeLibraryAction +{ + public RemoveMovie(MovieConfiguration si, TVDoc doc) : base(doc) + { + Movie = si; + } + + public override int CompareTo(Item? o) + { + if (o is not RemoveMovie r) + { + return -1; + } + + return string.Compare(this.Movie?.Name, r.Movie?.Name, StringComparison.Ordinal); + } + + public override bool SameAs(Item o) => + o is RemoveMovie cmr && Movie == cmr.Movie; + + public override string Name => "Remove Movie Configuration"; + + public override ActionOutcome Go(TVRenameStats stats, CancellationToken cancellationToken) + { + if (Movie != null) + { + Doc.FilmLibrary.Remove(Movie); + Doc.MoviesAddedOrEdited(false, true, true, null, Movie); + } + return ActionOutcome.Success(); + } + + public override string Produces => Movie?.Name ?? string.Empty; +} + +internal class RemoveShow : ChangeLibraryAction +{ + private readonly ShowConfiguration si; + + public RemoveShow(ShowConfiguration si, TVDoc doc) : base(doc) + { + this.si = si; + } + public override ActionOutcome Go(TVRenameStats stats, CancellationToken cancellationToken) + { + Doc.TvLibrary.Remove(si); + Doc.TvAddedOrEdited(false, true, true, null, si); + return ActionOutcome.Success(); + } + public override string Produces => si.Name ?? string.Empty; + + public override int CompareTo(Item? o) + { + if (o is not RemoveShow r) + { + return -1; + } + + return string.Compare(this.si.Name, r.si.Name, StringComparison.Ordinal); + } + + public override bool SameAs(Item o) => + o is RemoveShow cmr && si == cmr.si; + + public override string Name => "Remove TV Show Configuration"; + + public override ShowConfiguration Series => si; + public override string SeriesName => si.ShowName; +} + diff --git a/TVRename/ScanActivity/PostScanActivity/RemoveShowsWithNoFolders.cs b/TVRename/ScanActivity/PostScanActivity/RemoveShowsWithNoFolders.cs new file mode 100644 index 000000000..1ce5e0282 --- /dev/null +++ b/TVRename/ScanActivity/PostScanActivity/RemoveShowsWithNoFolders.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using Alphaleonis.Win32.Filesystem; + +namespace TVRename; + +internal class RemoveShowsWithNoFolders : PostScanActivity +{ + public RemoveShowsWithNoFolders(TVDoc doc) : base(doc) + { + } + + public override string ActivityName() => "Clean up shows with no folders that exist"; + + protected override bool Active() => true; + protected override void DoCheck(PostScanProgressDelegate progress, CancellationToken token) + { + List libraryShows = MDoc.TvLibrary.GetSortedShowItems(); + List movieConfigurations = MDoc.FilmLibrary.GetSortedMovies(); + + int totalRecords = libraryShows.Count + movieConfigurations.Count; + int n = 0; + string lastUpdate = string.Empty; + + foreach (ShowConfiguration si in libraryShows.Where(HasAiredEpisode)) + { + progress(n++, totalRecords, si.ShowName, lastUpdate); + + if (token.IsCancellationRequested) + { + return; + } + + bool removeThisShow = si.AllProposedFolderLocations().Any() + && si.AllProposedFolderLocations() + .SelectMany(folderLocation => folderLocation.Value) + .All(NotExist); + + if (removeThisShow && si.AutoAddFolderBase.HasValue() && Directory.Exists(si.AutoAddFolderBase)) + { + removeThisShow = false; + } + + if (removeThisShow) + { + lastUpdate = $"{si.Name} has no folders that exist, removing"; + MDoc.TheActionList.Add(new RemoveShow(si,MDoc)); + } + } + + foreach (MovieConfiguration si in movieConfigurations.Where(IsReleased)) + { + progress(n++, totalRecords, si.ShowName, lastUpdate); + + if (token.IsCancellationRequested) + { + return; + } + + bool removeThisShow = si.Locations.All(NotExist); + + if (removeThisShow) + { + lastUpdate = $"{si.Name} has no folders that exist, removing"; + MDoc.TheActionList.Add(new RemoveMovie(si, MDoc)); + } + } + } + + private bool IsReleased(MovieConfiguration mc) + { + DateTime? dt = mc.CachedMovie?.FirstAired; + + return dt.HasValue && dt.Value.CompareTo(DateTime.Now) < 0; + } + + private bool HasAiredEpisode(ShowConfiguration sc) + { + return sc.GetFirstAvailableEpisode()?.HasAired() ?? false; + } + + private bool NotExist(string folderName) => !Directory.Exists(folderName); +} diff --git a/TVRename/TVRename/ActionEngine.cs b/TVRename/TVRename/ActionEngine.cs index 42e2d9843..495a07b3f 100644 --- a/TVRename/TVRename/ActionEngine.cs +++ b/TVRename/TVRename/ActionEngine.cs @@ -386,6 +386,7 @@ private static int GetQueueId(Action action) case ActionDeleteFile: case ActionDeleteDirectory: case ActionMoveRenameDirectory: + case ChangeLibraryAction: return 1; case ActionDateTouch: