display server name in dashboard

This commit is contained in:
Luke Pulverenti 2015-01-18 14:53:34 -05:00
parent 5f76b59e67
commit cefd565e67
11 changed files with 52 additions and 70 deletions

View File

@ -629,7 +629,7 @@ namespace MediaBrowser.Api.Playback
if (!string.IsNullOrEmpty(state.SubtitleStream.Language)) if (!string.IsNullOrEmpty(state.SubtitleStream.Language))
{ {
var charenc = SubtitleEncoder.GetSubtitleFileCharacterSet(subtitlePath, state.SubtitleStream.Language); var charenc = SubtitleEncoder.GetSubtitleFileCharacterSet(subtitlePath);
if (!string.IsNullOrEmpty(charenc)) if (!string.IsNullOrEmpty(charenc))
{ {

View File

@ -47,9 +47,8 @@ namespace MediaBrowser.Controller.MediaEncoding
/// Gets the subtitle language encoding parameter. /// Gets the subtitle language encoding parameter.
/// </summary> /// </summary>
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <param name="language">The language.</param>
/// <returns>System.String.</returns> /// <returns>System.String.</returns>
string GetSubtitleFileCharacterSet(string path, string language); string GetSubtitleFileCharacterSet(string path);
} }
} }

View File

@ -1015,7 +1015,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
if (!string.IsNullOrEmpty(state.SubtitleStream.Language)) if (!string.IsNullOrEmpty(state.SubtitleStream.Language))
{ {
var charenc = SubtitleEncoder.GetSubtitleFileCharacterSet(subtitlePath, state.SubtitleStream.Language); var charenc = SubtitleEncoder.GetSubtitleFileCharacterSet(subtitlePath);
if (!string.IsNullOrEmpty(charenc)) if (!string.IsNullOrEmpty(charenc))
{ {

View File

@ -149,22 +149,22 @@ namespace MediaBrowser.MediaEncoding.Subtitles
var fileInfo = await GetReadableFile(mediaSource.Path, inputFiles, mediaSource.Protocol, subtitleStream, cancellationToken).ConfigureAwait(false); var fileInfo = await GetReadableFile(mediaSource.Path, inputFiles, mediaSource.Protocol, subtitleStream, cancellationToken).ConfigureAwait(false);
var stream = await GetSubtitleStream(fileInfo.Item1, subtitleStream.Language, fileInfo.Item3).ConfigureAwait(false); var stream = await GetSubtitleStream(fileInfo.Item1, fileInfo.Item3).ConfigureAwait(false);
return new Tuple<Stream, string>(stream, fileInfo.Item2); return new Tuple<Stream, string>(stream, fileInfo.Item2);
} }
private async Task<Stream> GetSubtitleStream(string path, string language, bool requiresCharset) private async Task<Stream> GetSubtitleStream(string path, bool requiresCharset)
{ {
if (requiresCharset && !string.IsNullOrEmpty(language)) if (requiresCharset)
{ {
var charset = GetSubtitleFileCharacterSet(path, language); var charset = GetSubtitleFileCharacterSet(path);
if (!string.IsNullOrEmpty(charset)) if (!string.IsNullOrEmpty(charset))
{ {
using (var fs = _fileSystem.GetFileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, true)) using (var fs = _fileSystem.GetFileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, true))
{ {
using (var reader = new StreamReader(fs, Encoding.GetEncoding(charset))) using (var reader = new StreamReader(fs, GetEncoding(charset)))
{ {
var text = await reader.ReadToEndAsync().ConfigureAwait(false); var text = await reader.ReadToEndAsync().ConfigureAwait(false);
@ -179,6 +179,23 @@ namespace MediaBrowser.MediaEncoding.Subtitles
return File.OpenRead(path); return File.OpenRead(path);
} }
private Encoding GetEncoding(string charset)
{
if (string.IsNullOrWhiteSpace(charset))
{
throw new ArgumentNullException("charset");
}
try
{
return Encoding.GetEncoding(charset);
}
catch (ArgumentException)
{
return Encoding.GetEncoding(charset.Replace("-", string.Empty));
}
}
private async Task<Tuple<string, string, bool>> GetReadableFile(string mediaPath, private async Task<Tuple<string, string, bool>> GetReadableFile(string mediaPath,
string[] inputFiles, string[] inputFiles,
MediaProtocol protocol, MediaProtocol protocol,
@ -227,8 +244,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
// Convert // Convert
var outputPath = GetSubtitleCachePath(mediaPath, subtitleStream.Index, ".srt"); var outputPath = GetSubtitleCachePath(mediaPath, subtitleStream.Index, ".srt");
await ConvertTextSubtitleToSrt(subtitleStream.Path, outputPath, subtitleStream.Language, cancellationToken) await ConvertTextSubtitleToSrt(subtitleStream.Path, outputPath, cancellationToken).ConfigureAwait(false);
.ConfigureAwait(false);
return new Tuple<string, string, bool>(outputPath, "srt", true); return new Tuple<string, string, bool>(outputPath, "srt", true);
} }
@ -321,11 +337,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles
/// </summary> /// </summary>
/// <param name="inputPath">The input path.</param> /// <param name="inputPath">The input path.</param>
/// <param name="outputPath">The output path.</param> /// <param name="outputPath">The output path.</param>
/// <param name="language">The language.</param>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns> /// <returns>Task.</returns>
public async Task ConvertTextSubtitleToSrt(string inputPath, string outputPath, string language, public async Task ConvertTextSubtitleToSrt(string inputPath, string outputPath, CancellationToken cancellationToken)
CancellationToken cancellationToken)
{ {
var semaphore = GetLock(outputPath); var semaphore = GetLock(outputPath);
@ -335,7 +349,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
{ {
if (!File.Exists(outputPath)) if (!File.Exists(outputPath))
{ {
await ConvertTextSubtitleToSrtInternal(inputPath, outputPath, language).ConfigureAwait(false); await ConvertTextSubtitleToSrtInternal(inputPath, outputPath).ConfigureAwait(false);
} }
} }
finally finally
@ -349,15 +363,12 @@ namespace MediaBrowser.MediaEncoding.Subtitles
/// </summary> /// </summary>
/// <param name="inputPath">The input path.</param> /// <param name="inputPath">The input path.</param>
/// <param name="outputPath">The output path.</param> /// <param name="outputPath">The output path.</param>
/// <param name="language">The language.</param>
/// <returns>Task.</returns> /// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException"> /// <exception cref="System.ArgumentNullException">inputPath
/// inputPath
/// or /// or
/// outputPath /// outputPath</exception>
/// </exception>
/// <exception cref="System.ApplicationException"></exception> /// <exception cref="System.ApplicationException"></exception>
private async Task ConvertTextSubtitleToSrtInternal(string inputPath, string outputPath, string language) private async Task ConvertTextSubtitleToSrtInternal(string inputPath, string outputPath)
{ {
if (string.IsNullOrEmpty(inputPath)) if (string.IsNullOrEmpty(inputPath))
{ {
@ -371,9 +382,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
var encodingParam = string.IsNullOrEmpty(language) var encodingParam = GetSubtitleFileCharacterSet(inputPath);
? string.Empty
: GetSubtitleFileCharacterSet(inputPath, language);
if (!string.IsNullOrEmpty(encodingParam)) if (!string.IsNullOrEmpty(encodingParam))
{ {
@ -696,10 +705,14 @@ namespace MediaBrowser.MediaEncoding.Subtitles
/// Gets the subtitle language encoding param. /// Gets the subtitle language encoding param.
/// </summary> /// </summary>
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <param name="language">The language.</param>
/// <returns>System.String.</returns> /// <returns>System.String.</returns>
public string GetSubtitleFileCharacterSet(string path, string language) public string GetSubtitleFileCharacterSet(string path)
{ {
if (GetFileEncoding(path).Equals(Encoding.UTF8))
{
return string.Empty;
}
var charset = DetectCharset(path); var charset = DetectCharset(path);
if (!string.IsNullOrWhiteSpace(charset)) if (!string.IsNullOrWhiteSpace(charset))
@ -712,11 +725,11 @@ namespace MediaBrowser.MediaEncoding.Subtitles
return charset; return charset;
} }
if (GetFileEncoding(path).Equals(Encoding.UTF8)) return null;
{ }
return string.Empty;
}
public string GetSubtitleFileCharacterSetFromLanguage(string language)
{
switch (language.ToLower()) switch (language.ToLower())
{ {
case "pol": case "pol":

View File

@ -191,8 +191,6 @@ namespace MediaBrowser.Model.Configuration
public bool SaveMetadataHidden { get; set; } public bool SaveMetadataHidden { get; set; }
public bool EnableWin8HttpListener { get; set; }
public NameValuePair[] ContentTypes { get; set; } public NameValuePair[] ContentTypes { get; set; }
public bool EnableAudioArchiveFiles { get; set; } public bool EnableAudioArchiveFiles { get; set; }
@ -214,7 +212,6 @@ namespace MediaBrowser.Model.Configuration
EnableDashboardResourceMinification = true; EnableDashboardResourceMinification = true;
EnableAutomaticRestart = true; EnableAutomaticRestart = true;
EnableWin8HttpListener = true;
EnableUPnP = true; EnableUPnP = true;

View File

@ -183,14 +183,7 @@ namespace MediaBrowser.Providers.Movies
if (DateTime.TryParseExact(result.release_date, "yyyy-MM-dd", EnUs, DateTimeStyles.None, out r)) if (DateTime.TryParseExact(result.release_date, "yyyy-MM-dd", EnUs, DateTimeStyles.None, out r))
{ {
// Allow one year tolernace, preserve order from Tmdb // Allow one year tolernace, preserve order from Tmdb
var variance = Math.Abs(r.Year - year.Value); return Math.Abs(r.Year - year.Value);
if (variance <= 1)
{
return 0;
}
return variance;
} }
} }

View File

@ -41,8 +41,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
private readonly ReaderWriterLockSlim _localEndpointLock = new ReaderWriterLockSlim(); private readonly ReaderWriterLockSlim _localEndpointLock = new ReaderWriterLockSlim();
private readonly bool _supportsNativeWebSocket;
private string _certificatePath; private string _certificatePath;
/// <summary> /// <summary>
@ -67,12 +65,10 @@ namespace MediaBrowser.Server.Implementations.HttpServer
ILogManager logManager, ILogManager logManager,
string serviceName, string serviceName,
string defaultRedirectPath, string defaultRedirectPath,
bool supportsNativeWebSocket,
params Assembly[] assembliesWithServices) params Assembly[] assembliesWithServices)
: base(serviceName, assembliesWithServices) : base(serviceName, assembliesWithServices)
{ {
DefaultRedirectPath = defaultRedirectPath; DefaultRedirectPath = defaultRedirectPath;
_supportsNativeWebSocket = supportsNativeWebSocket;
_logger = logManager.GetLogger("HttpServer"); _logger = logManager.GetLogger("HttpServer");
@ -210,13 +206,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
private IHttpListener GetListener() private IHttpListener GetListener()
{ {
if (_supportsNativeWebSocket && NativeWebSocket.IsSupported)
{
// Certificate location is ignored here. You need to use netsh
// to assign the certificate to the proper port.
return new HttpListenerServer(_logger, OnRequestReceived);
}
return new WebSocketSharpListener(_logger, OnRequestReceived, _certificatePath); return new WebSocketSharpListener(_logger, OnRequestReceived, _certificatePath);
} }

View File

@ -17,17 +17,15 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// <param name="logManager">The log manager.</param> /// <param name="logManager">The log manager.</param>
/// <param name="serverName">Name of the server.</param> /// <param name="serverName">Name of the server.</param>
/// <param name="defaultRedirectpath">The default redirectpath.</param> /// <param name="defaultRedirectpath">The default redirectpath.</param>
/// <param name="supportsNativeWebSocket">if set to <c>true</c> [supports native web socket].</param>
/// <returns>IHttpServer.</returns> /// <returns>IHttpServer.</returns>
public static IHttpServer CreateServer(IApplicationHost applicationHost, public static IHttpServer CreateServer(IApplicationHost applicationHost,
ILogManager logManager, ILogManager logManager,
string serverName, string serverName,
string defaultRedirectpath, string defaultRedirectpath)
bool supportsNativeWebSocket)
{ {
LogManager.LogFactory = new ServerLogFactory(logManager); LogManager.LogFactory = new ServerLogFactory(logManager);
return new HttpListenerHost(applicationHost, logManager, serverName, defaultRedirectpath, supportsNativeWebSocket); return new HttpListenerHost(applicationHost, logManager, serverName, defaultRedirectpath);
} }
} }
} }

View File

@ -591,6 +591,8 @@
"MediaInfoStreamTypeEmbeddedImage": "Embedded Image", "MediaInfoStreamTypeEmbeddedImage": "Embedded Image",
"MediaInfoRefFrames": "Ref frames", "MediaInfoRefFrames": "Ref frames",
"TabPlayback": "Playback", "TabPlayback": "Playback",
"TabNotifications": "Notifications",
"TabExpert": "Expert",
"HeaderSelectCustomIntrosPath": "Select Custom Intros Path", "HeaderSelectCustomIntrosPath": "Select Custom Intros Path",
"HeaderRateAndReview": "Rate and Review", "HeaderRateAndReview": "Rate and Review",
"HeaderThankYou": "Thank You", "HeaderThankYou": "Thank You",
@ -625,6 +627,7 @@
"DashboardTourMobile": "The Media Browser dashboard works great on smartphones and tablets. Manage your server from the palm of your hand anytime, anywhere.", "DashboardTourMobile": "The Media Browser dashboard works great on smartphones and tablets. Manage your server from the palm of your hand anytime, anywhere.",
"MessageRefreshQueued": "Refresh queued", "MessageRefreshQueued": "Refresh queued",
"TabDevices": "Devices", "TabDevices": "Devices",
"TabExtras": "Extras",
"DeviceLastUsedByUserName": "Last used by {0}", "DeviceLastUsedByUserName": "Last used by {0}",
"HeaderDeleteDevice": "Delete Device", "HeaderDeleteDevice": "Delete Device",
"DeleteDeviceConfirmation": "Are you sure you wish to delete this device? It will reappear the next time a user signs in with it.", "DeleteDeviceConfirmation": "Are you sure you wish to delete this device? It will reappear the next time a user signs in with it.",

View File

@ -42,7 +42,7 @@
"ButtonTermsOfService": "Terms of Service", "ButtonTermsOfService": "Terms of Service",
"HeaderDeveloperOptions": "Developer Options", "HeaderDeveloperOptions": "Developer Options",
"OptionEnableWebClientResponseCache": "Enable web client response caching", "OptionEnableWebClientResponseCache": "Enable web client response caching",
"OptionDisableForDevelopmentHelp": "Disable these for web client development purposes", "OptionDisableForDevelopmentHelp": "Configure these as needed for web client development purposes.",
"OptionEnableWebClientResourceMinification": "Enable web client resource minification", "OptionEnableWebClientResourceMinification": "Enable web client resource minification",
"LabelDashboardSourcePath": "Web client source path:", "LabelDashboardSourcePath": "Web client source path:",
"LabelDashboardSourcePathHelp": "If running the server from source, specify the path to the dashboard-ui folder. All web client files will be served from this location.", "LabelDashboardSourcePathHelp": "If running the server from source, specify the path to the dashboard-ui folder. All web client files will be served from this location.",
@ -53,6 +53,7 @@
"HeaderAudio": "Audio", "HeaderAudio": "Audio",
"HeaderVideo": "Video", "HeaderVideo": "Video",
"HeaderPaths": "Paths", "HeaderPaths": "Paths",
"TitleNotifications": "Notifications",
"ButtonDonateWithPayPal": "Donate with PayPal", "ButtonDonateWithPayPal": "Donate with PayPal",
"OptionDetectArchiveFilesAsMedia": "Detect archive files as media", "OptionDetectArchiveFilesAsMedia": "Detect archive files as media",
"OptionDetectArchiveFilesAsMediaHelp": "If enabled, files with .rar and .zip extensions will be detected as media files.", "OptionDetectArchiveFilesAsMediaHelp": "If enabled, files with .rar and .zip extensions will be detected as media files.",
@ -71,6 +72,7 @@
"FolderTypeTvShows": "TV", "FolderTypeTvShows": "TV",
"FolderTypeInherit": "Inherit", "FolderTypeInherit": "Inherit",
"LabelContentType": "Content type:", "LabelContentType": "Content type:",
"TitleScheduledTasks": "Scheduled Tasks",
"HeaderSetupLibrary": "Setup your media library", "HeaderSetupLibrary": "Setup your media library",
"ButtonAddMediaFolder": "Add media folder", "ButtonAddMediaFolder": "Add media folder",
"LabelFolderType": "Folder type:", "LabelFolderType": "Folder type:",

View File

@ -460,19 +460,7 @@ namespace MediaBrowser.Server.Startup.Common
RegisterSingleInstance<ISearchEngine>(() => new SearchEngine(LogManager, LibraryManager, UserManager)); RegisterSingleInstance<ISearchEngine>(() => new SearchEngine(LogManager, LibraryManager, UserManager));
if (IsFirstRun) HttpServer = ServerFactory.CreateServer(this, LogManager, "Media Browser", "web/index.html");
{
ServerConfigurationManager.Configuration.EnableWin8HttpListener = false;
ServerConfigurationManager.SaveConfiguration();
_supportsNativeWebSocket = false;
}
if (!ServerConfigurationManager.Configuration.EnableWin8HttpListener)
{
_supportsNativeWebSocket = false;
}
HttpServer = ServerFactory.CreateServer(this, LogManager, "Media Browser", "web/index.html", false);
RegisterSingleInstance(HttpServer, false); RegisterSingleInstance(HttpServer, false);
progress.Report(10); progress.Report(10);