Luke Pulverenti 8 年之前
父节点
当前提交
ce47f63389

+ 9 - 9
Emby.Common.Implementations/TextEncoding/TextEncoding.cs

@@ -68,7 +68,7 @@ namespace Emby.Common.Implementations.TextEncoding
         }
 
         private bool _langDetectInitialized;
-        public string GetDetectedEncodingName(byte[] bytes, string language)
+        public string GetDetectedEncodingName(byte[] bytes, string language, bool enableLanguageDetection)
         {
             var encoding = GetInitialEncoding(bytes);
 
@@ -77,14 +77,14 @@ namespace Emby.Common.Implementations.TextEncoding
                 return "utf-8";
             }
 
-            if (!_langDetectInitialized)
+            if (string.IsNullOrWhiteSpace(language) && enableLanguageDetection)
             {
-                _langDetectInitialized = true;
-                LanguageDetector.Initialize(_json);
-            }
+                if (!_langDetectInitialized)
+                {
+                    _langDetectInitialized = true;
+                    LanguageDetector.Initialize(_json);
+                }
 
-            if (string.IsNullOrWhiteSpace(language))
-            {
                 language = DetectLanguage(bytes);
 
                 if (!string.IsNullOrWhiteSpace(language))
@@ -167,9 +167,9 @@ namespace Emby.Common.Implementations.TextEncoding
             }
         }
 
-        public Encoding GetDetectedEncoding(byte[] bytes, string language)
+        public Encoding GetDetectedEncoding(byte[] bytes, string language, bool enableLanguageDetection)
         {
-            var charset = GetDetectedEncodingName(bytes, language);
+            var charset = GetDetectedEncodingName(bytes, language, enableLanguageDetection);
 
             return GetEncodingFromCharset(charset);
         }

+ 3 - 3
Emby.Server.Implementations/Dto/DtoService.cs

@@ -778,16 +778,16 @@ namespace Emby.Server.Implementations.Dto
                 .Select(i => new NameIdPair
                 {
                     Name = i,
-                    Id = GetStudioId(i, item)
+                    Id = GetGenreId(i, item)
                 })
                 .ToArray();
         }
 
-        private string GetStudioId(string name, BaseItem owner)
+        private string GetGenreId(string name, BaseItem owner)
         {
             if (owner is IHasMusicGenres)
             {
-                return _libraryManager.GetGameGenreId(name).ToString("N");
+                return _libraryManager.GetMusicGenreId(name).ToString("N");
             }
 
             if (owner is Game || owner is GameSystem)

+ 1 - 1
Emby.Server.Implementations/ServerManager/WebSocketConnection.cs

@@ -136,7 +136,7 @@ namespace Emby.Server.Implementations.ServerManager
                 return;
             }
 
-            var charset = _textEncoding.GetDetectedEncodingName(bytes, null);
+            var charset = _textEncoding.GetDetectedEncodingName(bytes, null, false);
 
             if (string.Equals(charset, "utf-8", StringComparison.OrdinalIgnoreCase))
             {

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

@@ -198,7 +198,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
             {
                 var bytes = await GetBytes(path, protocol, cancellationToken).ConfigureAwait(false);
 
-                var charset = _textEncoding.GetDetectedEncodingName(bytes, language);
+                var charset = _textEncoding.GetDetectedEncodingName(bytes, language, true);
                 _logger.Debug("charset {0} detected for {1}", charset ?? "null", path);
 
                 if (!string.IsNullOrEmpty(charset))
@@ -705,7 +705,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
         {
             var bytes = await GetBytes(path, protocol, cancellationToken).ConfigureAwait(false);
 
-            var charset = _textEncoding.GetDetectedEncodingName(bytes, language);
+            var charset = _textEncoding.GetDetectedEncodingName(bytes, language, true);
 
             _logger.Debug("charset {0} detected for {1}", charset ?? "null", path);
 

+ 2 - 2
MediaBrowser.Model/Text/ITextEncoding.cs

@@ -7,8 +7,8 @@ namespace MediaBrowser.Model.Text
     {
         Encoding GetASCIIEncoding();
 
-        string GetDetectedEncodingName(byte[] bytes, string language);
-        Encoding GetDetectedEncoding(byte[] bytes, string language);
+        string GetDetectedEncodingName(byte[] bytes, string language, bool enableLanguageDetection);
+        Encoding GetDetectedEncoding(byte[] bytes, string language, bool enableLanguageDetection);
         Encoding GetEncodingFromCharset(string charset);
     }
 }

+ 1 - 1
SharedVersion.cs

@@ -1,3 +1,3 @@
 using System.Reflection;
 
-[assembly: AssemblyVersion("3.2.20.4")]
+[assembly: AssemblyVersion("3.2.20.5")]