From 36295aa833bf5d152613500a4546aa76314150a8 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 3 Jan 2015 14:38:22 -0500 Subject: [PATCH] use SocketHttpListener project --- MediaBrowser.Api/Dlna/DlnaServerService.cs | 8 ++---- MediaBrowser.Api/IHasDtoOptions.cs | 2 +- .../Playback/BaseStreamingService.cs | 2 +- .../Dto/DtoOptions.cs | 2 +- .../MediaBrowser.Controller.csproj | 1 + .../Encoder/EncodingUtils.cs | 16 +++++++++++- .../MediaBrowser.Model.Portable.csproj | 3 --- .../MediaBrowser.Model.net35.csproj | 3 --- MediaBrowser.Model/MediaBrowser.Model.csproj | 1 - .../Drawing/ImageProcessor.cs | 2 +- .../FileOrganization/EpisodeFileOrganizer.cs | 1 + .../HttpServer/SocketSharp/Extensions.cs | 6 ++--- .../HttpServer/SocketSharp/SharpWebSocket.cs | 10 +++---- .../SocketSharp/SocketSharpLogger.cs | 2 +- .../SocketSharp/WebSocketSharpListener.cs | 2 +- .../SocketSharp/WebSocketSharpRequest.cs | 2 +- .../SocketSharp/WebSocketSharpResponse.cs | 2 +- ...MediaBrowser.Server.Implementations.csproj | 7 +++-- .../Sync/SyncManager.cs | 26 +++++++++++++++---- .../MediaBrowser.WebDashboard.csproj | 24 ----------------- 20 files changed, 59 insertions(+), 63 deletions(-) rename {MediaBrowser.Model => MediaBrowser.Controller}/Dto/DtoOptions.cs (97%) diff --git a/MediaBrowser.Api/Dlna/DlnaServerService.cs b/MediaBrowser.Api/Dlna/DlnaServerService.cs index 9981d506e..94d6e25b0 100644 --- a/MediaBrowser.Api/Dlna/DlnaServerService.cs +++ b/MediaBrowser.Api/Dlna/DlnaServerService.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Common.Configuration; -using MediaBrowser.Controller.Dlna; +using MediaBrowser.Controller.Dlna; using ServiceStack; using ServiceStack.Text.Controller; using ServiceStack.Web; @@ -77,14 +76,11 @@ namespace MediaBrowser.Api.Dlna private readonly IContentDirectory _contentDirectory; private readonly IConnectionManager _connectionManager; - private readonly IConfigurationManager _config; - - public DlnaServerService(IDlnaManager dlnaManager, IContentDirectory contentDirectory, IConnectionManager connectionManager, IConfigurationManager config) + public DlnaServerService(IDlnaManager dlnaManager, IContentDirectory contentDirectory, IConnectionManager connectionManager) { _dlnaManager = dlnaManager; _contentDirectory = contentDirectory; _connectionManager = connectionManager; - _config = config; } public object Get(GetDescriptionXml request) diff --git a/MediaBrowser.Api/IHasDtoOptions.cs b/MediaBrowser.Api/IHasDtoOptions.cs index 2e677e816..7fe47c4a1 100644 --- a/MediaBrowser.Api/IHasDtoOptions.cs +++ b/MediaBrowser.Api/IHasDtoOptions.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Model.Dto; +using MediaBrowser.Controller.Dto; using MediaBrowser.Model.Entities; using System; using System.Linq; diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 0858a0347..8662e64b4 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -834,7 +834,7 @@ namespace MediaBrowser.Api.Playback { if (state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream) { - arg += " -i " + state.SubtitleStream.Path; + arg += " -i \"" + state.SubtitleStream.Path + "\""; } } diff --git a/MediaBrowser.Model/Dto/DtoOptions.cs b/MediaBrowser.Controller/Dto/DtoOptions.cs similarity index 97% rename from MediaBrowser.Model/Dto/DtoOptions.cs rename to MediaBrowser.Controller/Dto/DtoOptions.cs index 60eb6b1fe..eeb4fc114 100644 --- a/MediaBrowser.Model/Dto/DtoOptions.cs +++ b/MediaBrowser.Controller/Dto/DtoOptions.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; -namespace MediaBrowser.Model.Dto +namespace MediaBrowser.Controller.Dto { public class DtoOptions { diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 1d16db62c..0667730fd 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -115,6 +115,7 @@ + diff --git a/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs b/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs index c76f78009..b34a4cd38 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs @@ -41,7 +41,7 @@ namespace MediaBrowser.MediaEncoding.Encoder // If there's more than one we'll need to use the concat command if (inputFiles.Count > 1) { - var files = string.Join("|", inputFiles); + var files = string.Join("|", inputFiles.Select(NormalizePath).ToArray()); return string.Format("concat:\"{0}\"", files); } @@ -57,9 +57,23 @@ namespace MediaBrowser.MediaEncoding.Encoder /// System.String. private static string GetFileInputArgument(string path) { + // Quotes are valid path characters in linux and they need to be escaped here with a leading \ + path = NormalizePath(path); + return string.Format("file:\"{0}\"", path); } + /// + /// Normalizes the path. + /// + /// The path. + /// System.String. + private static string NormalizePath(string path) + { + // Quotes are valid path characters in linux and they need to be escaped here with a leading \ + return path.Replace("\"", "\\\""); + } + public static string GetProbeSizeArgument(bool isDvd) { return isDvd ? "-probesize 1G -analyzeduration 200M" : string.Empty; diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index e4cfab571..c49e3e303 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -428,9 +428,6 @@ Dto\ChapterInfoDto.cs - - Dto\DtoOptions.cs - Dto\GameSystemSummary.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index 3fc5201a7..d8a29e8da 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -393,9 +393,6 @@ Dto\ChapterInfoDto.cs - - Dto\DtoOptions.cs - Dto\GameSystemSummary.cs diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index d5280f4b1..2a1b0b659 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -127,7 +127,6 @@ - diff --git a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs index 967c78c50..5055d2750 100644 --- a/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs +++ b/MediaBrowser.Server.Implementations/Drawing/ImageProcessor.cs @@ -367,7 +367,7 @@ namespace MediaBrowser.Server.Implementations.Drawing new UnplayedCountIndicator().DrawUnplayedCountIndicator(graphics, currentImageSize, options.UnplayedCount.Value); } - if (options.PercentPlayed >= 0) + if (options.PercentPlayed > 0) { var currentImageSize = new Size(imageWidth, imageHeight); diff --git a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs index 432ea1f69..a4ac22eea 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs +++ b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs @@ -373,6 +373,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization if (episode == null) { + _logger.Warn("No provider metadata found for {0} season {1} episode {2}", series.Name, seasonNumber, episodeNumber); return null; } diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/Extensions.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/Extensions.cs index 63d57b6be..154313fb9 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/Extensions.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/Extensions.cs @@ -1,6 +1,6 @@ -using System; -using MediaBrowser.Model.Logging; -using WebSocketSharp.Net; +using MediaBrowser.Model.Logging; +using SocketHttpListener.Net; +using System; namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp { diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs index 401d49325..9dcb679f4 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs @@ -21,7 +21,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp /// Gets or sets the web socket. /// /// The web socket. - private WebSocketSharp.WebSocket WebSocket { get; set; } + private SocketHttpListener.WebSocket WebSocket { get; set; } private readonly CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource(); @@ -31,7 +31,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp /// The socket. /// The logger. /// socket - public SharpWebSocket(WebSocketSharp.WebSocket socket, ILogger logger) + public SharpWebSocket(SocketHttpListener.WebSocket socket, ILogger logger) { if (socket == null) { @@ -53,17 +53,17 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp WebSocket.ConnectAsServer(); } - void socket_OnError(object sender, WebSocketSharp.ErrorEventArgs e) + void socket_OnError(object sender, SocketHttpListener.ErrorEventArgs e) { EventHelper.FireEventIfNotNull(Closed, this, EventArgs.Empty, _logger); } - void socket_OnClose(object sender, WebSocketSharp.CloseEventArgs e) + void socket_OnClose(object sender, SocketHttpListener.CloseEventArgs e) { EventHelper.FireEventIfNotNull(Closed, this, EventArgs.Empty, _logger); } - void socket_OnMessage(object sender, WebSocketSharp.MessageEventArgs e) + void socket_OnMessage(object sender, SocketHttpListener.MessageEventArgs e) { if (OnReceive != null) { diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SocketSharpLogger.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SocketSharpLogger.cs index ffc99793e..427671b30 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SocketSharpLogger.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SocketSharpLogger.cs @@ -3,7 +3,7 @@ using System; namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp { - public class SocketSharpLogger : WebSocketSharp.Logging.ILogger + public class SocketSharpLogger : SocketHttpListener.Logging.ILogger { private readonly ILogger _logger; diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs index 77d968409..419d145bb 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs @@ -7,7 +7,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using WebSocketSharp.Net; +using SocketHttpListener.Net; namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp { diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs index 7a5f6fbdc..54c27cf0a 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpRequest.cs @@ -7,7 +7,7 @@ using MediaBrowser.Model.Logging; using ServiceStack; using ServiceStack.Host; using ServiceStack.Web; -using WebSocketSharp.Net; +using SocketHttpListener.Net; namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp { diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs index b725af610..171dacb22 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpResponse.cs @@ -5,7 +5,7 @@ using MediaBrowser.Model.Logging; using ServiceStack; using ServiceStack.Host; using ServiceStack.Web; -using HttpListenerResponse = WebSocketSharp.Net.HttpListenerResponse; +using HttpListenerResponse = SocketHttpListener.Net.HttpListenerResponse; namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp { diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 4e698b12f..ccc0737e9 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -64,6 +64,9 @@ ..\ThirdParty\ServiceStack\ServiceStack.Api.Swagger.dll + + ..\ThirdParty\SocketHttpListener\SocketHttpListener.dll + @@ -91,10 +94,6 @@ ..\ThirdParty\ServiceStack.Text\ServiceStack.Text.dll - - False - ..\ThirdParty\WebsocketSharp\websocket-sharp.dll - diff --git a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs index 68eaa38d3..3b2d70f84 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs @@ -37,7 +37,7 @@ namespace MediaBrowser.Server.Implementations.Sync private readonly Func _dtoService; private readonly IApplicationHost _appHost; private readonly ITVSeriesManager _tvSeriesManager; - private readonly Func MediaEncoder; + private readonly Func _mediaEncoder; private ISyncProvider[] _providers = { }; @@ -51,7 +51,7 @@ namespace MediaBrowser.Server.Implementations.Sync _dtoService = dtoService; _appHost = appHost; _tvSeriesManager = tvSeriesManager; - MediaEncoder = mediaEncoder; + _mediaEncoder = mediaEncoder; } public void AddParts(IEnumerable providers) @@ -61,7 +61,7 @@ namespace MediaBrowser.Server.Implementations.Sync public async Task CreateJob(SyncJobRequest request) { - var processor = new SyncJobProcessor(_libraryManager, _repo, this, _logger, _userManager, _tvSeriesManager, MediaEncoder()); + var processor = new SyncJobProcessor(_libraryManager, _repo, this, _logger, _userManager, _tvSeriesManager, _mediaEncoder()); var user = _userManager.GetUserById(request.UserId); @@ -165,7 +165,7 @@ namespace MediaBrowser.Server.Implementations.Sync if (item == null) { - var processor = new SyncJobProcessor(_libraryManager, _repo, this, _logger, _userManager, _tvSeriesManager, MediaEncoder()); + var processor = new SyncJobProcessor(_libraryManager, _repo, this, _logger, _userManager, _tvSeriesManager, _mediaEncoder()); var user = _userManager.GetUserById(job.UserId); @@ -395,7 +395,7 @@ namespace MediaBrowser.Server.Implementations.Sync await _repo.Update(jobItem).ConfigureAwait(false); - var processor = new SyncJobProcessor(_libraryManager, _repo, this, _logger, _userManager, _tvSeriesManager, MediaEncoder()); + var processor = new SyncJobProcessor(_libraryManager, _repo, this, _logger, _userManager, _tvSeriesManager, _mediaEncoder()); await processor.UpdateJobStatus(jobItem.JobId).ConfigureAwait(false); } @@ -532,6 +532,22 @@ namespace MediaBrowser.Server.Implementations.Sync } } + // Now check each item that's on the device + foreach (var itemId in request.LocalItemIds) + { + // See if it's already marked for removal + if (response.ItemIdsToRemove.Contains(itemId, StringComparer.OrdinalIgnoreCase)) + { + continue; + } + + // If there isn't a sync job for this item, mark it for removal + if (!jobItemResult.Items.Any(i => string.Equals(itemId, i.ItemId, StringComparison.OrdinalIgnoreCase))) + { + response.ItemIdsToRemove.Add(itemId); + } + } + response.ItemIdsToRemove = response.ItemIdsToRemove.Distinct(StringComparer.OrdinalIgnoreCase).ToList(); return response; diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index df8f4072a..1343b1e69 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -624,33 +624,9 @@ PreserveNewest - - PreserveNewest - - - PreserveNewest - PreserveNewest - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - PreserveNewest