diff --git a/.github/workflows/beta.yaml b/.github/workflows/beta.yaml index 1bb4623..14f03bc 100644 --- a/.github/workflows/beta.yaml +++ b/.github/workflows/beta.yaml @@ -4,7 +4,7 @@ on: workflow_dispatch: env: - dotnet-version: 6.0.x + dotnet-version: 8.0.x python-version: 3.8 project: Jellyfin.Plugin.Danmu/Jellyfin.Plugin.Danmu.csproj artifact: danmu @@ -36,9 +36,9 @@ jobs: - name: Build run: | dotnet restore ${{ env.project }} --no-cache - dotnet publish --nologo --no-restore --configuration=Release --framework=net6.0 ${{ env.project }} + dotnet publish --nologo --no-restore --configuration=Release --framework=net8.0 ${{ env.project }} mkdir -p artifacts - cp ./Jellyfin.Plugin.Danmu/bin/Release/net6.0/Jellyfin.Plugin.Danmu.dll ./artifacts/ + cp ./Jellyfin.Plugin.Danmu/bin/Release/net8.0/Jellyfin.Plugin.Danmu.dll ./artifacts/ - name: Upload artifact uses: actions/upload-artifact@v3 with: diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 889a178..293fba8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -14,7 +14,7 @@ jobs: - uses: actions/setup-dotnet@v3 id: dotnet with: - dotnet-version: 6.0.x + dotnet-version: 8.0.x - name: Change default dotnet version run: | echo '{"sdk":{"version": "${{ steps.dotnet.outputs.dotnet-version }}"}}' > ./global.json diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 8c7324b..d25ac72 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -5,7 +5,7 @@ on: tags: ["*"] env: - dotnet-version: 6.0.x + dotnet-version: 8.0.x python-version: 3.8 project: Jellyfin.Plugin.Danmu/Jellyfin.Plugin.Danmu.csproj artifact: danmu @@ -41,9 +41,9 @@ jobs: - name: Build run: | dotnet restore ${{ env.project }} --no-cache - dotnet publish --nologo --no-restore --configuration=Release --framework=net6.0 -p:Version=${{steps.vars.outputs.VERSION}} ${{ env.project }} + dotnet publish --nologo --no-restore --configuration=Release --framework=net8.0 -p:Version=${{steps.vars.outputs.VERSION}} ${{ env.project }} mkdir -p artifacts - zip -j ./artifacts/${{ env.artifact }}_${{steps.vars.outputs.VERSION}}.zip ./Jellyfin.Plugin.Danmu/bin/Release/net6.0/Jellyfin.Plugin.Danmu.dll + zip -j ./artifacts/${{ env.artifact }}_${{steps.vars.outputs.VERSION}}.zip ./Jellyfin.Plugin.Danmu/bin/Release/net8.0/Jellyfin.Plugin.Danmu.dll - name: Generate manifest run: python3 ./scripts/generate_manifest.py ./artifacts/${{ env.artifact }}_${{steps.vars.outputs.VERSION}}.zip ${GITHUB_REF#refs/*/} env: diff --git a/Jellyfin.Plugin.Danmu.Test/Jellyfin.Plugin.Danmu.Test.csproj b/Jellyfin.Plugin.Danmu.Test/Jellyfin.Plugin.Danmu.Test.csproj index 8b12e69..bca4701 100644 --- a/Jellyfin.Plugin.Danmu.Test/Jellyfin.Plugin.Danmu.Test.csproj +++ b/Jellyfin.Plugin.Danmu.Test/Jellyfin.Plugin.Danmu.Test.csproj @@ -1,6 +1,6 @@ - net6.0 + net8.0 enable enable false diff --git a/Jellyfin.Plugin.Danmu/Jellyfin.Plugin.Danmu.csproj b/Jellyfin.Plugin.Danmu/Jellyfin.Plugin.Danmu.csproj index 7305dbe..527eacb 100644 --- a/Jellyfin.Plugin.Danmu/Jellyfin.Plugin.Danmu.csproj +++ b/Jellyfin.Plugin.Danmu/Jellyfin.Plugin.Danmu.csproj @@ -1,6 +1,6 @@ - net6.0 + net8.0 Jellyfin.Plugin.Danmu False true @@ -17,9 +17,12 @@ - - - + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + diff --git a/Jellyfin.Plugin.Danmu/LibraryManagerEventsHelper.cs b/Jellyfin.Plugin.Danmu/LibraryManagerEventsHelper.cs index 1854412..f1c2e43 100644 --- a/Jellyfin.Plugin.Danmu/LibraryManagerEventsHelper.cs +++ b/Jellyfin.Plugin.Danmu/LibraryManagerEventsHelper.cs @@ -1,28 +1,18 @@ -using System.Runtime.InteropServices; -using System.Net.Http; using System; -using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Text.Json; -using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using Jellyfin.Plugin.Danmu.Core; using Jellyfin.Plugin.Danmu.Model; -using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; -using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; -using MediaBrowser.Controller.Persistence; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Caching.Memory; using Jellyfin.Plugin.Danmu.Scrapers; diff --git a/Jellyfin.Plugin.Danmu/Plugin.cs b/Jellyfin.Plugin.Danmu/Plugin.cs index 681bed4..85c3545 100644 --- a/Jellyfin.Plugin.Danmu/Plugin.cs +++ b/Jellyfin.Plugin.Danmu/Plugin.cs @@ -23,11 +23,12 @@ public class Plugin : BasePlugin, IHasWebPages /// /// Instance of the interface. /// Instance of the interface. - public Plugin(IApplicationPaths applicationPaths, IApplicationHost applicationHost, IXmlSerializer xmlSerializer) + public Plugin(IApplicationPaths applicationPaths, IApplicationHost applicationHost, IXmlSerializer xmlSerializer, ScraperManager scraperManager) : base(applicationPaths, xmlSerializer) { Instance = this; Scrapers = applicationHost.GetExports(false).Where(o => o != null).OrderBy(x => x.DefaultOrder).ToList().AsReadOnly(); + scraperManager.Register(Scrapers); } /// diff --git a/Jellyfin.Plugin.Danmu/PluginStartup.cs b/Jellyfin.Plugin.Danmu/PluginStartup.cs index b963cfb..c591f1c 100644 --- a/Jellyfin.Plugin.Danmu/PluginStartup.cs +++ b/Jellyfin.Plugin.Danmu/PluginStartup.cs @@ -1,26 +1,20 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Net.Http; -using System.Text; using System.Threading.Tasks; using MediaBrowser.Controller.Library; using MediaBrowser.Controller; -using MediaBrowser.Controller.Plugins; -using MediaBrowser.Controller.Session; using Microsoft.Extensions.Logging; -using MediaBrowser.Common.Net; using Jellyfin.Plugin.Danmu.Model; using MediaBrowser.Model.Entities; using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Model.IO; -using MediaBrowser.Controller.Providers; -using Jellyfin.Plugin.Danmu.Core.Extensions; +using Microsoft.Extensions.Hosting; +using System.Threading; namespace Jellyfin.Plugin.Danmu { - public class PluginStartup : IServerEntryPoint, IDisposable + public class PluginStartup : IHostedService, IDisposable { private readonly ILibraryManager _libraryManager; private readonly LibraryManagerEventsHelper _libraryManagerEventsHelper; @@ -47,7 +41,7 @@ namespace Jellyfin.Plugin.Danmu _libraryManagerEventsHelper = libraryManagerEventsHelper; } - public Task RunAsync() + public Task StartAsync(CancellationToken cancellationToken) { _libraryManager.ItemAdded += LibraryManagerItemAdded; _libraryManager.ItemUpdated += LibraryManagerItemUpdated; @@ -127,5 +121,9 @@ namespace Jellyfin.Plugin.Danmu } } + public Task StopAsync(CancellationToken cancellationToken) + { + return Task.CompletedTask; + } } } diff --git a/Jellyfin.Plugin.Danmu/Scrapers/ScraperManager.cs b/Jellyfin.Plugin.Danmu/Scrapers/ScraperManager.cs index 3f8897a..c234302 100644 --- a/Jellyfin.Plugin.Danmu/Scrapers/ScraperManager.cs +++ b/Jellyfin.Plugin.Danmu/Scrapers/ScraperManager.cs @@ -1,8 +1,6 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; -using Jellyfin.Plugin.Danmu.Core.Extensions; -using MediaBrowser.Common; using Microsoft.Extensions.Logging; namespace Jellyfin.Plugin.Danmu.Scrapers; @@ -15,17 +13,18 @@ public class ScraperManager public ScraperManager(ILoggerFactory logManager) { log = logManager.CreateLogger(); - if (Plugin.Instance?.Scrapers != null) - { - this._scrapers.AddRange(Plugin.Instance.Scrapers); - } } - public void register(AbstractScraper scraper) + public void Register(AbstractScraper scraper) { this._scrapers.Add(scraper); } + public void Register(IList scrapers) + { + this._scrapers.AddRange(scrapers); + } + public ReadOnlyCollection All() { // 存在配置时,根据配置调整源顺序,并删除不启用的源 diff --git a/Jellyfin.Plugin.Danmu/ServiceRegistrator.cs b/Jellyfin.Plugin.Danmu/ServiceRegistrator.cs index 6a9de51..3e2108c 100644 --- a/Jellyfin.Plugin.Danmu/ServiceRegistrator.cs +++ b/Jellyfin.Plugin.Danmu/ServiceRegistrator.cs @@ -1,19 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using MediaBrowser.Controller.Providers; -using MediaBrowser.Common.Plugins; using MediaBrowser.Controller.Library; -using MediaBrowser.Model.IO; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using MediaBrowser.Controller.Persistence; using Jellyfin.Plugin.Danmu.Scrapers; -using Jellyfin.Plugin.Danmu.Scrapers.Bilibili; -using Jellyfin.Plugin.Danmu.Scrapers.Dandan; -using MediaBrowser.Common; +using MediaBrowser.Controller.Plugins; +using MediaBrowser.Controller; +using MediaBrowser.Controller.Subtitles; namespace Jellyfin.Plugin.Danmu { @@ -21,21 +12,21 @@ namespace Jellyfin.Plugin.Danmu public class ServiceRegistrator : IPluginServiceRegistrator { /// - public void RegisterServices(IServiceCollection serviceCollection) + public void RegisterServices(IServiceCollection serviceCollection, IServerApplicationHost applicationHost) { + serviceCollection.AddSingleton(); serviceCollection.AddSingleton((ctx) => { return new Jellyfin.Plugin.Danmu.Core.FileSystem(); }); - serviceCollection.AddSingleton((ctx) => + serviceCollection.AddSingleton((ctx) => { return new ScraperManager(ctx.GetRequiredService()); }); - serviceCollection.AddSingleton((ctx) => + serviceCollection.AddSingleton((ctx) => { return new LibraryManagerEventsHelper(ctx.GetRequiredService(), ctx.GetRequiredService(), ctx.GetRequiredService(), ctx.GetRequiredService()); }); - } } } diff --git a/README.md b/README.md index 3ac91f2..13f3949 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # jellyfin-plugin-danmu [![releases](https://img.shields.io/github/v/release/cxfksword/jellyfin-plugin-danmu)](https://github.com/cxfksword/jellyfin-plugin-danmu/releases) -[![jellyfin](https://img.shields.io/badge/jellyfin-10.8.x-lightgrey?logo=jellyfin)](https://github.com/cxfksword/jellyfin-plugin-danmu/releases) +[![jellyfin](https://img.shields.io/badge/jellyfin-10.8.x|10.9.x-lightgrey?logo=jellyfin)](https://github.com/cxfksword/jellyfin-plugin-danmu/releases) [![LICENSE](https://img.shields.io/github/license/cxfksword/jellyfin-plugin-danmu)](https://github.com/cxfksword/jellyfin-plugin-danmu/main/LICENSE) jellyfin弹幕自动下载插件,已支持的弹幕来源:b站,弹弹play,优酷,爱奇艺,腾讯视频,芒果TV。 @@ -17,8 +17,6 @@ jellyfin弹幕自动下载插件,已支持的弹幕来源:b站,弹弹play ## 安装插件 -只支持最新的`jellyfin 10.8.x`版本 - 添加插件存储库: 国内加速:https://mirror.ghproxy.com/https://github.com/cxfksword/jellyfin-plugin-danmu/releases/download/manifest/manifest_cn.json @@ -70,7 +68,7 @@ ass格式: 1. Clone or download this repository -2. Ensure you have .NET Core SDK 6.0 setup and installed +2. Ensure you have .NET Core SDK 8.0 setup and installed 3. Build plugin with following command. @@ -84,7 +82,7 @@ dotnet publish --configuration=Release Jellyfin.Plugin.Danmu/Jellyfin.Plugin.Dan 1. Build the plugin -2. Create a folder, like `danmu` and copy `./Jellyfin.Plugin.Danmu/bin/Release/net6.0/Jellyfin.Plugin.Danmu.dll` into it +2. Create a folder, like `danmu` and copy `./Jellyfin.Plugin.Danmu/bin/Release/net8.0/Jellyfin.Plugin.Danmu.dll` into it 3. Move folder `danmu` to jellyfin `data/plugins` folder diff --git a/scripts/generate_manifest.py b/scripts/generate_manifest.py index c59fdba..9dce491 100755 --- a/scripts/generate_manifest.py +++ b/scripts/generate_manifest.py @@ -26,7 +26,7 @@ def generate_version(filepath, version, changelog): return { 'version': f"{version}.0", 'changelog': changelog, - 'targetAbi': '10.8.0.0', + 'targetAbi': '10.9.0.0', 'sourceUrl': f'https://github.com/cxfksword/jellyfin-plugin-danmu/releases/download/v{version}/danmu_{version}.0.zip', 'checksum': md5sum(filepath), 'timestamp': datetime.now().strftime('%Y-%m-%dT%H:%M:%S')