jellyfin-server/MediaBrowser.Providers/Chapters/ChapterManager.cs

68 lines
2.2 KiB
C#
Raw Normal View History

2014-06-29 17:35:05 +00:00
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
2014-06-09 19:16:14 +00:00
using MediaBrowser.Controller.Chapters;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
2014-06-10 17:36:06 +00:00
using MediaBrowser.Controller.Persistence;
2014-06-09 19:16:14 +00:00
using MediaBrowser.Controller.Providers;
2014-06-29 17:35:05 +00:00
using MediaBrowser.Model.Configuration;
2014-06-10 17:36:06 +00:00
using MediaBrowser.Model.Entities;
2014-06-09 19:16:14 +00:00
using MediaBrowser.Model.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Providers.Chapters
{
public class ChapterManager : IChapterManager
{
private readonly ILibraryManager _libraryManager;
private readonly ILogger _logger;
private readonly IServerConfigurationManager _config;
2014-06-10 17:36:06 +00:00
private readonly IItemRepository _itemRepo;
2014-06-09 19:16:14 +00:00
2014-06-10 17:36:06 +00:00
public ChapterManager(ILibraryManager libraryManager, ILogger logger, IServerConfigurationManager config, IItemRepository itemRepo)
2014-06-09 19:16:14 +00:00
{
_libraryManager = libraryManager;
_logger = logger;
_config = config;
2014-06-10 17:36:06 +00:00
_itemRepo = itemRepo;
2014-06-09 19:16:14 +00:00
}
2014-06-10 17:36:06 +00:00
public IEnumerable<ChapterInfo> GetChapters(string itemId)
{
return _itemRepo.GetChapters(new Guid(itemId));
}
2016-06-11 20:12:01 +00:00
public Task SaveChapters(string itemId, List<ChapterInfo> chapters, CancellationToken cancellationToken)
2014-06-10 17:36:06 +00:00
{
return _itemRepo.SaveChapters(new Guid(itemId), chapters, cancellationToken);
}
2014-06-29 17:35:05 +00:00
public ChapterOptions GetConfiguration()
{
return _config.GetConfiguration<ChapterOptions>("chapters");
}
}
public class ChapterConfigurationStore : IConfigurationFactory
{
public IEnumerable<ConfigurationStore> GetConfigurations()
{
return new List<ConfigurationStore>
{
new ConfigurationStore
{
Key = "chapters",
ConfigurationType = typeof (ChapterOptions)
}
};
}
2014-06-09 19:16:14 +00:00
}
}