added UniversalDetector.dll

This commit is contained in:
Luke Pulverenti 2015-01-10 14:42:14 -05:00
parent e978482896
commit 5ff5df9867
14 changed files with 82 additions and 35 deletions

View File

@ -1,4 +1,5 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Serialization;
@ -100,15 +101,15 @@ namespace MediaBrowser.Api
public class PackageReviewService : BaseApiService
{
private readonly IHttpClient _httpClient;
private readonly INetworkManager _netManager;
private readonly IJsonSerializer _serializer;
private const string MbAdminUrl = "http://www.mb3admin.com/admin/";
private readonly IServerApplicationHost _appHost;
public PackageReviewService(IHttpClient client, INetworkManager net, IJsonSerializer serializer)
public PackageReviewService(IHttpClient httpClient, IJsonSerializer serializer, IServerApplicationHost appHost)
{
_httpClient = client;
_netManager = net;
_httpClient = httpClient;
_serializer = serializer;
_appHost = appHost;
}
public object Get(ReviewRequest request)
@ -146,7 +147,7 @@ namespace MediaBrowser.Api
var review = new Dictionary<string, string>
{ { "id", request.Id.ToString(CultureInfo.InvariantCulture) },
{ "mac", _netManager.GetMacAddress() },
{ "mac", _appHost.SystemId },
{ "rating", request.Rating.ToString(CultureInfo.InvariantCulture) },
{ "recommend", request.Recommend.ToString() },
{ "title", title },

View File

@ -472,10 +472,10 @@ namespace MediaBrowser.Common.Implementations
NetworkManager = CreateNetworkManager(LogManager.GetLogger("NetworkManager"));
RegisterSingleInstance(NetworkManager);
SecurityManager = new PluginSecurityManager(this, HttpClient, JsonSerializer, ApplicationPaths, NetworkManager, LogManager);
SecurityManager = new PluginSecurityManager(this, HttpClient, JsonSerializer, ApplicationPaths, LogManager);
RegisterSingleInstance(SecurityManager);
InstallationManager = new InstallationManager(Logger, this, ApplicationPaths, HttpClient, JsonSerializer, SecurityManager, NetworkManager, ConfigurationManager);
InstallationManager = new InstallationManager(Logger, this, ApplicationPaths, HttpClient, JsonSerializer, SecurityManager, ConfigurationManager);
RegisterSingleInstance(InstallationManager);
ZipClient = new ZipClient();

View File

@ -55,7 +55,6 @@ namespace MediaBrowser.Common.Implementations.Security
private readonly IJsonSerializer _jsonSerializer;
private readonly IApplicationHost _appHost;
private readonly ILogger _logger;
private readonly INetworkManager _networkManager;
private readonly IApplicationPaths _appPaths;
private IEnumerable<IRequiresRegistration> _registeredEntities;
@ -71,7 +70,7 @@ namespace MediaBrowser.Common.Implementations.Security
/// Initializes a new instance of the <see cref="PluginSecurityManager" /> class.
/// </summary>
public PluginSecurityManager(IApplicationHost appHost, IHttpClient httpClient, IJsonSerializer jsonSerializer,
IApplicationPaths appPaths, INetworkManager networkManager, ILogManager logManager)
IApplicationPaths appPaths, ILogManager logManager)
{
if (httpClient == null)
{
@ -81,7 +80,6 @@ namespace MediaBrowser.Common.Implementations.Security
_appHost = appHost;
_httpClient = httpClient;
_jsonSerializer = jsonSerializer;
_networkManager = networkManager;
_appPaths = appPaths;
_logger = logManager.GetLogger("SecurityManager");
}
@ -199,12 +197,11 @@ namespace MediaBrowser.Common.Implementations.Security
if (!(lastChecked > DateTime.UtcNow.AddDays(-1)))
{
var mac = _networkManager.GetMacAddress();
var data = new Dictionary<string, string>
{
{ "feature", feature },
{ "key", SupporterKey },
{ "mac", mac },
{ "mac", _appHost.SystemId },
{ "systemid", _appHost.SystemId },
{ "mb2equiv", mb2Equivalent },
{ "ver", version },

View File

@ -105,7 +105,6 @@ namespace MediaBrowser.Common.Implementations.Updates
private readonly IHttpClient _httpClient;
private readonly IJsonSerializer _jsonSerializer;
private readonly ISecurityManager _securityManager;
private readonly INetworkManager _networkManager;
private readonly IConfigurationManager _config;
/// <summary>
@ -114,7 +113,7 @@ namespace MediaBrowser.Common.Implementations.Updates
/// <value>The application host.</value>
private readonly IApplicationHost _applicationHost;
public InstallationManager(ILogger logger, IApplicationHost appHost, IApplicationPaths appPaths, IHttpClient httpClient, IJsonSerializer jsonSerializer, ISecurityManager securityManager, INetworkManager networkManager, IConfigurationManager config)
public InstallationManager(ILogger logger, IApplicationHost appHost, IApplicationPaths appPaths, IHttpClient httpClient, IJsonSerializer jsonSerializer, ISecurityManager securityManager, IConfigurationManager config)
{
if (logger == null)
{
@ -129,7 +128,6 @@ namespace MediaBrowser.Common.Implementations.Updates
_httpClient = httpClient;
_jsonSerializer = jsonSerializer;
_securityManager = securityManager;
_networkManager = networkManager;
_config = config;
_logger = logger;
}
@ -158,7 +156,7 @@ namespace MediaBrowser.Common.Implementations.Updates
var data = new Dictionary<string, string>
{
{ "key", _securityManager.SupporterKey },
{ "mac", _networkManager.GetMacAddress() },
{ "mac", _applicationHost.SystemId },
{ "systemid", _applicationHost.SystemId }
};

View File

@ -467,7 +467,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
{
if (job.SubtitleStream.IsExternal && !job.SubtitleStream.IsTextSubtitleStream)
{
arg += " -i " + job.SubtitleStream.Path;
arg += " -i \"" + job.SubtitleStream.Path + "\"";
}
}

View File

@ -50,6 +50,9 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UniversalDetector">
<HintPath>..\ThirdParty\UniversalDetector\UniversalDetector.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\SharedVersion.cs">

View File

@ -17,6 +17,7 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using UniversalDetector;
namespace MediaBrowser.MediaEncoding.Subtitles
{
@ -611,7 +612,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
}
catch (FileNotFoundException)
{
}
catch (DirectoryNotFoundException)
{
@ -699,6 +700,18 @@ namespace MediaBrowser.MediaEncoding.Subtitles
/// <returns>System.String.</returns>
public string GetSubtitleFileCharacterSet(string path, string language)
{
var charset = DetectCharset(path);
if (!string.IsNullOrWhiteSpace(charset))
{
if (string.Equals(charset, "utf-8", StringComparison.OrdinalIgnoreCase))
{
//return null;
}
//return charset;
}
if (GetFileEncoding(path).Equals(Encoding.UTF8))
{
return string.Empty;
@ -743,6 +756,34 @@ namespace MediaBrowser.MediaEncoding.Subtitles
}
}
private string DetectCharset(string path)
{
try
{
using (var file = new FileStream(path, FileMode.Open))
{
var detector = new CharsetDetector();
detector.Feed(file);
detector.DataEnd();
var charset = detector.Charset;
if (!string.IsNullOrWhiteSpace(charset))
{
_logger.Info("UniversalDetector detected charset {0} for {1}", charset, path);
}
return charset;
}
}
catch (IOException ex)
{
_logger.ErrorException("Error attempting to determine subtitle charset from {0}", ex, path);
}
return null;
}
private static Encoding GetFileEncoding(string srcFile)
{
// *** Detect byte order mark if any - otherwise assume default

View File

@ -168,7 +168,7 @@ namespace MediaBrowser.Model.Configuration
public PeopleMetadataOptions PeopleMetadataOptions { get; set; }
public bool FindInternetTrailers { get; set; }
public string[] InsecureApps7 { get; set; }
public string[] InsecureApps8 { get; set; }
public bool SaveMetadataHidden { get; set; }
public bool EnableWin8HttpListener { get; set; }
@ -223,7 +223,7 @@ namespace MediaBrowser.Model.Configuration
PeopleMetadataOptions = new PeopleMetadataOptions();
InsecureApps7 = new[]
InsecureApps8 = new[]
{
"Chromecast",
"iOS",
@ -232,7 +232,8 @@ namespace MediaBrowser.Model.Configuration
"Media Portal",
"iPad",
"iPhone",
"Roku"
"Roku",
"Windows Phone"
};
MetadataOptions = new[]

View File

@ -18,7 +18,6 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
public class UsageEntryPoint : IServerEntryPoint
{
private readonly IApplicationHost _applicationHost;
private readonly INetworkManager _networkManager;
private readonly IHttpClient _httpClient;
private readonly ILogger _logger;
private readonly ISessionManager _sessionManager;
@ -29,11 +28,10 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
private readonly ConcurrentDictionary<Guid, ClientInfo> _apps = new ConcurrentDictionary<Guid, ClientInfo>();
public UsageEntryPoint(ILogger logger, IApplicationHost applicationHost, INetworkManager networkManager, IHttpClient httpClient, ISessionManager sessionManager, IUserManager userManager)
public UsageEntryPoint(ILogger logger, IApplicationHost applicationHost, IHttpClient httpClient, ISessionManager sessionManager, IUserManager userManager)
{
_logger = logger;
_applicationHost = applicationHost;
_networkManager = networkManager;
_httpClient = httpClient;
_sessionManager = sessionManager;
_userManager = userManager;
@ -68,7 +66,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
{
try
{
await new UsageReporter(_applicationHost, _networkManager, _httpClient, _userManager)
await new UsageReporter(_applicationHost, _httpClient, _userManager)
.ReportAppUsage(client, CancellationToken.None)
.ConfigureAwait(false);
}
@ -110,7 +108,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
{
try
{
await new UsageReporter(_applicationHost, _networkManager, _httpClient, _userManager)
await new UsageReporter(_applicationHost, _httpClient, _userManager)
.ReportServerUsage(CancellationToken.None)
.ConfigureAwait(false);
}

View File

@ -14,15 +14,13 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
public class UsageReporter
{
private readonly IApplicationHost _applicationHost;
private readonly INetworkManager _networkManager;
private readonly IHttpClient _httpClient;
private readonly IUserManager _userManager;
private const string MbAdminUrl = "http://www.mb3admin.com/admin/";
public UsageReporter(IApplicationHost applicationHost, INetworkManager networkManager, IHttpClient httpClient, IUserManager userManager)
public UsageReporter(IApplicationHost applicationHost, IHttpClient httpClient, IUserManager userManager)
{
_applicationHost = applicationHost;
_networkManager = networkManager;
_httpClient = httpClient;
_userManager = userManager;
}
@ -31,12 +29,10 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
{
cancellationToken.ThrowIfCancellationRequested();
var mac = _networkManager.GetMacAddress();
var data = new Dictionary<string, string>
{
{ "feature", _applicationHost.Name },
{ "mac", mac },
{ "mac", _applicationHost.SystemId },
{ "serverid", _applicationHost.SystemId },
{ "deviceid", _applicationHost.SystemId },
{ "ver", _applicationHost.ApplicationVersion.ToString() },

View File

@ -138,7 +138,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
return true;
}
return _config.Configuration.InsecureApps7.Contains(auth.Client ?? string.Empty,
return _config.Configuration.InsecureApps8.Contains(auth.Client ?? string.Empty,
StringComparer.OrdinalIgnoreCase);
}

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
@ -143,6 +144,14 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
var namingOptions = ((LibraryManager)libraryManager).GetNamingOptions();
// In mixed folders we need to be conservative and avoid expressions that may result in false positives (e.g. movies with numbers in the title)
if (!isTvContentType)
{
namingOptions.EpisodeExpressions = namingOptions.EpisodeExpressions
.Where(i => i.IsNamed)
.ToList();
}
var episodeResolver = new Naming.TV.EpisodeResolver(namingOptions, new Naming.Logging.NullLogger());
var episodeInfo = episodeResolver.Resolve(fullName, FileInfoType.File, false);
if (episodeInfo != null && episodeInfo.EpisodeNumber.HasValue)

View File

@ -1,4 +1,5 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
@ -576,6 +577,8 @@ namespace MediaBrowser.XbmcMetadata.Parsers
{
if (!string.IsNullOrWhiteSpace(val))
{
val = val.Replace("plugin://plugin.video.youtube/?action=play_video&videoid=", "http://www.youtube.com/watch?v=", StringComparison.OrdinalIgnoreCase);
hasTrailer.AddTrailerUrl(val, false);
}
}

View File

@ -1,4 +1,4 @@
using System.Reflection;
//[assembly: AssemblyVersion("3.0.*")]
[assembly: AssemblyVersion("3.0.5482.4")]
[assembly: AssemblyVersion("3.0.*")]
//[assembly: AssemblyVersion("3.0.5482.4")]