diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-06-30 15:58:53 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2017-06-30 15:58:53 -0400 |
| commit | 1f96841e0452620763808b0b470e99ff188ef8f0 (patch) | |
| tree | 670212dc336cce289fbd0f6d647832cfaf58df8e /Emby.Server.Implementations/Channels/ChannelManager.cs | |
| parent | dcaf8356e6400543e10ff2ee89fc9b3bdf97ef77 (diff) | |
add perfect match indicator to subtitle editor
Diffstat (limited to 'Emby.Server.Implementations/Channels/ChannelManager.cs')
| -rw-r--r-- | Emby.Server.Implementations/Channels/ChannelManager.cs | 80 |
1 files changed, 77 insertions, 3 deletions
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<IChannel> channels) { - _channels = channels.ToArray(); + Channels = channels.ToArray(); } private IEnumerable<IChannel> 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<RefreshChannelsScheduledTask>(); + + 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 |
