mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-07 20:08:59 +02:00
sync updates
This commit is contained in:
parent
053f2fccbf
commit
ee632803b3
2 changed files with 22 additions and 3 deletions
|
@ -47,6 +47,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
private readonly Func<ISubtitleEncoder> _subtitleEncoder;
|
private readonly Func<ISubtitleEncoder> _subtitleEncoder;
|
||||||
private readonly IConfigurationManager _config;
|
private readonly IConfigurationManager _config;
|
||||||
|
private IUserDataManager _userDataManager;
|
||||||
|
|
||||||
private ISyncProvider[] _providers = { };
|
private ISyncProvider[] _providers = { };
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
public event EventHandler<GenericEventArgs<SyncJobItem>> SyncJobItemUpdated;
|
public event EventHandler<GenericEventArgs<SyncJobItem>> SyncJobItemUpdated;
|
||||||
public event EventHandler<GenericEventArgs<SyncJobItem>> SyncJobItemCreated;
|
public event EventHandler<GenericEventArgs<SyncJobItem>> SyncJobItemCreated;
|
||||||
|
|
||||||
public SyncManager(ILibraryManager libraryManager, ISyncRepository repo, IImageProcessor imageProcessor, ILogger logger, IUserManager userManager, Func<IDtoService> dtoService, IApplicationHost appHost, ITVSeriesManager tvSeriesManager, Func<IMediaEncoder> mediaEncoder, IFileSystem fileSystem, Func<ISubtitleEncoder> subtitleEncoder, IConfigurationManager config)
|
public SyncManager(ILibraryManager libraryManager, ISyncRepository repo, IImageProcessor imageProcessor, ILogger logger, IUserManager userManager, Func<IDtoService> dtoService, IApplicationHost appHost, ITVSeriesManager tvSeriesManager, Func<IMediaEncoder> mediaEncoder, IFileSystem fileSystem, Func<ISubtitleEncoder> subtitleEncoder, IConfigurationManager config, IUserDataManager userDataManager)
|
||||||
{
|
{
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
|
@ -70,6 +71,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
_subtitleEncoder = subtitleEncoder;
|
_subtitleEncoder = subtitleEncoder;
|
||||||
_config = config;
|
_config = config;
|
||||||
|
_userDataManager = userDataManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddParts(IEnumerable<ISyncProvider> providers)
|
public void AddParts(IEnumerable<ISyncProvider> providers)
|
||||||
|
@ -666,7 +668,24 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||||
|
|
||||||
public Task ReportOfflineAction(UserAction action)
|
public Task ReportOfflineAction(UserAction action)
|
||||||
{
|
{
|
||||||
return Task.FromResult(true);
|
switch (action.Type)
|
||||||
|
{
|
||||||
|
case UserActionType.PlayedItem:
|
||||||
|
return ReportOfflinePlayedItem(action);
|
||||||
|
default:
|
||||||
|
throw new ArgumentException("Unexpected action type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task ReportOfflinePlayedItem(UserAction action)
|
||||||
|
{
|
||||||
|
var item = _libraryManager.GetItemById(action.ItemId);
|
||||||
|
var userData = _userDataManager.GetUserData(new Guid(action.UserId), item.GetUserDataKey());
|
||||||
|
|
||||||
|
userData.LastPlayedDate = action.Date;
|
||||||
|
_userDataManager.UpdatePlayState(item, userData, action.PositionTicks ?? item.RunTimeTicks ?? 0);
|
||||||
|
|
||||||
|
return _userDataManager.SaveUserData(new Guid(action.UserId), item, userData, UserDataSaveReason.Import, CancellationToken.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SyncedItem> GetReadySyncItems(string targetId)
|
public List<SyncedItem> GetReadySyncItems(string targetId)
|
||||||
|
|
|
@ -445,7 +445,7 @@ namespace MediaBrowser.Server.Startup.Common
|
||||||
TVSeriesManager = new TVSeriesManager(UserManager, UserDataManager, LibraryManager);
|
TVSeriesManager = new TVSeriesManager(UserManager, UserDataManager, LibraryManager);
|
||||||
RegisterSingleInstance(TVSeriesManager);
|
RegisterSingleInstance(TVSeriesManager);
|
||||||
|
|
||||||
SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager, () => DtoService, this, TVSeriesManager, () => MediaEncoder, FileSystemManager, () => SubtitleEncoder, ServerConfigurationManager);
|
SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager, () => DtoService, this, TVSeriesManager, () => MediaEncoder, FileSystemManager, () => SubtitleEncoder, ServerConfigurationManager, UserDataManager);
|
||||||
RegisterSingleInstance(SyncManager);
|
RegisterSingleInstance(SyncManager);
|
||||||
|
|
||||||
DtoService = new DtoService(Logger, LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager, SyncManager, this, () => DeviceManager);
|
DtoService = new DtoService(Logger, LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager, SyncManager, this, () => DeviceManager);
|
||||||
|
|
Loading…
Reference in a new issue