Skip to content
This repository has been archived by the owner on Oct 13, 2024. It is now read-only.

Commit

Permalink
fix: bump Jellyfin to 10.9 (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher authored May 13, 2024
1 parent 971a217 commit 027139f
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
output: ./build
version: ${{ needs.setup_release.outputs.release_version }}
dotnet-config: Release
dotnet-target: net6.0
dotnet-target: net8.0
verbosity: debug

- name: Unit Test
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ RUN <<_DOTNET
url="https://dot.net/v1/dotnet-install.sh"
wget --quiet "$url" -O dotnet-install.sh
chmod +x ./dotnet-install.sh
./dotnet-install.sh --channel 6.0
./dotnet-install.sh --channel 8.0
_DOTNET

# create venv
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
28 changes: 28 additions & 0 deletions Jellyfin.Plugin.Themerr.Tests/TestHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using MediaBrowser.Common.Configuration;
using Moq;

namespace Jellyfin.Plugin.Themerr.Tests;

/// <summary>
/// This class is responsible for providing helper methods for testing.
/// </summary>
public static class TestHelper
{
/// <summary>
/// Gets a mock IApplicationPaths instance.
/// </summary>
/// <returns>A mock IApplicationPaths instance.</returns>
public static Mock<IApplicationPaths> GetMockApplicationPaths()
{
Mock<IApplicationPaths> mockApplicationPaths = new();

// Set up the mock IApplicationPaths instance to return valid paths
mockApplicationPaths.Setup(a => a.PluginConfigurationsPath).Returns("testing");
mockApplicationPaths.Setup(a => a.PluginsPath).Returns("testing");
mockApplicationPaths.Setup(a => a.DataPath).Returns("testing");
mockApplicationPaths.Setup(a => a.LogDirectoryPath).Returns("testing");
mockApplicationPaths.Setup(a => a.CachePath).Returns("testing");

return mockApplicationPaths;
}
}
8 changes: 7 additions & 1 deletion Jellyfin.Plugin.Themerr.Tests/TestThemerrController.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Collections;
using Jellyfin.Plugin.Themerr.Api;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Serialization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Moq;
Expand All @@ -24,10 +26,12 @@ public TestThemerrController(ITestOutputHelper output)
{
TestLogger.Initialize(output);

Mock<IApplicationPaths> mockApplicationPaths = TestHelper.GetMockApplicationPaths();
Mock<ILibraryManager> mockLibraryManager = new();
Mock<ILogger<ThemerrController>> mockLogger = new();
Mock<IServerConfigurationManager> mockServerConfigurationManager = new();
Mock<ILoggerFactory> mockLoggerFactory = new();
Mock<IXmlSerializer> mockXmlSerializer = new();

// Create a TestableServerConfiguration with UICulture set to "en-US"
var testableServerConfiguration = new TestableServerConfiguration("en-US");
Expand All @@ -36,10 +40,12 @@ public TestThemerrController(ITestOutputHelper output)
mockServerConfigurationManager.Setup(x => x.Configuration).Returns(testableServerConfiguration);

_controller = new ThemerrController(
mockApplicationPaths.Object,
mockLibraryManager.Object,
mockLogger.Object,
mockServerConfigurationManager.Object,
mockLoggerFactory.Object);
mockLoggerFactory.Object,
mockXmlSerializer.Object);
}

/// <summary>
Expand Down
10 changes: 9 additions & 1 deletion Jellyfin.Plugin.Themerr.Tests/TestThemerrManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Serialization;
using Microsoft.Extensions.Logging;
using Moq;
using Newtonsoft.Json;
Expand All @@ -26,10 +28,16 @@ public TestThemerrManager(ITestOutputHelper output)
{
TestLogger.Initialize(output);

Mock<IApplicationPaths> mockApplicationPaths = TestHelper.GetMockApplicationPaths();
Mock<ILibraryManager> mockLibraryManager = new();
Mock<ILogger<ThemerrManager>> mockLogger = new();
Mock<IXmlSerializer> mockXmlSerializer = new();

_themerrManager = new ThemerrManager(mockLibraryManager.Object, mockLogger.Object);
_themerrManager = new ThemerrManager(
mockApplicationPaths.Object,
mockLibraryManager.Object,
mockLogger.Object,
mockXmlSerializer.Object);
}

/// <summary>
Expand Down
17 changes: 14 additions & 3 deletions Jellyfin.Plugin.Themerr/Api/ThemerrController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
using System.Net.Mime;
using System.Reflection;
using System.Threading.Tasks;
using MediaBrowser.Common.Api;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Serialization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
Expand All @@ -20,7 +23,7 @@ namespace Jellyfin.Plugin.Themerr.Api
/// The Themerr api controller.
/// </summary>
[ApiController]
[Authorize(Policy = "DefaultAuthorization")]
[Authorize(Policy = Policies.RequiresElevation)]
[Route("Themerr")]
[Produces(MediaTypeNames.Application.Json)]

Expand All @@ -33,17 +36,25 @@ public class ThemerrController : ControllerBase
/// <summary>
/// Initializes a new instance of the <see cref="ThemerrController"/> class.
/// </summary>
/// <param name="applicationPaths">The application paths.</param>
/// <param name="libraryManager">The library manager.</param>
/// <param name="logger">The logger.</param>
/// <param name="configurationManager">The configuration manager.</param>
/// <param name="loggerFactory">The logger factory.</param>
/// <param name="xmlSerializer">The XML serializer.</param>
public ThemerrController(
IApplicationPaths applicationPaths,
ILibraryManager libraryManager,
ILogger<ThemerrController> logger,
IServerConfigurationManager configurationManager,
ILoggerFactory loggerFactory)
ILoggerFactory loggerFactory,
IXmlSerializer xmlSerializer)
{
_themerrManager = new ThemerrManager(libraryManager, loggerFactory.CreateLogger<ThemerrManager>());
_themerrManager = new ThemerrManager(
applicationPaths,
libraryManager,
loggerFactory.CreateLogger<ThemerrManager>(),
xmlSerializer);
_logger = logger;
_configurationManager = configurationManager;
}
Expand Down
4 changes: 2 additions & 2 deletions Jellyfin.Plugin.Themerr/Jellyfin.Plugin.Themerr.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>true</IsPackable>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
<FileVersion>0.0.0.0</FileVersion>
Expand All @@ -11,7 +11,7 @@

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Jellyfin.Controller" Version="10.8.13" />
<PackageReference Include="Jellyfin.Controller" Version="10.9.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="YoutubeExplode" Version="6.3.14" />
</ItemGroup>
Expand Down
14 changes: 12 additions & 2 deletions Jellyfin.Plugin.Themerr/ScheduledTasks/ThemerrTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Tasks;
using Microsoft.Extensions.Logging;

Expand All @@ -19,16 +21,24 @@ public class ThemerrTasks : IScheduledTask
/// <summary>
/// Initializes a new instance of the <see cref="ThemerrTasks"/> class.
/// </summary>
/// <param name="applicationPaths">The application paths.</param>
/// <param name="libraryManager">The library manager.</param>
/// <param name="logger">The logger.</param>
/// <param name="loggerFactory">The logger factory.</param>
/// <param name="xmlSerializer">The XML serializer.</param>
public ThemerrTasks(
IApplicationPaths applicationPaths,
ILibraryManager libraryManager,
ILogger<ThemerrTasks> logger,
ILoggerFactory loggerFactory)
ILoggerFactory loggerFactory,
IXmlSerializer xmlSerializer)
{
_logger = logger;
_themerrManager = new ThemerrManager(libraryManager, loggerFactory.CreateLogger<ThemerrManager>());
_themerrManager = new ThemerrManager(
applicationPaths,
libraryManager,
loggerFactory.CreateLogger<ThemerrManager>(),
xmlSerializer);
}

/// <summary>
Expand Down
21 changes: 18 additions & 3 deletions Jellyfin.Plugin.Themerr/ThemerrManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Data.Enums;
using Jellyfin.Plugin.Themerr.Configuration;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Serialization;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using YoutubeExplode;
Expand All @@ -21,7 +24,7 @@ namespace Jellyfin.Plugin.Themerr
/// <summary>
/// The main entry point for the plugin.
/// </summary>
public class ThemerrManager : IServerEntryPoint
public class ThemerrManager : BasePlugin<PluginConfiguration>
{
private readonly ILibraryManager _libraryManager;
private readonly Timer _timer;
Expand All @@ -30,15 +33,27 @@ public class ThemerrManager : IServerEntryPoint
/// <summary>
/// Initializes a new instance of the <see cref="ThemerrManager"/> class.
/// </summary>
/// <param name="applicationPaths">The application paths.</param>
/// <param name="libraryManager">The library manager.</param>
/// <param name="logger">The logger.</param>
public ThemerrManager(ILibraryManager libraryManager, ILogger<ThemerrManager> logger)
/// <param name="xmlSerializer">The XML serializer.</param>
public ThemerrManager(
IApplicationPaths applicationPaths,
ILibraryManager libraryManager,
ILogger<ThemerrManager> logger,
IXmlSerializer xmlSerializer)
: base(applicationPaths, xmlSerializer)
{
_libraryManager = libraryManager;
_logger = logger;
_timer = new Timer(_ => OnTimerElapsed(), null, Timeout.Infinite, Timeout.Infinite);
}

/// <summary>
/// Gets the plugin instance.
/// </summary>
public override string Name => "Themerr";

/// <summary>
/// Get a value from the themerr data file if it exists.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
name: "Themerr"
image: "themerr-jellyfin.png"
guid: "e41ef0c4-c413-41ba-b4fa-8c565dc3c969"
targetAbi: "10.8.13.0"
framework: "net6.0"
targetAbi: "10.9.0.0"
framework: "net8.0"
overview: "Automatically add theme songs to movies using ThemerrDB"
description: >-
Automatically add theme songs to movies using ThemerrDB
Expand Down

0 comments on commit 027139f

Please sign in to comment.