Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
kookxiang committed May 12, 2024
2 parents e712f99 + ba8377f commit dd1a096
Show file tree
Hide file tree
Showing 13 changed files with 137 additions and 92 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/jellyfin-unstable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: 'Jellyfin (unstable) Plugin'

on:
push:
branches:
- next

permissions:
contents: read
packages: read

jobs:
build:
name: Build Plugin
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 8
- name: Restore NuGet Packages
run: |
dotnet nuget add source --username ${{ github.repository_owner }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name jellyfin-unstable "https://nuget.pkg.github.com/jellyfin/index.json"
dotnet restore
- name: .NET Test
run: dotnet test --configuration Release Jellyfin.Plugin.Bangumi.Test
- name: .NET Publish
run: dotnet publish --configuration Release --output publish Jellyfin.Plugin.Bangumi
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: Jellyfin.Plugin.Bangumi
path: publish/*.dll
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Jellyfin.Controller" Version="10.8.12"/>
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="6.0.12"/>
<PackageReference Include="Jellyfin.Controller" Version="10.9.0-*"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0"/>
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2"/>
<PackageReference Include="MSTest.TestAdapter" Version="3.3.1"/>
<PackageReference Include="MSTest.TestFramework" Version="3.0.2"/>
<ProjectReference Include="..\Jellyfin.Plugin.Bangumi\Jellyfin.Plugin.Bangumi.csproj"/>
</ItemGroup>
Expand Down
53 changes: 34 additions & 19 deletions Jellyfin.Plugin.Bangumi.Test/Mock/MockedLibraryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public BaseItem ResolvePath(FileSystemMetadata fileInfo, Folder parent = null, I
throw new NotImplementedException();
}

public IEnumerable<BaseItem> ResolvePaths(IEnumerable<FileSystemMetadata> files, IDirectoryService directoryService, Folder parent, LibraryOptions libraryOptions, string collectionType = null)
public IEnumerable<BaseItem> ResolvePaths(IEnumerable<FileSystemMetadata> files, IDirectoryService directoryService, Folder parent, LibraryOptions libraryOptions, CollectionType? collectionType = null)
{
throw new NotImplementedException();
}
Expand Down Expand Up @@ -103,6 +103,21 @@ public BaseItem GetItemById(Guid id)
throw new NotImplementedException();
}

public T GetItemById<T>(Guid id) where T : BaseItem
{
throw new NotImplementedException();
}

public T GetItemById<T>(Guid id, Guid userId) where T : BaseItem
{
throw new NotImplementedException();
}

public T GetItemById<T>(Guid id, User user) where T : BaseItem
{
throw new NotImplementedException();
}

public Task<IEnumerable<Video>> GetIntros(BaseItem item, User user)
{
throw new NotImplementedException();
Expand All @@ -113,12 +128,12 @@ public void AddParts(IEnumerable<IResolverIgnoreRule> rules, IEnumerable<IItemRe
throw new NotImplementedException();
}

public IEnumerable<BaseItem> Sort(IEnumerable<BaseItem> items, User user, IEnumerable<string> sortBy, SortOrder sortOrder)
public IEnumerable<BaseItem> Sort(IEnumerable<BaseItem> items, User user, IEnumerable<ItemSortBy> sortBy, SortOrder sortOrder)
{
throw new NotImplementedException();
}

public IEnumerable<BaseItem> Sort(IEnumerable<BaseItem> items, User user, IEnumerable<(string OrderBy, SortOrder SortOrder)> orderBy)
public IEnumerable<BaseItem> Sort(IEnumerable<BaseItem> items, User user, IEnumerable<(ItemSortBy OrderBy, SortOrder SortOrder)> orderBy)
{
throw new NotImplementedException();
}
Expand Down Expand Up @@ -153,22 +168,22 @@ public BaseItem RetrieveItem(Guid id)
throw new NotImplementedException();
}

public string GetContentType(BaseItem item)
public CollectionType? GetContentType(BaseItem item)
{
throw new NotImplementedException();
}

public string GetInheritedContentType(BaseItem item)
public CollectionType? GetInheritedContentType(BaseItem item)
{
throw new NotImplementedException();
}

public string GetConfiguredContentType(BaseItem item)
public CollectionType? GetConfiguredContentType(BaseItem item)
{
throw new NotImplementedException();
}

public string GetConfiguredContentType(string path)
public CollectionType? GetConfiguredContentType(string path)
{
throw new NotImplementedException();
}
Expand Down Expand Up @@ -198,27 +213,27 @@ public void DeleteItem(BaseItem item, DeleteOptions options, BaseItem parent, bo
throw new NotImplementedException();
}

public UserView GetNamedView(User user, string name, Guid parentId, string viewType, string sortName)
public UserView GetNamedView(User user, string name, Guid parentId, CollectionType? viewType, string sortName)
{
throw new NotImplementedException();
}

public UserView GetNamedView(User user, string name, string viewType, string sortName)
public UserView GetNamedView(User user, string name, CollectionType? viewType, string sortName)
{
throw new NotImplementedException();
}

public UserView GetNamedView(string name, string viewType, string sortName)
public UserView GetNamedView(string name, CollectionType viewType, string sortName)
{
throw new NotImplementedException();
}

public UserView GetNamedView(string name, Guid parentId, string viewType, string sortName, string uniqueId)
public UserView GetNamedView(string name, Guid parentId, CollectionType? viewType, string sortName, string uniqueId)
{
throw new NotImplementedException();
}

public UserView GetShadowView(BaseItem parent, string viewType, string sortName)
public UserView GetShadowView(BaseItem parent, CollectionType? viewType, string sortName)
{
throw new NotImplementedException();
}
Expand Down Expand Up @@ -253,7 +268,7 @@ public List<Folder> GetCollectionFolders(BaseItem item)
throw new NotImplementedException();
}

public List<Folder> GetCollectionFolders(BaseItem item, List<Folder> allUserRootChildren)
public List<Folder> GetCollectionFolders(BaseItem item, IEnumerable<Folder> allUserRootChildren)
{
throw new NotImplementedException();
}
Expand Down Expand Up @@ -308,7 +323,7 @@ public string GetPathAfterNetworkSubstitution(string path, BaseItem ownerItem =
throw new NotImplementedException();
}

public Task<ItemImageInfo> ConvertImageToLocal(BaseItem item, ItemImageInfo image, int imageIndex)
public Task<ItemImageInfo> ConvertImageToLocal(BaseItem item, ItemImageInfo image, int imageIndex, bool removeOnFailure = true)
{
throw new NotImplementedException();
}
Expand Down Expand Up @@ -423,14 +438,14 @@ public BaseItem GetParentItem(Guid? parentId, Guid? userId)
throw new NotImplementedException();
}

public void QueueLibraryScan()
{
throw new NotImplementedException();
}

public AggregateFolder RootFolder { get; }
public bool IsScanRunning { get; }
public event EventHandler<ItemChangeEventArgs> ItemAdded;
public event EventHandler<ItemChangeEventArgs> ItemUpdated;
public event EventHandler<ItemChangeEventArgs> ItemRemoved;

public void QueueLibraryScan()
{
throw new NotImplementedException();
}
}
8 changes: 4 additions & 4 deletions Jellyfin.Plugin.Bangumi.Test/Movie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Data.Enums;
using Jellyfin.Plugin.Bangumi.Providers;
using Jellyfin.Plugin.Bangumi.Test.Util;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Jellyfin.Plugin.Bangumi.Test;
Expand Down Expand Up @@ -86,9 +86,9 @@ private static void AssertMovie(MetadataResult<MediaBrowser.Controller.Entities.
Assert.AreNotEqual("", result.Item.Overview, "should return series overview");
Assert.AreEqual(DateTime.Parse("2013-04-20"), result.Item.PremiereDate, "should return correct premiere date");
Assert.IsTrue(result.Item.CommunityRating is > 0 and <= 10, "should return rating info");
Assert.IsNotNull(result.People.Find(x => x.IsType(PersonType.Actor)), "should have at least one actor");
Assert.IsNotNull(result.People.Find(x => x.IsType(PersonType.Director)), "should have at least one director");
Assert.IsNotNull(result.People.Find(x => x.IsType(PersonType.Writer)), "should have at least one writer");
Assert.IsNotNull(result.People.Find(x => x.IsType(PersonKind.Actor)), "should have at least one actor");
Assert.IsNotNull(result.People.Find(x => x.IsType(PersonKind.Director)), "should have at least one director");
Assert.IsNotNull(result.People.Find(x => x.IsType(PersonKind.Writer)), "should have at least one writer");
Assert.AreNotEqual("", result.People?[0].ImageUrl, "person should have image url");
Assert.AreEqual("23119", result.Item.ProviderIds[Constants.ProviderName], "should have plugin provider id");
}
Expand Down
7 changes: 4 additions & 3 deletions Jellyfin.Plugin.Bangumi.Test/Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Data.Enums;
using Jellyfin.Plugin.Bangumi.Providers;
using Jellyfin.Plugin.Bangumi.Test.Util;
using MediaBrowser.Controller.Providers;
Expand Down Expand Up @@ -191,9 +192,9 @@ private static void AssertSeries(MetadataResult<MediaBrowser.Controller.Entities
Assert.AreEqual("2013-10-05", result.Item.AirTime, "should return correct air time info");
Assert.AreEqual(DayOfWeek.Saturday, result.Item.AirDays?[0], "should return correct air day info");
Assert.IsTrue(result.Item.CommunityRating is > 0 and <= 10, "should return rating info");
Assert.IsNotNull(result.People.Find(x => x.IsType(PersonType.Actor)), "should have at least one actor");
Assert.IsNotNull(result.People.Find(x => x.IsType(PersonType.Director)), "should have at least one director");
Assert.IsNotNull(result.People.Find(x => x.IsType(PersonType.Writer)), "should have at least one writer");
Assert.IsNotNull(result.People.Find(x => x.IsType(PersonKind.Actor)), "should have at least one actor");
Assert.IsNotNull(result.People.Find(x => x.IsType(PersonKind.Director)), "should have at least one director");
Assert.IsNotNull(result.People.Find(x => x.IsType(PersonKind.Writer)), "should have at least one writer");
Assert.AreNotEqual("", result.People?.Find(x => x.Name.Equals("丸戸史明")).ImageUrl, "person should have image url");
Assert.IsNotNull(result.Item.ProviderIds[Constants.ProviderName], "should have plugin provider id");
}
Expand Down
2 changes: 1 addition & 1 deletion Jellyfin.Plugin.Bangumi.Test/Util/ServiceLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void Init(TestContext context)
serviceCollection.AddScoped<SeasonProvider>();
serviceCollection.AddScoped<SeriesProvider>();
serviceCollection.AddScoped<SubjectImageProvider>();
new PluginServiceRegistrator().RegisterServices(serviceCollection);
new PluginServiceRegistrator().RegisterServices(serviceCollection, null!);
_provider = serviceCollection.BuildServiceProvider();

var plugin = GetService<Bangumi.Plugin>();
Expand Down
17 changes: 3 additions & 14 deletions Jellyfin.Plugin.Bangumi/Jellyfin.Plugin.Bangumi.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Jellyfin.Plugin.Bangumi</RootNamespace>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AnitomySharp" Version="0.2.0"/>
<PackageReference Include="Fastenshtein" Version="1.0.0.8"/>
<PackageReference Include="Jellyfin.Controller" IncludeAssets="compile" Version="10.8.12"/>
<PackageReference Include="Microsoft.AspNetCore.Authorization" IncludeAssets="compile" Version="6.0.12"/>
<PackageReference Include="Jellyfin.Controller" IncludeAssets="compile" Version="10.9.0-*"/>
<PackageReference Include="Newtonsoft.Json" IncludeAssets="compile" Version="13.0.3"/>
</ItemGroup>

<ItemGroup>
Expand All @@ -24,14 +23,4 @@
<ItemGroup>
<InternalsVisibleTo Include="Jellyfin.Plugin.Bangumi.Test"/>
</ItemGroup>

<Target Name="Release" AfterTargets="Build" Condition="'$(Configuration)'=='Release'">
<ItemGroup>
<AssemblyDependencies Include="$(OutputPath)*.dll"/>
</ItemGroup>
<MakeDir Directories="$(OutputPath)zip"/>
<Copy SourceFiles="@(AssemblyDependencies)" DestinationFolder="$(OutputPath)\zip"/>
<ZipDirectory SourceDirectory="$(OutputPath)zip" DestinationFile="$(MSBuildProjectDirectory)\..\$(AssemblyName).zip" Overwrite="true"/>
<RemoveDir Directories="$(OutputPath)zip"/>
</Target>
</Project>
10 changes: 9 additions & 1 deletion Jellyfin.Plugin.Bangumi/Model/RelatedCharacter.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#if EMBY
using PersonEntityType = MediaBrowser.Model.Entities.PersonType;
#else
using Jellyfin.Data.Enums;
#endif
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
using MediaBrowser.Controller.Entities;
using PersonEntityType = MediaBrowser.Model.Entities.PersonType;

namespace Jellyfin.Plugin.Bangumi.Model;

Expand Down Expand Up @@ -34,7 +38,11 @@ public IEnumerable<PersonInfo> ToPersonInfos()
Name = actor.Name,
Role = Name,
ImageUrl = actor.DefaultImage,
#if EMBY
Type = PersonEntityType.Actor
#else
Type = PersonKind.Actor
#endif
};
info.ProviderIds.Add(Constants.ProviderName, $"{actor.Id}");
return info;
Expand Down
17 changes: 14 additions & 3 deletions Jellyfin.Plugin.Bangumi/Model/RelatedPerson.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@

using System.Collections.Generic;
using System.Text.Json.Serialization;
using MediaBrowser.Controller.Entities;
#if EMBY
using PersonEntityType = MediaBrowser.Model.Entities.PersonType;
#else
using Jellyfin.Data.Enums;
#endif

namespace Jellyfin.Plugin.Bangumi.Model;

public class RelatedPerson
{
#if EMBY
private static readonly Dictionary<string, PersonEntityType> RelationMap = new()
#else
private static readonly Dictionary<string, string> RelationMap = new()
#endif
{
["导演"] = PersonEntityType.Director,
["制片人"] = PersonEntityType.Producer,
["系列构成"] = PersonEntityType.Composer,
["脚本"] = PersonEntityType.Writer
};
#else
private static readonly Dictionary<string, PersonKind> RelationMap = new()
{
["导演"] = PersonKind.Director,
["制片人"] = PersonKind.Producer,
["系列构成"] = PersonKind.Composer,
["脚本"] = PersonKind.Writer
};
#endif

public int Id { get; set; }

Expand Down

0 comments on commit dd1a096

Please sign in to comment.