diff --git a/Emby.AutoOrganize/Api/FileOrganizationController.cs b/Emby.AutoOrganize/Api/FileOrganizationController.cs index c8140fd..b553ceb 100644 --- a/Emby.AutoOrganize/Api/FileOrganizationController.cs +++ b/Emby.AutoOrganize/Api/FileOrganizationController.cs @@ -166,7 +166,7 @@ public ActionResult OrganizeEpisode( /// Performs organization of a movie. /// /// Result id. - /// Movie id + /// Movie id. /// Name of a movie to add. /// Year of a movie to add. /// A list of provider IDs identifying a new movie. diff --git a/Emby.AutoOrganize/Core/EpisodeFileOrganizer.cs b/Emby.AutoOrganize/Core/EpisodeFileOrganizer.cs index b40cc78..aadcd16 100644 --- a/Emby.AutoOrganize/Core/EpisodeFileOrganizer.cs +++ b/Emby.AutoOrganize/Core/EpisodeFileOrganizer.cs @@ -104,7 +104,7 @@ public async Task OrganizeEpisodeFile( var resolver = new EpisodeResolver(namingOptions); var episodeInfo = resolver.Resolve(path, false) ?? - new Naming.TV.EpisodeInfo(); + new Naming.TV.EpisodeInfo(string.Empty); var seriesName = episodeInfo.SeriesName; int? seriesYear = null; @@ -153,7 +153,7 @@ public async Task OrganizeEpisodeFile( // if an earlier result exist with an different type, we update it result.Type = CurrentFileOrganizerType; - var endingEpisodeNumber = episodeInfo.EndingEpsiodeNumber; + var endingEpisodeNumber = episodeInfo.EndingEpisodeNumber; result.ExtractedEndingEpisodeNumber = endingEpisodeNumber; diff --git a/Emby.AutoOrganize/Core/FileOrganizationService.cs b/Emby.AutoOrganize/Core/FileOrganizationService.cs index 442b29c..fb86e41 100644 --- a/Emby.AutoOrganize/Core/FileOrganizationService.cs +++ b/Emby.AutoOrganize/Core/FileOrganizationService.cs @@ -2,7 +2,6 @@ using System.Collections.Concurrent; using System.Diagnostics.CodeAnalysis; using System.Globalization; -using System.Linq; using System.Threading; using System.Threading.Tasks; using Emby.AutoOrganize.Data; @@ -11,7 +10,6 @@ using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Providers; -using MediaBrowser.Model.Events; using MediaBrowser.Model.IO; using MediaBrowser.Model.Querying; using MediaBrowser.Model.Tasks; @@ -58,18 +56,6 @@ public FileOrganizationService( _providerManager = providerManager; } - /// - public event EventHandler> ItemAdded; - - /// - public event EventHandler> ItemUpdated; - - /// - public event EventHandler> ItemRemoved; - - /// - public event EventHandler LogReset; - /// public void BeginProcessNewFiles() { @@ -165,8 +151,6 @@ public async Task DeleteOriginalFile(string resultId) } await _repo.Delete(resultId).ConfigureAwait(false); - - ItemRemoved?.Invoke(this, new GenericEventArgs(result)); } /// @@ -219,14 +203,12 @@ public async Task PerformOrganization(string resultId) public async Task ClearLog() { await _repo.DeleteAll().ConfigureAwait(false); - LogReset?.Invoke(this, EventArgs.Empty); } /// public async Task ClearCompleted() { await _repo.DeleteCompleted().ConfigureAwait(false); - LogReset?.Invoke(this, EventArgs.Empty); } /// @@ -311,16 +293,6 @@ public bool AddToInProgressList(FileOrganizationResult result, bool isNewItem) } result.IsInProgress = true; - - if (isNewItem) - { - ItemAdded?.Invoke(this, new GenericEventArgs(result)); - } - else - { - ItemUpdated?.Invoke(this, new GenericEventArgs(result)); - } - return true; } @@ -331,9 +303,6 @@ public bool RemoveFromInprogressList(FileOrganizationResult result) var retval = _inProgressItemIds.TryRemove(result.Id, out itemValue); result.IsInProgress = false; - - ItemUpdated.Invoke(this, new GenericEventArgs(result)); - return retval; } } diff --git a/Emby.AutoOrganize/Core/IFileOrganizationService.cs b/Emby.AutoOrganize/Core/IFileOrganizationService.cs index 258991f..6ffd8bb 100644 --- a/Emby.AutoOrganize/Core/IFileOrganizationService.cs +++ b/Emby.AutoOrganize/Core/IFileOrganizationService.cs @@ -1,8 +1,6 @@ -using System; using System.Threading; using System.Threading.Tasks; using Emby.AutoOrganize.Model; -using MediaBrowser.Model.Events; using MediaBrowser.Model.Querying; namespace Emby.AutoOrganize.Core @@ -12,26 +10,6 @@ namespace Emby.AutoOrganize.Core /// public interface IFileOrganizationService { - /// - /// Occurs when a new record has been created. - /// - event EventHandler> ItemAdded; - - /// - /// Occurs when a record has been updated. - /// - event EventHandler> ItemUpdated; - - /// - /// Occurs when a record has been deleted. - /// - event EventHandler> ItemRemoved; - - /// - /// Occurs when multiple records are deleted. - /// - event EventHandler LogReset; - /// /// Processes the new files. /// diff --git a/Emby.AutoOrganize/Core/MovieFileOrganizer.cs b/Emby.AutoOrganize/Core/MovieFileOrganizer.cs index 199fa11..4fc24a2 100644 --- a/Emby.AutoOrganize/Core/MovieFileOrganizer.cs +++ b/Emby.AutoOrganize/Core/MovieFileOrganizer.cs @@ -90,23 +90,19 @@ public async Task OrganizeMovieFile( return result; } - _namingOptions = _namingOptions ?? new NamingOptions(); + _namingOptions ??= new NamingOptions(); var resolver = new VideoResolver(_namingOptions); - var movieInfo = resolver.Resolve(path, false) ?? - new VideoFileInfo(); - - var movieName = movieInfo.Name; - - if (!string.IsNullOrEmpty(movieName)) + var movieInfo = resolver.Resolve(path, false); + if (!string.IsNullOrEmpty(movieInfo?.Name)) { var movieYear = movieInfo.Year; - _logger.LogDebug("Extracted information from {0}. Movie {1}, Year {2}", path, movieName, movieYear); + _logger.LogDebug("Extracted information from {0}. Movie {1}, Year {2}", path, movieInfo.Name, movieYear); await OrganizeMovie( path, - movieName, + movieInfo.Name, movieYear, options, overwriteExisting, diff --git a/Emby.AutoOrganize/Emby.AutoOrganize.csproj b/Emby.AutoOrganize/Emby.AutoOrganize.csproj index 4c8e9ec..4894092 100644 --- a/Emby.AutoOrganize/Emby.AutoOrganize.csproj +++ b/Emby.AutoOrganize/Emby.AutoOrganize.csproj @@ -1,9 +1,9 @@ - netstandard2.1 - 8.0.0.0 - 8.0.0.0 + net5.0 + 9.0.0.0 + 9.0.0.0 true diff --git a/Emby.AutoOrganize/PluginEntryPoint.cs b/Emby.AutoOrganize/PluginEntryPoint.cs index e18222b..5bf6127 100644 --- a/Emby.AutoOrganize/PluginEntryPoint.cs +++ b/Emby.AutoOrganize/PluginEntryPoint.cs @@ -4,14 +4,15 @@ using Emby.AutoOrganize.Core; using Emby.AutoOrganize.Data; using Emby.AutoOrganize.Model; +using Jellyfin.Data.Events; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Plugins; using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Session; -using MediaBrowser.Model.Events; using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; +using MediaBrowser.Model.Session; using MediaBrowser.Model.Tasks; using Microsoft.Extensions.Logging; @@ -86,11 +87,6 @@ public Task RunAsync() Current = this; FileOrganizationService = new FileOrganizationService(_taskManager, _repository, _loggerFactory, _libraryMonitor, _libraryManager, _config, _fileSystem, _providerManager); - FileOrganizationService.ItemAdded += OnOrganizationServiceItemAdded; - FileOrganizationService.ItemRemoved += OnOrganizationServiceItemRemoved; - FileOrganizationService.ItemUpdated += OnOrganizationServiceItemUpdated; - FileOrganizationService.LogReset += OnOrganizationServiceLogReset; - // Convert Config _config.ConvertSmartMatchInfo(FileOrganizationService); @@ -109,38 +105,11 @@ private IFileOrganizationRepository GetRepository() return repo; } - private void OnOrganizationServiceLogReset(object sender, EventArgs e) - { - _sessionManager.SendMessageToAdminSessions("AutoOrganize_LogReset", (FileOrganizationResult)null, CancellationToken.None); - } - - private void OnOrganizationServiceItemUpdated(object sender, GenericEventArgs e) - { - _sessionManager.SendMessageToAdminSessions("AutoOrganize_ItemUpdated", e.Argument, CancellationToken.None); - } - - private void OnOrganizationServiceItemRemoved(object sender, GenericEventArgs e) - { - _sessionManager.SendMessageToAdminSessions("AutoOrganize_ItemRemoved", e.Argument, CancellationToken.None); - } - - private void OnOrganizationServiceItemAdded(object sender, GenericEventArgs e) - { - _sessionManager.SendMessageToAdminSessions("AutoOrganize_ItemAdded", e.Argument, CancellationToken.None); - } - - /// public void Dispose() { - FileOrganizationService.ItemAdded -= OnOrganizationServiceItemAdded; - FileOrganizationService.ItemRemoved -= OnOrganizationServiceItemRemoved; - FileOrganizationService.ItemUpdated -= OnOrganizationServiceItemUpdated; - FileOrganizationService.LogReset -= OnOrganizationServiceLogReset; - - if (_repository is IDisposable repo) - { - repo.Dispose(); - } + _taskManager?.Dispose(); + _loggerFactory?.Dispose(); + _libraryMonitor?.Dispose(); } } } diff --git a/build.yaml b/build.yaml index 0bb2dd1..ec1fdcc 100644 --- a/build.yaml +++ b/build.yaml @@ -1,8 +1,9 @@ --- name: "Auto Organize" guid: "70b7b43b-471b-4159-b4be-56750c795499" -version: "8.0.0.0" -targetAbi: "10.6.0.0" +version: "9.0.0.0" +targetAbi: "10.7.0.0" +framework: "net5.0" owner: "jellyfin" overview: "Automatically organize your media" description: "Automatically organize your media"