2
0
Эх сурвалжийг харах

Merge pull request #2096 from Bond-009/embytv

Clean up Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
dkanada 5 жил өмнө
parent
commit
d217f1614e

+ 2 - 2
Emby.Server.Implementations/Library/MediaSourceManager.cs

@@ -146,7 +146,7 @@ namespace Emby.Server.Implementations.Library
             });
         }
 
-        public async Task<List<MediaSourceInfo>> GetPlayackMediaSources(BaseItem item, User user, bool allowMediaProbe, bool enablePathSubstitution, CancellationToken cancellationToken)
+        public async Task<List<MediaSourceInfo>> GetPlaybackMediaSources(BaseItem item, User user, bool allowMediaProbe, bool enablePathSubstitution, CancellationToken cancellationToken)
         {
             var mediaSources = GetStaticMediaSources(item, enablePathSubstitution, user);
 
@@ -308,7 +308,7 @@ namespace Emby.Server.Implementations.Library
                 return await GetLiveStream(liveStreamId, cancellationToken).ConfigureAwait(false);
             }
 
-            var sources = await GetPlayackMediaSources(item, null, false, enablePathSubstitution, cancellationToken).ConfigureAwait(false);
+            var sources = await GetPlaybackMediaSources(item, null, false, enablePathSubstitution, cancellationToken).ConfigureAwait(false);
 
             return sources.FirstOrDefault(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase));
         }

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 213 - 279
Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs


+ 68 - 0
Emby.Server.Implementations/LiveTv/EmbyTV/EpgChannelData.cs

@@ -0,0 +1,68 @@
+#pragma warning disable SA1600
+#pragma warning disable CS1591
+
+using System;
+using System.Collections.Generic;
+using MediaBrowser.Controller.LiveTv;
+
+namespace Emby.Server.Implementations.LiveTv.EmbyTV
+{
+
+    internal class EpgChannelData
+    {
+        public EpgChannelData(IEnumerable<ChannelInfo> channels)
+        {
+            ChannelsById = new Dictionary<string, ChannelInfo>(StringComparer.OrdinalIgnoreCase);
+            ChannelsByNumber = new Dictionary<string, ChannelInfo>(StringComparer.OrdinalIgnoreCase);
+            ChannelsByName = new Dictionary<string, ChannelInfo>(StringComparer.OrdinalIgnoreCase);
+
+            foreach (var channel in channels)
+            {
+                ChannelsById[channel.Id] = channel;
+
+                if (!string.IsNullOrEmpty(channel.Number))
+                {
+                    ChannelsByNumber[channel.Number] = channel;
+                }
+
+                var normalizedName = NormalizeName(channel.Name ?? string.Empty);
+                if (!string.IsNullOrWhiteSpace(normalizedName))
+                {
+                    ChannelsByName[normalizedName] = channel;
+                }
+            }
+        }
+
+        private Dictionary<string, ChannelInfo> ChannelsById { get; set; }
+
+        private Dictionary<string, ChannelInfo> ChannelsByNumber { get; set; }
+
+        private Dictionary<string, ChannelInfo> ChannelsByName { get; set; }
+
+        public ChannelInfo GetChannelById(string id)
+        {
+            ChannelsById.TryGetValue(id, out var result);
+
+            return result;
+        }
+
+        public ChannelInfo GetChannelByNumber(string number)
+        {
+            ChannelsByNumber.TryGetValue(number, out var result);
+
+            return result;
+        }
+
+        public ChannelInfo GetChannelByName(string name)
+        {
+            ChannelsByName.TryGetValue(name, out var result);
+
+            return result;
+        }
+
+        public static string NormalizeName(string value)
+        {
+            return value.Replace(" ", string.Empty, StringComparison.Ordinal).Replace("-", string.Empty, StringComparison.Ordinal);
+        }
+    }
+}

+ 19 - 0
Emby.Server.Implementations/LiveTv/EmbyTV/NfoConfigurationExtensions.cs

@@ -0,0 +1,19 @@
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Model.Configuration;
+
+namespace Emby.Server.Implementations.LiveTv.EmbyTV
+{
+    /// <summary>
+    /// Class containing extension methods for working with the nfo configuration.
+    /// </summary>
+    public static class NfoConfigurationExtensions
+    {
+        /// <summary>
+        /// Gets the nfo configuration.
+        /// </summary>
+        /// <param name="configurationManager">The configuration manager.</param>
+        /// <returns>The nfo configuration.</returns>
+        public static XbmcMetadataOptions GetNfoConfiguration(this IConfigurationManager configurationManager)
+         => configurationManager.GetConfiguration<XbmcMetadataOptions>("xbmcmetadata");
+    }
+}

+ 4 - 1
Emby.Server.Implementations/LiveTv/LiveTvManager.cs

@@ -1,3 +1,6 @@
+#pragma warning disable SA1600
+#pragma warning disable CS1591
+
 using System;
 using System.Collections.Generic;
 using System.Globalization;
@@ -35,7 +38,7 @@ using Microsoft.Extensions.Logging;
 namespace Emby.Server.Implementations.LiveTv
 {
     /// <summary>
-    /// Class LiveTvManager
+    /// Class LiveTvManager.
     /// </summary>
     public class LiveTvManager : ILiveTvManager, IDisposable
     {

+ 1 - 1
MediaBrowser.Api/Playback/BaseStreamingService.cs

@@ -759,7 +759,7 @@ namespace MediaBrowser.Api.Playback
 
                 if (mediaSource == null)
                 {
-                    var mediaSources = await MediaSourceManager.GetPlayackMediaSources(LibraryManager.GetItemById(request.Id), null, false, false, cancellationToken).ConfigureAwait(false);
+                    var mediaSources = await MediaSourceManager.GetPlaybackMediaSources(LibraryManager.GetItemById(request.Id), null, false, false, cancellationToken).ConfigureAwait(false);
 
                     mediaSource = string.IsNullOrEmpty(request.MediaSourceId)
                        ? mediaSources[0]

+ 1 - 1
MediaBrowser.Api/Playback/MediaInfoService.cs

@@ -284,7 +284,7 @@ namespace MediaBrowser.Api.Playback
                 try
                 {
                     // TODO handle supportedLiveMediaTypes ?
-                    mediaSources = await _mediaSourceManager.GetPlayackMediaSources(item, user, true, false, CancellationToken.None).ConfigureAwait(false);
+                    mediaSources = await _mediaSourceManager.GetPlaybackMediaSources(item, user, true, false, CancellationToken.None).ConfigureAwait(false);
                 }
                 catch (Exception ex)
                 {

+ 1 - 1
MediaBrowser.Controller/Library/IMediaSourceManager.cs

@@ -55,7 +55,7 @@ namespace MediaBrowser.Controller.Library
         /// <summary>
         /// Gets the playack media sources.
         /// </summary>
-        Task<List<MediaSourceInfo>> GetPlayackMediaSources(BaseItem item, User user, bool allowMediaProbe, bool enablePathSubstitution, CancellationToken cancellationToken);
+        Task<List<MediaSourceInfo>> GetPlaybackMediaSources(BaseItem item, User user, bool allowMediaProbe, bool enablePathSubstitution, CancellationToken cancellationToken);
 
         /// <summary>
         /// Gets the static media sources.

+ 2 - 2
MediaBrowser.MediaEncoding/Attachments/AttachmentExtractor.cs

@@ -59,7 +59,7 @@ namespace MediaBrowser.MediaEncoding.Attachments
                 throw new ArgumentNullException(nameof(mediaSourceId));
             }
 
-            var mediaSources = await _mediaSourceManager.GetPlayackMediaSources(item, null, true, false, cancellationToken).ConfigureAwait(false);
+            var mediaSources = await _mediaSourceManager.GetPlaybackMediaSources(item, null, true, false, cancellationToken).ConfigureAwait(false);
             var mediaSource = mediaSources
                 .FirstOrDefault(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase));
             if (mediaSource == null)
@@ -196,7 +196,7 @@ namespace MediaBrowser.MediaEncoding.Attachments
             var exitCode = ranToCompletion ? process.ExitCode : -1;
 
             process.Dispose();
-            
+
             var failed = false;
 
             if (exitCode != 0)

+ 1 - 1
MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs

@@ -123,7 +123,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
                 throw new ArgumentNullException(nameof(mediaSourceId));
             }
 
-            var mediaSources = await _mediaSourceManager.GetPlayackMediaSources(item, null, true, false, cancellationToken).ConfigureAwait(false);
+            var mediaSources = await _mediaSourceManager.GetPlaybackMediaSources(item, null, true, false, cancellationToken).ConfigureAwait(false);
 
             var mediaSource = mediaSources
                 .First(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase));

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно