Use the common interface IComicFileProvider

This commit is contained in:
Patrick Farwick 2021-10-31 23:39:52 +00:00
parent 77f0515f07
commit 67bd6f705b
3 changed files with 9 additions and 11 deletions

View File

@ -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>

View File

@ -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>();
}
}
}

View File

@ -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;
}
}
}
}