Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

Target 10.7 #49

Merged
merged 3 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Emby.AutoOrganize/Api/FileOrganizationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public ActionResult PerformOrganization([FromRoute] string id)
/// Performs organization of a movie.
/// </summary>
/// <param name="id">Result id.</param>
/// <param name="movieId">Movie id</param>
/// <param name="movieId">Movie id.</param>
/// <param name="newMovieName">Name of a movie to add.</param>
/// <param name="newMovieYear">Year of a movie to add.</param>
/// <param name="newMovieProviderIds">A list of provider IDs identifying a new movie.</param>
Expand Down
4 changes: 2 additions & 2 deletions Emby.AutoOrganize/Core/EpisodeFileOrganizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private NamingOptions GetNamingOptionsInternal()
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;
Expand Down Expand Up @@ -153,7 +153,7 @@ private NamingOptions GetNamingOptionsInternal()
// 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;

Expand Down
31 changes: 0 additions & 31 deletions Emby.AutoOrganize/Core/FileOrganizationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -58,18 +56,6 @@ public class FileOrganizationService : IFileOrganizationService
_providerManager = providerManager;
}

/// <inheritdoc/>
public event EventHandler<GenericEventArgs<FileOrganizationResult>> ItemAdded;

/// <inheritdoc/>
public event EventHandler<GenericEventArgs<FileOrganizationResult>> ItemUpdated;

/// <inheritdoc/>
public event EventHandler<GenericEventArgs<FileOrganizationResult>> ItemRemoved;

/// <inheritdoc/>
public event EventHandler LogReset;

/// <inheritdoc/>
public void BeginProcessNewFiles()
{
Expand Down Expand Up @@ -165,8 +151,6 @@ public async Task DeleteOriginalFile(string resultId)
}

await _repo.Delete(resultId).ConfigureAwait(false);

ItemRemoved?.Invoke(this, new GenericEventArgs<FileOrganizationResult>(result));
}

/// <inheritdoc/>
Expand Down Expand Up @@ -219,14 +203,12 @@ public async Task PerformOrganization(string resultId)
public async Task ClearLog()
{
await _repo.DeleteAll().ConfigureAwait(false);
LogReset?.Invoke(this, EventArgs.Empty);
}

/// <inheritdoc/>
public async Task ClearCompleted()
{
await _repo.DeleteCompleted().ConfigureAwait(false);
LogReset?.Invoke(this, EventArgs.Empty);
}

/// <inheritdoc/>
Expand Down Expand Up @@ -311,16 +293,6 @@ public bool AddToInProgressList(FileOrganizationResult result, bool isNewItem)
}

result.IsInProgress = true;

if (isNewItem)
{
ItemAdded?.Invoke(this, new GenericEventArgs<FileOrganizationResult>(result));
}
else
{
ItemUpdated?.Invoke(this, new GenericEventArgs<FileOrganizationResult>(result));
}

return true;
}

Expand All @@ -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<FileOrganizationResult>(result));

return retval;
}
}
Expand Down
22 changes: 0 additions & 22 deletions Emby.AutoOrganize/Core/IFileOrganizationService.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,26 +10,6 @@ namespace Emby.AutoOrganize.Core
/// </summary>
public interface IFileOrganizationService
{
/// <summary>
/// Occurs when a new <see cref="FileOrganizationResult"/> record has been created.
/// </summary>
event EventHandler<GenericEventArgs<FileOrganizationResult>> ItemAdded;

/// <summary>
/// Occurs when a <see cref="FileOrganizationResult"/> record has been updated.
/// </summary>
event EventHandler<GenericEventArgs<FileOrganizationResult>> ItemUpdated;

/// <summary>
/// Occurs when a <see cref="FileOrganizationResult"/> record has been deleted.
/// </summary>
event EventHandler<GenericEventArgs<FileOrganizationResult>> ItemRemoved;

/// <summary>
/// Occurs when multiple <see cref="FileOrganizationResult"/> records are deleted.
/// </summary>
event EventHandler LogReset;

/// <summary>
/// Processes the new files.
/// </summary>
Expand Down
14 changes: 5 additions & 9 deletions Emby.AutoOrganize/Core/MovieFileOrganizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,19 @@ public class MovieFileOrganizer
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,
Expand Down
6 changes: 3 additions & 3 deletions Emby.AutoOrganize/Emby.AutoOrganize.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<FileVersion>8.0.0.0</FileVersion>
<TargetFramework>net5.0</TargetFramework>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<FileVersion>9.0.0.0</FileVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

Expand Down
41 changes: 5 additions & 36 deletions Emby.AutoOrganize/PluginEntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);

Expand All @@ -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<FileOrganizationResult> e)
{
_sessionManager.SendMessageToAdminSessions("AutoOrganize_ItemUpdated", e.Argument, CancellationToken.None);
}

private void OnOrganizationServiceItemRemoved(object sender, GenericEventArgs<FileOrganizationResult> e)
{
_sessionManager.SendMessageToAdminSessions("AutoOrganize_ItemRemoved", e.Argument, CancellationToken.None);
}

private void OnOrganizationServiceItemAdded(object sender, GenericEventArgs<FileOrganizationResult> e)
{
_sessionManager.SendMessageToAdminSessions("AutoOrganize_ItemAdded", e.Argument, CancellationToken.None);
}

/// <inheritdoc/>
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();
}
}
}
5 changes: 3 additions & 2 deletions build.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down