mirror of
https://github.com/jellyfin/jellyfin-plugin-bookshelf.git
synced 2024-11-23 05:39:51 +00:00
Use the common interface IComicFileProvider
This commit is contained in:
parent
77f0515f07
commit
67bd6f705b
@ -10,7 +10,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Jellyfin.Controller" Version="10.*-*" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
|
||||
<PackageReference Include="sharpcompress" Version="0.28.3" />
|
||||
<PackageReference Include="sharpcompress" Version="0.30.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using MediaBrowser.Common.Plugins;
|
||||
using Jellyfin.Plugin.Bookshelf.Providers.ComicBook;
|
||||
using Jellyfin.Plugin.Bookshelf.Providers.ComicBookInfo;
|
||||
using Jellyfin.Plugin.Bookshelf.Providers;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
@ -18,6 +19,7 @@ namespace Jellyfin.Plugin.Bookshelf
|
||||
// register the actual implementations of the local metadata provider for comic files
|
||||
serviceCollection.AddSingleton<IComicFileProvider, ExternalComicInfoProvider>();
|
||||
serviceCollection.AddSingleton<IComicFileProvider, InternalComicInfoProvider>();
|
||||
serviceCollection.AddSingleton<IComicFileProvider, ComicBookInfoProvider>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,21 +15,19 @@ using Microsoft.Extensions.Logging;
|
||||
#nullable enable
|
||||
namespace Jellyfin.Plugin.Bookshelf.Providers.ComicBookInfo
|
||||
{
|
||||
public class ComicBookInfoProvider : ILocalMetadataProvider<Book>, IHasItemChangeMonitor
|
||||
public class ComicBookInfoProvider : IComicFileProvider
|
||||
{
|
||||
private readonly ILogger<ComicBookInfoProvider> _logger;
|
||||
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
public string Name => "ComicBookInfo";
|
||||
|
||||
protected ComicBookInfoProvider(IFileSystem fileSystem, ILogger<ComicBookInfoProvider> logger)
|
||||
public ComicBookInfoProvider(IFileSystem fileSystem, ILogger<ComicBookInfoProvider> logger)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<MetadataResult<Book>> GetMetadata(ItemInfo info, IDirectoryService directoryService, CancellationToken cancellationToken)
|
||||
public async Task<MetadataResult<Book>> ReadMetadata(ItemInfo info, IDirectoryService directoryService, CancellationToken cancellationToken)
|
||||
{
|
||||
var path = GetComicBookFile(info.Path)?.FullName;
|
||||
|
||||
@ -62,7 +60,7 @@ namespace Jellyfin.Plugin.Bookshelf.Providers.ComicBookInfo
|
||||
return new MetadataResult<Book> { HasMetadata = false };
|
||||
}
|
||||
|
||||
return ReadMetadata(comicBookMetadata);
|
||||
return SaveMetadata(comicBookMetadata);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -80,7 +78,7 @@ namespace Jellyfin.Plugin.Bookshelf.Providers.ComicBookInfo
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasChanged(BaseItem item, IDirectoryService directoryService)
|
||||
public bool HasItemChanged(BaseItem item, IDirectoryService directoryService)
|
||||
{
|
||||
var file = GetComicBookFile(item.Path);
|
||||
|
||||
@ -92,7 +90,7 @@ namespace Jellyfin.Plugin.Bookshelf.Providers.ComicBookInfo
|
||||
return file.Exists && _fileSystem.GetLastWriteTimeUtc(file) > item.DateLastSaved;
|
||||
}
|
||||
|
||||
private MetadataResult<Book> ReadMetadata(ComicBookInfoFormat comic)
|
||||
private MetadataResult<Book> SaveMetadata(ComicBookInfoFormat comic)
|
||||
{
|
||||
var book = new Book
|
||||
{
|
||||
@ -165,8 +163,6 @@ namespace Jellyfin.Plugin.Bookshelf.Providers.ComicBookInfo
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user