diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index 85f6c6667..2adf6a37c 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -29,13 +29,15 @@ using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.IO; +using MediaBrowser.Controller.Plugins; using MediaBrowser.Model.Globalization; +using MediaBrowser.Model.Tasks; namespace Emby.Server.Implementations.Channels { public class ChannelManager : IChannelManager { - private IChannel[] _channels; + internal IChannel[] Channels { get; private set; } private readonly IUserManager _userManager; private readonly IUserDataManager _userDataManager; @@ -76,12 +78,12 @@ namespace Emby.Server.Implementations.Channels public void AddParts(IEnumerable channels) { - _channels = channels.ToArray(); + Channels = channels.ToArray(); } private IEnumerable GetAllChannels() { - return _channels + return Channels .OrderBy(i => i.Name); } @@ -1559,4 +1561,76 @@ namespace Emby.Server.Implementations.Channels return await _libraryManager.GetNamedView(name, "channels", "zz_" + name, cancellationToken).ConfigureAwait(false); } } + + public class ChannelsEntryPoint : IServerEntryPoint + { + private readonly IServerConfigurationManager _config; + private readonly IChannelManager _channelManager; + private readonly ITaskManager _taskManager; + private readonly IFileSystem _fileSystem; + + public ChannelsEntryPoint(IChannelManager channelManager, ITaskManager taskManager, IServerConfigurationManager config, IFileSystem fileSystem) + { + _channelManager = channelManager; + _taskManager = taskManager; + _config = config; + _fileSystem = fileSystem; + } + + public void Run() + { + var channels = ((ChannelManager)_channelManager).Channels + .Select(i => i.GetType().FullName.GetMD5().ToString("N")) + .ToArray(); + + var channelsString = string.Join(",", channels); + + if (!string.Equals(channelsString, GetSavedLastChannels(), StringComparison.OrdinalIgnoreCase)) + { + _taskManager.QueueIfNotRunning(); + + SetSavedLastChannels(channelsString); + } + } + + private string DataPath + { + get { return Path.Combine(_config.ApplicationPaths.DataPath, "channels.txt"); } + } + + private string GetSavedLastChannels() + { + try + { + return _fileSystem.ReadAllText(DataPath); + } + catch + { + return string.Empty; + } + } + + private void SetSavedLastChannels(string value) + { + try + { + if (string.IsNullOrWhiteSpace(value)) + { + _fileSystem.DeleteFile(DataPath); + + } + else + { + _fileSystem.WriteAllText(DataPath, value); + } + } + catch + { + } + } + + public void Dispose() + { + } + } } \ No newline at end of file diff --git a/Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs b/Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs index e25955782..df8d1ac45 100644 --- a/Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs +++ b/Emby.Server.Implementations/Data/CleanDatabaseScheduledTask.cs @@ -56,24 +56,9 @@ namespace Emby.Server.Implementations.Data var rootChildren = _libraryManager.RootFolder.Children.ToList(); rootChildren = _libraryManager.GetUserRootFolder().Children.ToList(); - var innerProgress = new ActionableProgress(); - innerProgress.RegisterAction(p => - { - double newPercentCommplete = .45 * p; - progress.Report(newPercentCommplete); - }); - await CleanDeadItems(cancellationToken, innerProgress).ConfigureAwait(false); - progress.Report(45); + await CleanDeadItems(cancellationToken, progress).ConfigureAwait(false); - innerProgress = new ActionableProgress(); - innerProgress.RegisterAction(p => - { - double newPercentCommplete = 45 + .55 * p; - progress.Report(newPercentCommplete); - }); - - await _itemRepo.UpdateInheritedValues(cancellationToken).ConfigureAwait(false); - progress.Report(100); + //await _itemRepo.UpdateInheritedValues(cancellationToken).ConfigureAwait(false); } private async Task CleanDeadItems(CancellationToken cancellationToken, IProgress progress) diff --git a/MediaBrowser.Api/Subtitles/SubtitleService.cs b/MediaBrowser.Api/Subtitles/SubtitleService.cs index 7dde974ae..645aacdec 100644 --- a/MediaBrowser.Api/Subtitles/SubtitleService.cs +++ b/MediaBrowser.Api/Subtitles/SubtitleService.cs @@ -46,6 +46,8 @@ namespace MediaBrowser.Api.Subtitles [ApiMember(Name = "Language", Description = "Language", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] public string Language { get; set; } + + public bool? IsPerfectMatch { get; set; } } [Route("/Items/{Id}/RemoteSearch/Subtitles/Providers", "GET")] @@ -247,11 +249,11 @@ namespace MediaBrowser.Api.Subtitles CancellationToken.None); } - public object Get(SearchRemoteSubtitles request) + public async Task Get(SearchRemoteSubtitles request) { var video = (Video)_libraryManager.GetItemById(request.Id); - var response = _subtitleManager.SearchSubtitles(video, request.Language, CancellationToken.None).Result; + var response = await _subtitleManager.SearchSubtitles(video, request.Language, request.IsPerfectMatch, CancellationToken.None).ConfigureAwait(false); return ToOptimizedResult(response); } diff --git a/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs b/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs index 0c814c0d4..d1d5f27be 100644 --- a/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs +++ b/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs @@ -28,12 +28,9 @@ namespace MediaBrowser.Controller.Subtitles /// /// Searches the subtitles. /// - /// The video. - /// The language. - /// The cancellation token. - /// Task{IEnumerable{RemoteSubtitleInfo}}. Task> SearchSubtitles(Video video, string language, + bool? isPerfectMatch, CancellationToken cancellationToken); /// diff --git a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs index fb8c34034..8555f9c38 100644 --- a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs +++ b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs @@ -52,6 +52,7 @@ namespace MediaBrowser.Model.LiveTv public TunerHostInfo() { AllowHWTranscoding = true; + EnableTvgId = true; } } diff --git a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs index be2ecf04a..f7071f519 100644 --- a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs +++ b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs @@ -173,7 +173,7 @@ namespace MediaBrowser.Providers.Subtitles } } - public Task> SearchSubtitles(Video video, string language, CancellationToken cancellationToken) + public Task> SearchSubtitles(Video video, string language, bool? isPerfectMatch, CancellationToken cancellationToken) { if (video.LocationType != LocationType.FileSystem || video.VideoType != VideoType.VideoFile) @@ -207,7 +207,8 @@ namespace MediaBrowser.Providers.Subtitles ParentIndexNumber = video.ParentIndexNumber, ProductionYear = video.ProductionYear, ProviderIds = video.ProviderIds, - RuntimeTicks = video.RunTimeTicks + RuntimeTicks = video.RunTimeTicks, + IsPerfectMatch = isPerfectMatch ?? false }; var episode = video as Episode; @@ -261,8 +262,7 @@ namespace MediaBrowser.Providers.Subtitles _monitor.ReportFileSystemChangeComplete(path, false); } - _libraryManager.GetItemById(itemId).ChangedExternally(); - return Task.FromResult(true); + return _libraryManager.GetItemById(itemId).RefreshMetadata(CancellationToken.None); } public Task GetRemoteSubtitles(string id, CancellationToken cancellationToken) diff --git a/SharedVersion.cs b/SharedVersion.cs index 1af2abc27..686b4c737 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.20.17")] +[assembly: AssemblyVersion("3.2.20.18")]