This commit is contained in:
Luke Pulverenti 2017-06-18 03:11:55 -04:00
parent 0e7cbb0465
commit ce47f63389
6 changed files with 18 additions and 18 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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