Target 10.9.z

This commit is contained in:
Kilian von Pflugk 2024-03-22 23:41:58 +01:00
parent 1e300f0182
commit 5d743302e4
9 changed files with 88 additions and 64 deletions

View File

@ -21,7 +21,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore

View File

@ -22,7 +22,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>

View File

@ -9,6 +9,7 @@ using MediaBrowser.Controller.Plugins;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Session;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace ConfusedPolarBear.Plugin.IntroSkipper;
@ -17,7 +18,7 @@ namespace ConfusedPolarBear.Plugin.IntroSkipper;
/// Automatically skip past introduction sequences.
/// Commands clients to seek to the end of the intro as soon as they start playing it.
/// </summary>
public class AutoSkip : IServerEntryPoint
public class AutoSkip : IHostedService, IDisposable
{
private readonly object _sentSeekCommandLock = new();
@ -44,26 +45,6 @@ public class AutoSkip : IServerEntryPoint
_sentSeekCommand = new Dictionary<string, bool>();
}
/// <summary>
/// If introduction auto skipping is enabled, set it up.
/// </summary>
/// <returns>Task.</returns>
public Task RunAsync()
{
_logger.LogDebug("Setting up automatic skipping");
_userDataManager.UserDataSaved += UserDataManager_UserDataSaved;
Plugin.Instance!.AutoSkipChanged += AutoSkipChanged;
// Make the timer restart automatically and set enabled to match the configuration value.
_playbackTimer.AutoReset = true;
_playbackTimer.Elapsed += PlaybackTimer_Elapsed;
AutoSkipChanged(null, EventArgs.Empty);
return Task.CompletedTask;
}
private void AutoSkipChanged(object? sender, EventArgs e)
{
var newState = Plugin.Instance!.Configuration.AutoSkip;
@ -222,8 +203,31 @@ public class AutoSkip : IServerEntryPoint
return;
}
_userDataManager.UserDataSaved -= UserDataManager_UserDataSaved;
_playbackTimer.Stop();
_playbackTimer.Dispose();
}
/// <inheritdoc />
public Task StartAsync(CancellationToken cancellationToken)
{
_logger.LogDebug("Setting up automatic skipping");
_userDataManager.UserDataSaved += UserDataManager_UserDataSaved;
Plugin.Instance!.AutoSkipChanged += AutoSkipChanged;
// Make the timer restart automatically and set enabled to match the configuration value.
_playbackTimer.AutoReset = true;
_playbackTimer.Elapsed += PlaybackTimer_Elapsed;
AutoSkipChanged(null, EventArgs.Empty);
return Task.CompletedTask;
}
/// <inheritdoc />
public Task StopAsync(CancellationToken cancellationToken)
{
_userDataManager.UserDataSaved -= UserDataManager_UserDataSaved;
return Task.CompletedTask;
}
}

View File

@ -41,7 +41,7 @@ introSkipper.fetchWrapper = async function (...args) {
introSkipper.viewShow = function () {
const location = window.location.hash;
introSkipper.d("Location changed to " + location);
if (location !== "#!/video") {
if (location !== "#/video") {
introSkipper.d("Ignoring location change");
return;
}

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>ConfusedPolarBear.Plugin.IntroSkipper</RootNamespace>
<AssemblyVersion>0.1.16.3</AssemblyVersion>
<FileVersion>0.1.16.3</FileVersion>
@ -11,8 +11,8 @@
<CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Jellyfin.Controller" Version="10.8.*" />
<PackageReference Include="Jellyfin.Model" Version="10.8.*" />
<PackageReference Include="Jellyfin.Controller" Version="10.9.*" />
<PackageReference Include="Jellyfin.Model" Version="10.9.*" />
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.556" PrivateAssets="All" />

View File

@ -1,8 +1,8 @@
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Plugins;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace ConfusedPolarBear.Plugin.IntroSkipper;
@ -10,7 +10,7 @@ namespace ConfusedPolarBear.Plugin.IntroSkipper;
/// <summary>
/// Server entrypoint.
/// </summary>
public class Entrypoint : IServerEntryPoint
public class Entrypoint : IHostedService
{
private readonly IUserManager _userManager;
private readonly IUserViewManager _userViewManager;
@ -40,39 +40,12 @@ public class Entrypoint : IServerEntryPoint
_loggerFactory = loggerFactory;
}
/// <summary>
/// Registers event handler.
/// </summary>
/// <returns>Task.</returns>
public Task RunAsync()
{
FFmpegWrapper.Logger = _logger;
// TODO: when a new item is added to the server, immediately analyze the season it belongs to
// instead of waiting for the next task interval. The task start should be debounced by a few seconds.
try
{
// Enqueue all episodes at startup to ensure any FFmpeg errors appear as early as possible
_logger.LogInformation("Running startup enqueue");
var queueManager = new QueueManager(_loggerFactory.CreateLogger<QueueManager>(), _libraryManager);
queueManager.GetMediaItems();
}
catch (Exception ex)
{
_logger.LogError("Unable to run startup enqueue: {Exception}", ex);
}
return Task.CompletedTask;
}
/// <summary>
/// Dispose.
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
@ -86,4 +59,33 @@ public class Entrypoint : IServerEntryPoint
return;
}
}
/// <inheritdoc />
public Task StartAsync(CancellationToken cancellationToken)
{
FFmpegWrapper.Logger = _logger;
// TODO: when a new item is added to the server, immediately analyze the season it belongs to
// instead of waiting for the next task interval. The task start should be debounced by a few seconds.
try
{
// Enqueue all episodes at startup to ensure any FFmpeg errors appear as early as possible
_logger.LogInformation("Running startup enqueue");
var queueManager = new QueueManager(_loggerFactory.CreateLogger<QueueManager>(), _libraryManager);
queueManager?.GetMediaItems();
}
catch (Exception ex)
{
_logger.LogError("Unable to run startup enqueue: {Exception}", ex);
}
return Task.CompletedTask;
}
/// <inheritdoc />
public Task StopAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
}

View File

@ -0,0 +1,18 @@
using MediaBrowser.Controller;
using MediaBrowser.Controller.Plugins;
using Microsoft.Extensions.DependencyInjection;
namespace ConfusedPolarBear.Plugin.IntroSkipper
{
/// <summary>
/// Register Intro Skipper services.
/// </summary>
public class PluginServiceRegistrator : IPluginServiceRegistrator
{
/// <inheritdoc />
public void RegisterServices(IServiceCollection serviceCollection, IServerApplicationHost applicationHost)
{
serviceCollection.AddHostedService<AutoSkip>();
}
}
}

View File

@ -129,13 +129,13 @@ public class QueueManager
{
// Order by series name, season, and then episode number so that status updates are logged in order
ParentId = id,
OrderBy = new[]
OrderBy = new List<(ItemSortBy, SortOrder)>
{
("SeriesSortName", SortOrder.Ascending),
("ParentIndexNumber", SortOrder.Ascending),
("IndexNumber", SortOrder.Ascending),
new(ItemSortBy.SeriesSortName, SortOrder.Ascending),
new(ItemSortBy.ParentIndexNumber, SortOrder.Ascending),
new(ItemSortBy.IndexNumber, SortOrder.Ascending),
},
IncludeItemTypes = new BaseItemKind[] { BaseItemKind.Episode },
IncludeItemTypes = [BaseItemKind.Episode],
Recursive = true,
IsVirtualItem = false
};