From d8d5dd487326dd3fccf4e9f30cd8f7e3783fcfda Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 12 Jan 2015 22:46:44 -0500 Subject: make channel access opt-in rather than opt out --- .../HttpServer/SocketSharp/RequestMono.cs | 25 ---------------------- 1 file changed, 25 deletions(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/RequestMono.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/RequestMono.cs index 226d97b3cd..2c8413f5e3 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/RequestMono.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/RequestMono.cs @@ -556,31 +556,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp return (stream); } } - - public void SaveAs(string filename) - { - byte[] buffer = new byte[16 * 1024]; - long old_post = stream.Position; - - try - { - File.Delete(filename); - using (FileStream fs = File.Create(filename)) - { - stream.Position = 0; - int n; - - while ((n = stream.Read(buffer, 0, 16 * 1024)) != 0) - { - fs.Write(buffer, 0, n); - } - } - } - finally - { - stream.Position = old_post; - } - } } class Helpers -- cgit v1.2.3 From 7a136349eea53097a4fb9e52de81a32bf2a4e086 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 16 Jan 2015 23:38:24 -0500 Subject: update components --- .../MediaBrowser.Common.Implementations.csproj | 8 +-- .../packages.config | 2 +- .../FileOrganization/EpisodeFileOrganizer.cs | 3 +- .../HttpServer/SocketSharp/SocketSharpLogger.cs | 50 ----------------- .../SocketSharp/WebSocketSharpListener.cs | 3 +- .../Library/LibraryManager.cs | 13 ++--- .../Library/Resolvers/Audio/MusicAlbumResolver.cs | 3 +- .../Library/Resolvers/BaseVideoResolver.cs | 5 +- .../Library/Resolvers/Movies/MovieResolver.cs | 5 +- .../Library/Resolvers/TV/SeriesResolver.cs | 3 +- .../Logging/PatternsLogger.cs | 63 ++++++++++++++++++++++ .../MediaBrowser.Server.Implementations.csproj | 14 +++-- .../packages.config | 4 +- 13 files changed, 102 insertions(+), 74 deletions(-) delete mode 100644 MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SocketSharpLogger.cs create mode 100644 MediaBrowser.Server.Implementations/Logging/PatternsLogger.cs (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj index b04f46c7a5..d7e5886d59 100644 --- a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj +++ b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj @@ -56,13 +56,13 @@ False ..\ThirdParty\SharpCompress\SharpCompress.dll - + False - ..\packages\SimpleInjector.2.6.1\lib\net45\SimpleInjector.dll + ..\packages\SimpleInjector.2.7.0\lib\net45\SimpleInjector.dll - + False - ..\packages\SimpleInjector.2.6.1\lib\net45\SimpleInjector.Diagnostics.dll + ..\packages\SimpleInjector.2.7.0\lib\net45\SimpleInjector.Diagnostics.dll diff --git a/MediaBrowser.Common.Implementations/packages.config b/MediaBrowser.Common.Implementations/packages.config index ba9df1b8a0..825b6662b2 100644 --- a/MediaBrowser.Common.Implementations/packages.config +++ b/MediaBrowser.Common.Implementations/packages.config @@ -1,5 +1,5 @@  - + diff --git a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs index cfc3e2b234..2fc5f9bc20 100644 --- a/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs +++ b/MediaBrowser.Server.Implementations/FileOrganization/EpisodeFileOrganizer.cs @@ -17,6 +17,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Server.Implementations.Library; +using MediaBrowser.Server.Implementations.Logging; namespace MediaBrowser.Server.Implementations.FileOrganization { @@ -57,7 +58,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization }; var namingOptions = ((LibraryManager) _libraryManager).GetNamingOptions(); - var resolver = new Naming.TV.EpisodeResolver(namingOptions, new Naming.Logging.NullLogger()); + var resolver = new Naming.TV.EpisodeResolver(namingOptions, new PatternsLogger()); var episodeInfo = resolver.Resolve(path, FileInfoType.File) ?? new Naming.TV.EpisodeInfo(); diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SocketSharpLogger.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SocketSharpLogger.cs deleted file mode 100644 index 427671b30a..0000000000 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/SocketSharpLogger.cs +++ /dev/null @@ -1,50 +0,0 @@ -using MediaBrowser.Model.Logging; -using System; - -namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp -{ - public class SocketSharpLogger : SocketHttpListener.Logging.ILogger - { - private readonly ILogger _logger; - - public SocketSharpLogger(ILogger logger) - { - _logger = logger; - } - - public void Debug(string message, params object[] paramList) - { - _logger.Debug(message, paramList); - } - - public void Error(string message, params object[] paramList) - { - _logger.Error(message, paramList); - } - - public void ErrorException(string message, Exception exception, params object[] paramList) - { - _logger.ErrorException(message, exception, paramList); - } - - public void Fatal(string message, params object[] paramList) - { - _logger.Fatal(message, paramList); - } - - public void FatalException(string message, Exception exception, params object[] paramList) - { - _logger.FatalException(message, exception, paramList); - } - - public void Info(string message, params object[] paramList) - { - _logger.Info(message, paramList); - } - - public void Warn(string message, params object[] paramList) - { - _logger.Warn(message, paramList); - } - } -} diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs index 419d145bba..04db0d8a58 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs @@ -1,5 +1,6 @@ using MediaBrowser.Controller.Net; using MediaBrowser.Model.Logging; +using MediaBrowser.Server.Implementations.Logging; using ServiceStack; using ServiceStack.Web; using System; @@ -33,7 +34,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp public void Start(IEnumerable urlPrefixes) { if (_listener == null) - _listener = new HttpListener(new SocketSharpLogger(_logger)); + _listener = new HttpListener(new PatternsLogger(_logger), null); foreach (var prefix in urlPrefixes) { diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 6a999a7f4a..684a03894a 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -22,6 +22,7 @@ using MediaBrowser.Naming.IO; using MediaBrowser.Naming.TV; using MediaBrowser.Naming.Video; using MediaBrowser.Server.Implementations.Library.Validators; +using MediaBrowser.Server.Implementations.Logging; using MediaBrowser.Server.Implementations.ScheduledTasks; using System; using System.Collections.Concurrent; @@ -1771,7 +1772,7 @@ namespace MediaBrowser.Server.Implementations.Library public bool IsVideoFile(string path) { - var resolver = new VideoResolver(GetNamingOptions(), new Naming.Logging.NullLogger()); + var resolver = new VideoResolver(GetNamingOptions(), new PatternsLogger()); return resolver.IsVideoFile(path); } @@ -1789,7 +1790,7 @@ namespace MediaBrowser.Server.Implementations.Library public bool FillMissingEpisodeNumbersFromPath(Episode episode) { var resolver = new EpisodeResolver(GetNamingOptions(), - new Naming.Logging.NullLogger()); + new PatternsLogger()); var fileType = episode.VideoType == VideoType.BluRay || episode.VideoType == VideoType.Dvd || episode.VideoType == VideoType.HdDvd ? FileInfoType.Directory : @@ -1927,7 +1928,7 @@ namespace MediaBrowser.Server.Implementations.Library public ItemLookupInfo ParseName(string name) { - var resolver = new VideoResolver(GetNamingOptions(), new Naming.Logging.NullLogger()); + var resolver = new VideoResolver(GetNamingOptions(), new PatternsLogger()); var result = resolver.CleanDateTime(name); var cleanName = resolver.CleanString(result.Name); @@ -1946,7 +1947,7 @@ namespace MediaBrowser.Server.Implementations.Library .SelectMany(i => i.EnumerateFiles("*", SearchOption.TopDirectoryOnly)) .ToList(); - var videoListResolver = new VideoListResolver(GetNamingOptions(), new Naming.Logging.NullLogger()); + var videoListResolver = new VideoListResolver(GetNamingOptions(), new PatternsLogger()); var videos = videoListResolver.Resolve(fileSystemChildren.Select(i => new PortableFileInfo { @@ -1999,7 +2000,7 @@ namespace MediaBrowser.Server.Implementations.Library .SelectMany(i => i.EnumerateFiles("*", SearchOption.TopDirectoryOnly)) .ToList(); - var videoListResolver = new VideoListResolver(GetNamingOptions(), new Naming.Logging.NullLogger()); + var videoListResolver = new VideoListResolver(GetNamingOptions(), new PatternsLogger()); var videos = videoListResolver.Resolve(fileSystemChildren.Select(i => new PortableFileInfo { @@ -2037,7 +2038,7 @@ namespace MediaBrowser.Server.Implementations.Library private void SetExtraTypeFromFilename(Video item) { - var resolver = new ExtraResolver(GetNamingOptions(), new Naming.Logging.NullLogger(), new RegexProvider()); + var resolver = new ExtraResolver(GetNamingOptions(), new PatternsLogger(), new RegexProvider()); var result = resolver.GetExtraInfo(item.Path); diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs index 7c8ddabebf..d349665b11 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs @@ -10,6 +10,7 @@ using MediaBrowser.Naming.Common; using System; using System.Collections.Generic; using System.IO; +using MediaBrowser.Server.Implementations.Logging; namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio { @@ -169,7 +170,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio { var namingOptions = ((LibraryManager)_libraryManager).GetNamingOptions(); - var parser = new AlbumParser(namingOptions, new Naming.Logging.NullLogger()); + var parser = new AlbumParser(namingOptions, new PatternsLogger()); var result = parser.ParseMultiPart(path); return result.IsMultiPart; diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs index 1a4d35af55..3333719b79 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs @@ -7,6 +7,7 @@ using MediaBrowser.Naming.Video; using System; using System.IO; using System.Linq; +using MediaBrowser.Server.Implementations.Logging; namespace MediaBrowser.Server.Implementations.Library.Resolvers { @@ -47,7 +48,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers var namingOptions = ((LibraryManager)LibraryManager).GetNamingOptions(); // If the path is a file check for a matching extensions - var parser = new Naming.Video.VideoResolver(namingOptions, new Naming.Logging.NullLogger()); + var parser = new Naming.Video.VideoResolver(namingOptions, new PatternsLogger()); if (args.IsDirectory) { @@ -233,7 +234,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers { var namingOptions = ((LibraryManager)LibraryManager).GetNamingOptions(); - var resolver = new Format3DParser(namingOptions, new Naming.Logging.NullLogger()); + var resolver = new Format3DParser(namingOptions, new PatternsLogger()); var result = resolver.Parse(video.Path); Set3DFormat(video, result.Is3D, result.Format3D); diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs index 96ae281b90..3c8141e77e 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs @@ -12,6 +12,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using MediaBrowser.Server.Implementations.Logging; namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies { @@ -111,7 +112,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies var namingOptions = ((LibraryManager)LibraryManager).GetNamingOptions(); - var resolver = new VideoListResolver(namingOptions, new Naming.Logging.NullLogger()); + var resolver = new VideoListResolver(namingOptions, new PatternsLogger()); var resolverResult = resolver.Resolve(files.Select(i => new PortableFileInfo { FullName = i.FullName, @@ -436,7 +437,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies } var namingOptions = ((LibraryManager)LibraryManager).GetNamingOptions(); - var resolver = new StackResolver(namingOptions, new Naming.Logging.NullLogger()); + var resolver = new StackResolver(namingOptions, new PatternsLogger()); var result = resolver.ResolveDirectories(folderPaths); diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs index ff05c29ee9..7371ca5a9c 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs @@ -12,6 +12,7 @@ using MediaBrowser.Model.Logging; using MediaBrowser.Naming.Common; using MediaBrowser.Naming.IO; using MediaBrowser.Naming.TV; +using MediaBrowser.Server.Implementations.Logging; using EpisodeInfo = MediaBrowser.Controller.Providers.EpisodeInfo; namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV @@ -152,7 +153,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV .ToList(); } - var episodeResolver = new Naming.TV.EpisodeResolver(namingOptions, new Naming.Logging.NullLogger()); + var episodeResolver = new Naming.TV.EpisodeResolver(namingOptions, new PatternsLogger()); var episodeInfo = episodeResolver.Resolve(fullName, FileInfoType.File, false); if (episodeInfo != null && episodeInfo.EpisodeNumber.HasValue) { diff --git a/MediaBrowser.Server.Implementations/Logging/PatternsLogger.cs b/MediaBrowser.Server.Implementations/Logging/PatternsLogger.cs new file mode 100644 index 0000000000..00b6cc5a8b --- /dev/null +++ b/MediaBrowser.Server.Implementations/Logging/PatternsLogger.cs @@ -0,0 +1,63 @@ +using Patterns.Logging; +using System; + +namespace MediaBrowser.Server.Implementations.Logging +{ + public class PatternsLogger : ILogger + { + private readonly Model.Logging.ILogger _logger; + + public PatternsLogger() + : this(new Model.Logging.NullLogger()) + { + } + + public PatternsLogger(Model.Logging.ILogger logger) + { + _logger = logger; + } + + public void Debug(string message, params object[] paramList) + { + _logger.Debug(message, paramList); + } + + public void Error(string message, params object[] paramList) + { + _logger.Error(message, paramList); + } + + public void ErrorException(string message, Exception exception, params object[] paramList) + { + _logger.ErrorException(message, exception, paramList); + } + + public void Fatal(string message, params object[] paramList) + { + _logger.Fatal(message, paramList); + } + + public void FatalException(string message, Exception exception, params object[] paramList) + { + _logger.FatalException(message, exception, paramList); + } + + public void Info(string message, params object[] paramList) + { + _logger.Info(message, paramList); + } + + public void Warn(string message, params object[] paramList) + { + _logger.Warn(message, paramList); + } + + public void Log(LogSeverity severity, string message, params object[] paramList) + { + } + + public void LogMultiline(string message, LogSeverity severity, System.Text.StringBuilder additionalContent) + { + } + } +} diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index b4f277fbdf..548ac07aaf 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -50,7 +50,8 @@ ..\ThirdParty\libwebp\Imazen.WebP.dll - ..\packages\MediaBrowser.Naming.1.0.0.29\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll + ..\packages\MediaBrowser.Naming.1.0.0.30\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll + True False @@ -60,11 +61,16 @@ False ..\packages\morelinq.1.1.0\lib\net35\MoreLinq.dll + + ..\packages\Patterns.Logging.1.0.0.2\lib\portable-net45+sl4+wp71+win8+wpa81\Patterns.Logging.dll + True + ..\ThirdParty\ServiceStack\ServiceStack.Api.Swagger.dll - - ..\ThirdParty\SocketHttpListener\SocketHttpListener.dll + + False + ..\packages\SocketHttpListener.1.0.0.0\lib\net45\SocketHttpListener.dll @@ -164,7 +170,6 @@ - @@ -224,6 +229,7 @@ + diff --git a/MediaBrowser.Server.Implementations/packages.config b/MediaBrowser.Server.Implementations/packages.config index b23446eee6..b2edfbbc1c 100644 --- a/MediaBrowser.Server.Implementations/packages.config +++ b/MediaBrowser.Server.Implementations/packages.config @@ -1,6 +1,8 @@  - + + + \ No newline at end of file -- cgit v1.2.3 From 2300d56f688c2515def000fbd2330ad9e0116d33 Mon Sep 17 00:00:00 2001 From: Mike Date: Tue, 6 Jan 2015 22:36:42 -0500 Subject: Ssl in mediabrowser against new listener. --- MediaBrowser.Controller/IServerApplicationHost.cs | 22 ++++++++++++++++++++ MediaBrowser.Controller/Net/IHttpServer.cs | 4 +++- MediaBrowser.Controller/Net/IServerManager.cs | 4 +++- .../Configuration/ServerConfiguration.cs | 17 ++++++++++++++- MediaBrowser.Model/System/SystemInfo.cs | 18 ++++++++++++++++ .../HttpServer/HttpListenerHost.cs | 9 ++++++-- .../SocketSharp/WebSocketSharpListener.cs | 7 +++++-- .../Localization/Server/server.json | 8 ++++++++ .../ServerManager/ServerManager.cs | 8 ++++---- .../ApplicationHost.cs | 24 +++++++++++++++++++++- 10 files changed, 109 insertions(+), 12 deletions(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.cs index 76eb9fceb0..6bee5e58a3 100644 --- a/MediaBrowser.Controller/IServerApplicationHost.cs +++ b/MediaBrowser.Controller/IServerApplicationHost.cs @@ -36,6 +36,28 @@ namespace MediaBrowser.Controller /// The HTTP server port. int HttpServerPort { get; } + /// + /// Gets the HTTPS server port. + /// + /// The HTTPS server port. + int HttpsServerPort { get; } + + /// + /// Gets the value indiciating if an https port should be hosted. + /// + /// + /// The value indiciating if an https port should be hosted. + /// + bool UseHttps { get; } + + /// + /// Gets the value pointing to the file system where the ssl certiifcate is located. + /// + /// + /// The value pointing to the file system where the ssl certiifcate is located. + /// + string CertificatePath { get; } + /// /// Gets a value indicating whether this instance has update available. /// diff --git a/MediaBrowser.Controller/Net/IHttpServer.cs b/MediaBrowser.Controller/Net/IHttpServer.cs index 5b179d479a..d56bee009e 100644 --- a/MediaBrowser.Controller/Net/IHttpServer.cs +++ b/MediaBrowser.Controller/Net/IHttpServer.cs @@ -19,7 +19,9 @@ namespace MediaBrowser.Controller.Net /// Starts the specified server name. /// /// The URL prefixes. - void StartServer(IEnumerable urlPrefixes); + /// If an https prefix is specified, + /// the ssl certificate localtion on the file system. + void StartServer(IEnumerable urlPrefixes, string certificatePath); /// /// Gets the local end points. diff --git a/MediaBrowser.Controller/Net/IServerManager.cs b/MediaBrowser.Controller/Net/IServerManager.cs index dff0863478..d90a0f8ed6 100644 --- a/MediaBrowser.Controller/Net/IServerManager.cs +++ b/MediaBrowser.Controller/Net/IServerManager.cs @@ -15,7 +15,9 @@ namespace MediaBrowser.Controller.Net /// Starts this instance. /// /// The URL prefixes. - void Start(IEnumerable urlPrefixes); + /// If an https prefix is specified, + /// the ssl certificate localtion on the file system. + void Start(IEnumerable urlPrefixes, string certificatePath); /// /// Sends a message to all clients currently connected via a web socket diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index c4a9c5eeaf..755fe8aa83 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Model.Dto; +using System.Xml.Schema; +using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; namespace MediaBrowser.Model.Configuration @@ -32,6 +33,17 @@ namespace MediaBrowser.Model.Configuration /// The HTTPS server port number. public int HttpsPortNumber { get; set; } + /// Gets or sets the value pointing to the file system where the ssl certiifcate is located. + /// + /// The value pointing to the file system where the ssl certiifcate is located. + public bool UseHttps { get; set; } + + /// + /// Gets or sets the value pointing to the file system where the ssl certiifcate is located.. + /// + /// The value pointing to the file system where the ssl certiifcate is located.. + public string CertificatePath { get; set; } + /// /// Gets or sets a value indicating whether [enable internet providers]. /// @@ -187,6 +199,7 @@ namespace MediaBrowser.Model.Configuration public string[] InsecureApps8 { get; set; } public bool SaveMetadataHidden { get; set; } + public bool EnableWin8HttpListener { get; set; } public NameValuePair[] ContentTypes { get; set; } @@ -204,6 +217,8 @@ namespace MediaBrowser.Model.Configuration PublicPort = 8096; HttpServerPortNumber = 8096; HttpsPortNumber = 8920; + UseHttps = false; + CertificatePath = null; EnableDashboardResponseCaching = true; EnableAutomaticRestart = true; diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs index f9cacea122..9d4cfd6dbd 100644 --- a/MediaBrowser.Model/System/SystemInfo.cs +++ b/MediaBrowser.Model/System/SystemInfo.cs @@ -122,6 +122,24 @@ namespace MediaBrowser.Model.System /// The HTTP server port number. public int HttpServerPortNumber { get; set; } + /// + /// Gets or sets the value pointing to the file system where the ssl certiifcate is located. + /// + /// The value pointing to the file system where the ssl certiifcate is located. + public bool UseHttps { get; set; } + + /// + /// Gets or sets the value pointing to the file system where the ssl certiifcate is located.. + /// + /// The value pointing to the file system where the ssl certiifcate is located.. + public string CertificatePath { get; set; } + + /// + /// Gets or sets the HTTPS server port number. + /// + /// The HTTPS server port number. + public int HttpsPortNumber { get; set; } + /// /// Gets or sets a value indicating whether this instance has update available. /// diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index c3228db920..0c0922800a 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -44,6 +44,8 @@ namespace MediaBrowser.Server.Implementations.HttpServer private readonly bool _supportsNativeWebSocket; + private string _certificatePath; + /// /// Gets the local end points. /// @@ -217,10 +219,12 @@ namespace MediaBrowser.Server.Implementations.HttpServer { 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); + return new WebSocketSharpListener(_logger, OnRequestReceived, _certificatePath); } private void WebSocketHandler(WebSocketConnectEventArgs args) @@ -425,8 +429,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer GC.SuppressFinalize(this); } - public void StartServer(IEnumerable urlPrefixes) + public void StartServer(IEnumerable urlPrefixes, string certificatePath) { + _certificatePath = certificatePath; UrlPrefixes = urlPrefixes.ToList(); Start(UrlPrefixes.First()); } diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs index 04db0d8a58..1cf523ad29 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs @@ -18,11 +18,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp private readonly ILogger _logger; private readonly Action _endpointListener; + private readonly string _certificatePath ; - public WebSocketSharpListener(ILogger logger, Action endpointListener) + public WebSocketSharpListener(ILogger logger, Action endpointListener, + string certificatePath) { _logger = logger; _endpointListener = endpointListener; + _certificatePath = certificatePath; } public Action ErrorHandler { get; set; } @@ -34,7 +37,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp public void Start(IEnumerable urlPrefixes) { if (_listener == null) - _listener = new HttpListener(new PatternsLogger(_logger), null); + _listener = new HttpListener(new PatternsLogger(_logger), _certificatePath); foreach (var prefix in urlPrefixes) { diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index 35d58837cb..253d9a00db 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -508,6 +508,14 @@ "LabelLocalHttpServerPortNumberHelp": "The tcp port number that Media Browser's http server should bind to.", "LabelPublicPort": "Public port number:", "LabelPublicPortHelp": "The public port number that should be mapped to the local port.", + + "LabelUseHttps": "Enable SSL", + "LabelUseHttpsHelp": "Check to enable SSL hosting.", + "LabelHttpsPort": "Local http port:", + "LabelHttpsPortHelp": "The tcp port number that Media Browser's https server should bind to.", + "LabelCertificatePath": "SSL Certificate path:", + "LabelCertificatePathHelp": "The path on the filesystem to the ssl certificate pfx file.", + "LabelWebSocketPortNumber": "Web socket port number:", "LabelEnableAutomaticPortMap": "Enable automatic port mapping", "LabelEnableAutomaticPortMapHelp": "Attempt to automatically map the public port to the local port via UPnP. This may not work with some router models.", diff --git a/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs b/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs index 7a23d8e082..ef2fef7466 100644 --- a/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs +++ b/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs @@ -99,22 +99,22 @@ namespace MediaBrowser.Server.Implementations.ServerManager /// /// Starts this instance. /// - public void Start(IEnumerable urlPrefixes) + public void Start(IEnumerable urlPrefixes, string certificatePath) { - ReloadHttpServer(urlPrefixes); + ReloadHttpServer(urlPrefixes, certificatePath); } /// /// Restarts the Http Server, or starts it if not currently running /// - private void ReloadHttpServer(IEnumerable urlPrefixes) + private void ReloadHttpServer(IEnumerable urlPrefixes, string certificatePath) { _logger.Info("Loading Http Server"); try { HttpServer = _applicationHost.Resolve(); - HttpServer.StartServer(urlPrefixes); + HttpServer.StartServer(urlPrefixes, certificatePath); } catch (SocketException ex) { diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index f7ff5eef15..29c5304382 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -133,6 +133,11 @@ namespace MediaBrowser.Server.Startup.Common "http://+:" + ServerConfigurationManager.Configuration.HttpServerPortNumber + "/" + WebApplicationName + "/" }; + if (ServerConfigurationManager.Configuration.UseHttps) + { + list.Add("https://+:" + ServerConfigurationManager.Configuration.HttpsPortNumber + "/" + WebApplicationName + "/"); + } + return list; } } @@ -805,7 +810,7 @@ namespace MediaBrowser.Server.Startup.Common { try { - ServerManager.Start(HttpServerUrlPrefixes); + ServerManager.Start(HttpServerUrlPrefixes, CertificatePath); } catch (Exception ex) { @@ -972,6 +977,8 @@ namespace MediaBrowser.Server.Startup.Common CachePath = ApplicationPaths.CachePath, MacAddress = GetMacAddress(), HttpServerPortNumber = HttpServerPort, + UseHttps = UseHttps, + CertificatePath = CertificatePath, OperatingSystem = OperatingSystemDisplayName, CanSelfRestart = CanSelfRestart, CanSelfUpdate = CanSelfUpdate, @@ -1046,6 +1053,21 @@ namespace MediaBrowser.Server.Startup.Common get { return ServerConfigurationManager.Configuration.HttpServerPortNumber; } } + public bool UseHttps + { + get { return this.ServerConfigurationManager.Configuration.UseHttps; } + } + + public string CertificatePath + { + get { return this.ServerConfigurationManager.Configuration.CertificatePath; } + } + + public int HttpsServerPort + { + get { return ServerConfigurationManager.Configuration.HttpsPortNumber; } + } + /// /// Gets the mac address. /// -- cgit v1.2.3 From a8da86d059c0a9ba724bfcf11166d1b32406ca89 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 17 Jan 2015 14:30:23 -0500 Subject: support api without /mediabrowser --- MediaBrowser.Api/Playback/BaseStreamingService.cs | 2 +- MediaBrowser.Api/Playback/Hls/MpegDashService.cs | 2 +- MediaBrowser.Controller/IServerApplicationHost.cs | 28 --------- MediaBrowser.Dlna/Main/DlnaEntryPoint.cs | 2 +- MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs | 24 ++++---- MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs | 2 +- MediaBrowser.Model/System/SystemInfo.cs | 12 ---- .../Connect/ConnectManager.cs | 1 - .../HttpServer/HttpListenerHost.cs | 68 +++++++++++++--------- .../HttpServer/ServerFactory.cs | 4 +- .../Library/UserManager.cs | 2 +- .../Localization/Server/server.json | 8 ++- .../ApplicationHost.cs | 20 ++----- .../Browser/BrowserLauncher.cs | 6 +- .../BackgroundServiceInstaller.cs | 2 +- 15 files changed, 71 insertions(+), 112 deletions(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 84dd0c1e8d..e70c1e5733 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -857,7 +857,7 @@ namespace MediaBrowser.Api.Playback { if (SupportsThrottleWithStream) { - var url = "http://localhost:" + ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(UsCulture) + "/mediabrowser/videos/" + state.Request.Id + "/stream?static=true&Throttle=true&mediaSourceId=" + state.Request.MediaSourceId; + var url = "http://localhost:" + ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(UsCulture) + "/videos/" + state.Request.Id + "/stream?static=true&Throttle=true&mediaSourceId=" + state.Request.MediaSourceId; url += "&transcodingJobId=" + transcodingJobId; diff --git a/MediaBrowser.Api/Playback/Hls/MpegDashService.cs b/MediaBrowser.Api/Playback/Hls/MpegDashService.cs index 514597c3e1..a0b67a2209 100644 --- a/MediaBrowser.Api/Playback/Hls/MpegDashService.cs +++ b/MediaBrowser.Api/Playback/Hls/MpegDashService.cs @@ -625,7 +625,7 @@ namespace MediaBrowser.Api.Playback.Hls protected override string GetCommandLineArguments(string outputPath, string transcodingJobId, StreamState state, bool isEncoding) { - // test url http://192.168.1.2:8096/mediabrowser/videos/233e8905d559a8f230db9bffd2ac9d6d/master.mpd?mediasourceid=233e8905d559a8f230db9bffd2ac9d6d&videocodec=h264&audiocodec=aac&maxwidth=1280&videobitrate=500000&audiobitrate=128000&profile=baseline&level=3 + // test url http://192.168.1.2:8096/videos/233e8905d559a8f230db9bffd2ac9d6d/master.mpd?mediasourceid=233e8905d559a8f230db9bffd2ac9d6d&videocodec=h264&audiocodec=aac&maxwidth=1280&videobitrate=500000&audiobitrate=128000&profile=baseline&level=3 // Good info on i-frames http://blog.streamroot.io/encode-multi-bitrate-videos-mpeg-dash-mse-based-media-players/ var threads = GetNumberOfThreads(state, false); diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.cs index 6bee5e58a3..181c14debe 100644 --- a/MediaBrowser.Controller/IServerApplicationHost.cs +++ b/MediaBrowser.Controller/IServerApplicationHost.cs @@ -18,12 +18,6 @@ namespace MediaBrowser.Controller /// SystemInfo. SystemInfo GetSystemInfo(); - /// - /// Gets the name of the web application. - /// - /// The name of the web application. - string WebApplicationName { get; } - /// /// Gets a value indicating whether [supports automatic run at startup]. /// @@ -36,28 +30,6 @@ namespace MediaBrowser.Controller /// The HTTP server port. int HttpServerPort { get; } - /// - /// Gets the HTTPS server port. - /// - /// The HTTPS server port. - int HttpsServerPort { get; } - - /// - /// Gets the value indiciating if an https port should be hosted. - /// - /// - /// The value indiciating if an https port should be hosted. - /// - bool UseHttps { get; } - - /// - /// Gets the value pointing to the file system where the ssl certiifcate is located. - /// - /// - /// The value pointing to the file system where the ssl certiifcate is located. - /// - string CertificatePath { get; } - /// /// Gets a value indicating whether this instance has update available. /// diff --git a/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs b/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs index 810b1e5684..bcb539ac8d 100644 --- a/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs +++ b/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs @@ -165,7 +165,7 @@ namespace MediaBrowser.Dlna.Main { var guid = address.GetMD5(); - var descriptorURI = "/mediabrowser/dlna/" + guid.ToString("N") + "/description.xml"; + var descriptorURI = "/dlna/" + guid.ToString("N") + "/description.xml"; var uri = new Uri(string.Format("http://{0}:{1}{2}", address, _config.Configuration.HttpServerPortNumber, descriptorURI)); diff --git a/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs b/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs index f4f724d07a..545da7a86f 100644 --- a/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs +++ b/MediaBrowser.Dlna/Server/DescriptionXmlBuilder.cs @@ -139,7 +139,7 @@ namespace MediaBrowser.Dlna.Server Depth = "24", Width = 240, Height = 240, - Url = "/mediabrowser/dlna/icons/logo240.png" + Url = "/dlna/icons/logo240.png" }); list.Add(new DeviceIcon @@ -148,7 +148,7 @@ namespace MediaBrowser.Dlna.Server Depth = "24", Width = 240, Height = 240, - Url = "/mediabrowser/dlna/icons/logo240.jpg" + Url = "/dlna/icons/logo240.jpg" }); list.Add(new DeviceIcon @@ -157,7 +157,7 @@ namespace MediaBrowser.Dlna.Server Depth = "24", Width = 120, Height = 120, - Url = "/mediabrowser/dlna/icons/logo120.png" + Url = "/dlna/icons/logo120.png" }); list.Add(new DeviceIcon @@ -166,7 +166,7 @@ namespace MediaBrowser.Dlna.Server Depth = "24", Width = 120, Height = 120, - Url = "/mediabrowser/dlna/icons/logo120.jpg" + Url = "/dlna/icons/logo120.jpg" }); list.Add(new DeviceIcon @@ -175,7 +175,7 @@ namespace MediaBrowser.Dlna.Server Depth = "24", Width = 48, Height = 48, - Url = "/mediabrowser/dlna/icons/logo48.png" + Url = "/dlna/icons/logo48.png" }); list.Add(new DeviceIcon @@ -184,7 +184,7 @@ namespace MediaBrowser.Dlna.Server Depth = "24", Width = 48, Height = 48, - Url = "/mediabrowser/dlna/icons/logo48.jpg" + Url = "/dlna/icons/logo48.jpg" }); return list; @@ -198,18 +198,18 @@ namespace MediaBrowser.Dlna.Server { ServiceType = "urn:schemas-upnp-org:service:ContentDirectory:1", ServiceId = "urn:upnp-org:serviceId:ContentDirectory", - ScpdUrl = "/mediabrowser/dlna/contentdirectory/contentdirectory.xml", - ControlUrl = "/mediabrowser/dlna/contentdirectory/" + _serverUdn + "/control", - EventSubUrl = "/mediabrowser/dlna/contentdirectory/" + _serverUdn + "/events" + ScpdUrl = "/dlna/contentdirectory/contentdirectory.xml", + ControlUrl = "/dlna/contentdirectory/" + _serverUdn + "/control", + EventSubUrl = "/dlna/contentdirectory/" + _serverUdn + "/events" }); list.Add(new DeviceService { ServiceType = "urn:schemas-upnp-org:service:ConnectionManager:1", ServiceId = "urn:upnp-org:serviceId:ConnectionManager", - ScpdUrl = "/mediabrowser/dlna/connectionmanager/connectionmanager.xml", - ControlUrl = "/mediabrowser/dlna/connectionmanager/" + _serverUdn + "/control", - EventSubUrl = "/mediabrowser/dlna/connectionmanager/" + _serverUdn + "/events" + ScpdUrl = "/dlna/connectionmanager/connectionmanager.xml", + ControlUrl = "/dlna/connectionmanager/" + _serverUdn + "/control", + EventSubUrl = "/dlna/connectionmanager/" + _serverUdn + "/events" }); return list; diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index 4dc522f05c..b357b04178 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -461,7 +461,7 @@ namespace MediaBrowser.MediaEncoding.Encoder // { // if (SupportsThrottleWithStream) // { - // var url = "http://localhost:" + ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(UsCulture) + "/mediabrowser/videos/" + job.Request.Id + "/stream?static=true&Throttle=true&mediaSourceId=" + job.Request.MediaSourceId; + // var url = "http://localhost:" + ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(UsCulture) + "/videos/" + job.Request.Id + "/stream?static=true&Throttle=true&mediaSourceId=" + job.Request.MediaSourceId; // url += "&transcodingJobId=" + transcodingJobId; diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs index 9d4cfd6dbd..5a91978279 100644 --- a/MediaBrowser.Model/System/SystemInfo.cs +++ b/MediaBrowser.Model/System/SystemInfo.cs @@ -122,18 +122,6 @@ namespace MediaBrowser.Model.System /// The HTTP server port number. public int HttpServerPortNumber { get; set; } - /// - /// Gets or sets the value pointing to the file system where the ssl certiifcate is located. - /// - /// The value pointing to the file system where the ssl certiifcate is located. - public bool UseHttps { get; set; } - - /// - /// Gets or sets the value pointing to the file system where the ssl certiifcate is located.. - /// - /// The value pointing to the file system where the ssl certiifcate is located.. - public string CertificatePath { get; set; } - /// /// Gets or sets the HTTPS server port number. /// diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs index 9625593d10..194a8a4a23 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs @@ -1,5 +1,4 @@ using MediaBrowser.Common.Configuration; -using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; using MediaBrowser.Controller; using MediaBrowser.Controller.Configuration; diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index 0c0922800a..1d7e89d285 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -24,7 +24,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer { public class HttpListenerHost : ServiceStackHost, IHttpServer { - private string HandlerPath { get; set; } private string DefaultRedirectPath { get; set; } private readonly ILogger _logger; @@ -64,18 +63,16 @@ namespace MediaBrowser.Server.Implementations.HttpServer } } - public HttpListenerHost(IApplicationHost applicationHost, - ILogManager logManager, - string serviceName, - string handlerPath, - string defaultRedirectPath, - bool supportsNativeWebSocket, + public HttpListenerHost(IApplicationHost applicationHost, + ILogManager logManager, + string serviceName, + string defaultRedirectPath, + bool supportsNativeWebSocket, params Assembly[] assembliesWithServices) : base(serviceName, assembliesWithServices) { DefaultRedirectPath = defaultRedirectPath; _supportsNativeWebSocket = supportsNativeWebSocket; - HandlerPath = handlerPath; _logger = logManager.GetLogger("HttpServer"); @@ -136,13 +133,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer { base.OnConfigLoad(); - Config.HandlerFactoryPath = string.IsNullOrEmpty(HandlerPath) - ? null - : HandlerPath; + Config.HandlerFactoryPath = null; - Config.MetadataRedirectPath = string.IsNullOrEmpty(HandlerPath) - ? "metadata" - : PathUtils.CombinePaths(HandlerPath, "metadata"); + Config.MetadataRedirectPath = "metadata"; } protected override ServiceController CreateServiceController(params Assembly[] assembliesWithServices) @@ -245,7 +238,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer { return; } - + var errorResponse = new ErrorResponse { ResponseStatus = new ResponseStatus @@ -314,24 +307,24 @@ namespace MediaBrowser.Server.Implementations.HttpServer var operationName = httpReq.OperationName; var localPath = url.LocalPath; - if (string.Equals(localPath, "/" + HandlerPath + "/", StringComparison.OrdinalIgnoreCase)) + if (string.Equals(localPath, "/mediabrowser/", StringComparison.OrdinalIgnoreCase)) { - httpRes.RedirectToUrl(DefaultRedirectPath); + httpRes.RedirectToUrl("/../" + DefaultRedirectPath); return Task.FromResult(true); } - if (string.Equals(localPath, "/" + HandlerPath, StringComparison.OrdinalIgnoreCase)) + if (string.Equals(localPath, "/mediabrowser", StringComparison.OrdinalIgnoreCase)) { - httpRes.RedirectToUrl(HandlerPath + "/" + DefaultRedirectPath); + httpRes.RedirectToUrl("../" + DefaultRedirectPath); return Task.FromResult(true); } if (string.Equals(localPath, "/", StringComparison.OrdinalIgnoreCase)) { - httpRes.RedirectToUrl(HandlerPath + "/" + DefaultRedirectPath); + httpRes.RedirectToUrl(DefaultRedirectPath); return Task.FromResult(true); } if (string.IsNullOrEmpty(localPath)) { - httpRes.RedirectToUrl("/" + HandlerPath + "/" + DefaultRedirectPath); + httpRes.RedirectToUrl("/" + DefaultRedirectPath); return Task.FromResult(true); } @@ -386,12 +379,33 @@ namespace MediaBrowser.Server.Implementations.HttpServer base.Init(); } - //public override RouteAttribute[] GetRouteAttributes(System.Type requestType) - //{ - // var routes = base.GetRouteAttributes(requestType); - // routes.Each(x => x.Path = "/api" + x.Path); - // return routes; - //} + public override RouteAttribute[] GetRouteAttributes(Type requestType) + { + var routes = base.GetRouteAttributes(requestType).ToList(); + var clone = routes.ToList(); + + foreach (var route in clone) + { + routes.Add(new RouteAttribute(NormalizeRoutePath(route.Path), route.Verbs) + { + Notes = route.Notes, + Priority = route.Priority, + Summary = route.Summary + }); + } + + return routes.ToArray(); + } + + private string NormalizeRoutePath(string path) + { + if (path.StartsWith("/", StringComparison.OrdinalIgnoreCase)) + { + return "/mediabrowser" + path; + } + + return "mediabrowser/" + path; + } /// /// Releases the specified instance. diff --git a/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs index b48703a15f..73d7610601 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs @@ -16,20 +16,18 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// The application host. /// The log manager. /// Name of the server. - /// The handler path. /// The default redirectpath. /// if set to true [supports native web socket]. /// IHttpServer. public static IHttpServer CreateServer(IApplicationHost applicationHost, ILogManager logManager, string serverName, - string handlerPath, string defaultRedirectpath, bool supportsNativeWebSocket) { LogManager.LogFactory = new ServerLogFactory(logManager); - return new HttpListenerHost(applicationHost, logManager, serverName, handlerPath, defaultRedirectpath, supportsNativeWebSocket); + return new HttpListenerHost(applicationHost, logManager, serverName, defaultRedirectpath, supportsNativeWebSocket); } } } diff --git a/MediaBrowser.Server.Implementations/Library/UserManager.cs b/MediaBrowser.Server.Implementations/Library/UserManager.cs index b51a9ee7cd..edcf7255d7 100644 --- a/MediaBrowser.Server.Implementations/Library/UserManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserManager.cs @@ -744,7 +744,7 @@ namespace MediaBrowser.Server.Implementations.Library text.AppendLine("Use your web browser to visit:"); text.AppendLine(string.Empty); - text.AppendLine(localAddress + "/mediabrowser/web/forgotpasswordpin.html"); + text.AppendLine(localAddress + "/web/forgotpasswordpin.html"); text.AppendLine(string.Empty); text.AppendLine("Enter the following pin code:"); text.AppendLine(string.Empty); diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index 253d9a00db..1ed5ddb4fd 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -46,6 +46,7 @@ "HeaderTV": "TV", "HeaderAudio": "Audio", "HeaderVideo": "Video", + "HeaderPaths": "Paths", "OptionDetectArchiveFilesAsMedia": "Detect archive files as media", "OptionDetectArchiveFilesAsMediaHelp": "If enabled, files with .rar and .zip extensions will be detected as media files.", "LabelEnterConnectUserName": "User name or email:", @@ -321,8 +322,8 @@ "LabelAutomaticUpdatesFanartHelp": "If enabled, new images will be downloaded automatically as they're added to fanart.tv. Existing images will not be replaced.", "LabelAutomaticUpdatesTmdbHelp": "If enabled, new images will be downloaded automatically as they're added to TheMovieDB.org. Existing images will not be replaced.", "LabelAutomaticUpdatesTvdbHelp": "If enabled, new images will be downloaded automatically as they're added to TheTVDB.com. Existing images will not be replaced.", - "LabelFanartApiKey": "Personal api key:", - "LabelFanartApiKeyHelp": "Requests to fanart without a personal API key return results that were approved over 7 days ago. With a personal API key that drops to 48 hours and if you are also a fanart VIP member that will further drop to around 10 minutes.", + "LabelFanartApiKey": "Personal api key:", + "LabelFanartApiKeyHelp": "Requests to fanart without a personal API key return results that were approved over 7 days ago. With a personal API key that drops to 48 hours and if you are also a fanart VIP member that will further drop to around 10 minutes.", "ExtractChapterImagesHelp": "Extracting chapter images will allow clients to display graphical scene selection menus. The process can be slow, cpu-intensive and may require several gigabytes of space. It runs when videos are discovered, and also as a nightly scheduled task at 4am. The schedule is configurable in the scheduled tasks area. It is not recommended to run this task during peak usage hours.", "LabelMetadataDownloadLanguage": "Preferred download language:", "ButtonAutoScroll": "Auto-scroll", @@ -492,6 +493,7 @@ "HeaderSystemPaths": "System Paths", "LinkCommunity": "Community", "LinkGithub": "Github", + "LinkApi": "Api", "LinkApiDocumentation": "Api Documentation", "LabelFriendlyServerName": "Friendly server name:", "LabelFriendlyServerNameHelp": "This name will be used to identify this server. If left blank, the computer name will be used.", @@ -511,7 +513,7 @@ "LabelUseHttps": "Enable SSL", "LabelUseHttpsHelp": "Check to enable SSL hosting.", - "LabelHttpsPort": "Local http port:", + "LabelHttpsPort": "Local http port:", "LabelHttpsPortHelp": "The tcp port number that Media Browser's https server should bind to.", "LabelCertificatePath": "SSL Certificate path:", "LabelCertificatePathHelp": "The path on the filesystem to the ssl certificate pfx file.", diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 29c5304382..0d8b651904 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -130,12 +130,12 @@ namespace MediaBrowser.Server.Startup.Common { var list = new List { - "http://+:" + ServerConfigurationManager.Configuration.HttpServerPortNumber + "/" + WebApplicationName + "/" + "http://+:" + ServerConfigurationManager.Configuration.HttpServerPortNumber + "/" }; if (ServerConfigurationManager.Configuration.UseHttps) { - list.Add("https://+:" + ServerConfigurationManager.Configuration.HttpsPortNumber + "/" + WebApplicationName + "/"); + list.Add("https://+:" + ServerConfigurationManager.Configuration.HttpsPortNumber + "/"); } return list; @@ -472,7 +472,7 @@ namespace MediaBrowser.Server.Startup.Common _supportsNativeWebSocket = false; } - HttpServer = ServerFactory.CreateServer(this, LogManager, "Media Browser", WebApplicationName, "dashboard/index.html", false); + HttpServer = ServerFactory.CreateServer(this, LogManager, "Media Browser", "web/index.html", false); RegisterSingleInstance(HttpServer, false); progress.Report(10); @@ -810,7 +810,7 @@ namespace MediaBrowser.Server.Startup.Common { try { - ServerManager.Start(HttpServerUrlPrefixes, CertificatePath); + ServerManager.Start(HttpServerUrlPrefixes, ServerConfigurationManager.Configuration.CertificatePath); } catch (Exception ex) { @@ -977,8 +977,6 @@ namespace MediaBrowser.Server.Startup.Common CachePath = ApplicationPaths.CachePath, MacAddress = GetMacAddress(), HttpServerPortNumber = HttpServerPort, - UseHttps = UseHttps, - CertificatePath = CertificatePath, OperatingSystem = OperatingSystemDisplayName, CanSelfRestart = CanSelfRestart, CanSelfUpdate = CanSelfUpdate, @@ -1053,16 +1051,6 @@ namespace MediaBrowser.Server.Startup.Common get { return ServerConfigurationManager.Configuration.HttpServerPortNumber; } } - public bool UseHttps - { - get { return this.ServerConfigurationManager.Configuration.UseHttps; } - } - - public string CertificatePath - { - get { return this.ServerConfigurationManager.Configuration.CertificatePath; } - } - public int HttpsServerPort { get { return ServerConfigurationManager.Configuration.HttpsPortNumber; } diff --git a/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs b/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs index 97f6b89d78..bb78cc02f8 100644 --- a/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs +++ b/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs @@ -18,8 +18,7 @@ namespace MediaBrowser.Server.Startup.Common.Browser /// The logger. public static void OpenDashboardPage(string page, IServerApplicationHost appHost, ILogger logger) { - var url = "http://localhost:" + appHost.HttpServerPort + "/" + - appHost.WebApplicationName + "/web/" + page; + var url = "http://localhost:" + appHost.HttpServerPort + "/web/" + page; OpenUrl(url, logger); } @@ -69,8 +68,7 @@ namespace MediaBrowser.Server.Startup.Common.Browser /// The logger. public static void OpenSwagger(IServerApplicationHost appHost, ILogger logger) { - OpenUrl("http://localhost:" + appHost.HttpServerPort + "/" + - appHost.WebApplicationName + "/swagger-ui/index.html", logger); + OpenUrl("http://localhost:" + appHost.HttpServerPort + "/swagger-ui/index.html", logger); } /// diff --git a/MediaBrowser.ServerApplication/BackgroundServiceInstaller.cs b/MediaBrowser.ServerApplication/BackgroundServiceInstaller.cs index 27ddfeb955..15cab6c197 100644 --- a/MediaBrowser.ServerApplication/BackgroundServiceInstaller.cs +++ b/MediaBrowser.ServerApplication/BackgroundServiceInstaller.cs @@ -25,7 +25,7 @@ namespace MediaBrowser.ServerApplication Description = "The windows background service for Media Browser Server.", // Will ensure the network is available - ServicesDependedOn = new[] { "LanmanServer" } + ServicesDependedOn = new[] { "LanmanServer", "Tcpip" } }; // Microsoft didn't add the ability to add a -- cgit v1.2.3 From cefd565e67ce3b8225eb2fa8a7338dc4d85b458d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 18 Jan 2015 14:53:34 -0500 Subject: display server name in dashboard --- MediaBrowser.Api/Playback/BaseStreamingService.cs | 2 +- .../MediaEncoding/ISubtitleEncoder.cs | 3 +- MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs | 2 +- .../Subtitles/SubtitleEncoder.cs | 65 +++++++++++++--------- .../Configuration/ServerConfiguration.cs | 3 - MediaBrowser.Providers/Movies/MovieDbSearch.cs | 9 +-- .../HttpServer/HttpListenerHost.cs | 11 ---- .../HttpServer/ServerFactory.cs | 6 +- .../Localization/JavaScript/javascript.json | 3 + .../Localization/Server/server.json | 4 +- .../ApplicationHost.cs | 14 +---- 11 files changed, 52 insertions(+), 70 deletions(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 56dc38e91f..9253bc369b 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -629,7 +629,7 @@ namespace MediaBrowser.Api.Playback if (!string.IsNullOrEmpty(state.SubtitleStream.Language)) { - var charenc = SubtitleEncoder.GetSubtitleFileCharacterSet(subtitlePath, state.SubtitleStream.Language); + var charenc = SubtitleEncoder.GetSubtitleFileCharacterSet(subtitlePath); if (!string.IsNullOrEmpty(charenc)) { diff --git a/MediaBrowser.Controller/MediaEncoding/ISubtitleEncoder.cs b/MediaBrowser.Controller/MediaEncoding/ISubtitleEncoder.cs index 9e32fc32b0..37c2bf4d2e 100644 --- a/MediaBrowser.Controller/MediaEncoding/ISubtitleEncoder.cs +++ b/MediaBrowser.Controller/MediaEncoding/ISubtitleEncoder.cs @@ -47,9 +47,8 @@ namespace MediaBrowser.Controller.MediaEncoding /// Gets the subtitle language encoding parameter. /// /// The path. - /// The language. /// System.String. - string GetSubtitleFileCharacterSet(string path, string language); + string GetSubtitleFileCharacterSet(string path); } } diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index b357b04178..344eb9fbdf 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -1015,7 +1015,7 @@ namespace MediaBrowser.MediaEncoding.Encoder if (!string.IsNullOrEmpty(state.SubtitleStream.Language)) { - var charenc = SubtitleEncoder.GetSubtitleFileCharacterSet(subtitlePath, state.SubtitleStream.Language); + var charenc = SubtitleEncoder.GetSubtitleFileCharacterSet(subtitlePath); if (!string.IsNullOrEmpty(charenc)) { diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs index 10d8112ff0..4723525e38 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs @@ -149,22 +149,22 @@ namespace MediaBrowser.MediaEncoding.Subtitles 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, fileInfo.Item2); } - private async Task GetSubtitleStream(string path, string language, bool requiresCharset) + private async Task 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)) { 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); @@ -179,6 +179,23 @@ namespace MediaBrowser.MediaEncoding.Subtitles 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> GetReadableFile(string mediaPath, string[] inputFiles, MediaProtocol protocol, @@ -227,8 +244,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles // Convert var outputPath = GetSubtitleCachePath(mediaPath, subtitleStream.Index, ".srt"); - await ConvertTextSubtitleToSrt(subtitleStream.Path, outputPath, subtitleStream.Language, cancellationToken) - .ConfigureAwait(false); + await ConvertTextSubtitleToSrt(subtitleStream.Path, outputPath, cancellationToken).ConfigureAwait(false); return new Tuple(outputPath, "srt", true); } @@ -321,11 +337,9 @@ namespace MediaBrowser.MediaEncoding.Subtitles /// /// The input path. /// The output path. - /// The language. /// The cancellation token. /// Task. - public async Task ConvertTextSubtitleToSrt(string inputPath, string outputPath, string language, - CancellationToken cancellationToken) + public async Task ConvertTextSubtitleToSrt(string inputPath, string outputPath, CancellationToken cancellationToken) { var semaphore = GetLock(outputPath); @@ -335,7 +349,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles { if (!File.Exists(outputPath)) { - await ConvertTextSubtitleToSrtInternal(inputPath, outputPath, language).ConfigureAwait(false); + await ConvertTextSubtitleToSrtInternal(inputPath, outputPath).ConfigureAwait(false); } } finally @@ -349,15 +363,12 @@ namespace MediaBrowser.MediaEncoding.Subtitles /// /// The input path. /// The output path. - /// The language. /// Task. - /// - /// inputPath + /// inputPath /// or - /// outputPath - /// + /// outputPath /// - private async Task ConvertTextSubtitleToSrtInternal(string inputPath, string outputPath, string language) + private async Task ConvertTextSubtitleToSrtInternal(string inputPath, string outputPath) { if (string.IsNullOrEmpty(inputPath)) { @@ -371,9 +382,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles Directory.CreateDirectory(Path.GetDirectoryName(outputPath)); - var encodingParam = string.IsNullOrEmpty(language) - ? string.Empty - : GetSubtitleFileCharacterSet(inputPath, language); + var encodingParam = GetSubtitleFileCharacterSet(inputPath); if (!string.IsNullOrEmpty(encodingParam)) { @@ -696,10 +705,14 @@ namespace MediaBrowser.MediaEncoding.Subtitles /// Gets the subtitle language encoding param. /// /// The path. - /// The language. /// System.String. - 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); if (!string.IsNullOrWhiteSpace(charset)) @@ -712,11 +725,11 @@ namespace MediaBrowser.MediaEncoding.Subtitles return charset; } - if (GetFileEncoding(path).Equals(Encoding.UTF8)) - { - return string.Empty; - } + return null; + } + public string GetSubtitleFileCharacterSetFromLanguage(string language) + { switch (language.ToLower()) { case "pol": diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index e51cca7708..a2a909dcc5 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -191,8 +191,6 @@ namespace MediaBrowser.Model.Configuration public bool SaveMetadataHidden { get; set; } - public bool EnableWin8HttpListener { get; set; } - public NameValuePair[] ContentTypes { get; set; } public bool EnableAudioArchiveFiles { get; set; } @@ -214,7 +212,6 @@ namespace MediaBrowser.Model.Configuration EnableDashboardResourceMinification = true; EnableAutomaticRestart = true; - EnableWin8HttpListener = true; EnableUPnP = true; diff --git a/MediaBrowser.Providers/Movies/MovieDbSearch.cs b/MediaBrowser.Providers/Movies/MovieDbSearch.cs index ae176e4897..f1ccd1c304 100644 --- a/MediaBrowser.Providers/Movies/MovieDbSearch.cs +++ b/MediaBrowser.Providers/Movies/MovieDbSearch.cs @@ -183,14 +183,7 @@ namespace MediaBrowser.Providers.Movies if (DateTime.TryParseExact(result.release_date, "yyyy-MM-dd", EnUs, DateTimeStyles.None, out r)) { // Allow one year tolernace, preserve order from Tmdb - var variance = Math.Abs(r.Year - year.Value); - - if (variance <= 1) - { - return 0; - } - - return variance; + return Math.Abs(r.Year - year.Value); } } diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index 1d7e89d285..7022dc76d5 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -41,8 +41,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer private readonly ReaderWriterLockSlim _localEndpointLock = new ReaderWriterLockSlim(); - private readonly bool _supportsNativeWebSocket; - private string _certificatePath; /// @@ -67,12 +65,10 @@ namespace MediaBrowser.Server.Implementations.HttpServer ILogManager logManager, string serviceName, string defaultRedirectPath, - bool supportsNativeWebSocket, params Assembly[] assembliesWithServices) : base(serviceName, assembliesWithServices) { DefaultRedirectPath = defaultRedirectPath; - _supportsNativeWebSocket = supportsNativeWebSocket; _logger = logManager.GetLogger("HttpServer"); @@ -210,13 +206,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer 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); } diff --git a/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs index 73d7610601..d1222ab746 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs @@ -17,17 +17,15 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// The log manager. /// Name of the server. /// The default redirectpath. - /// if set to true [supports native web socket]. /// IHttpServer. public static IHttpServer CreateServer(IApplicationHost applicationHost, ILogManager logManager, string serverName, - string defaultRedirectpath, - bool supportsNativeWebSocket) + string defaultRedirectpath) { LogManager.LogFactory = new ServerLogFactory(logManager); - return new HttpListenerHost(applicationHost, logManager, serverName, defaultRedirectpath, supportsNativeWebSocket); + return new HttpListenerHost(applicationHost, logManager, serverName, defaultRedirectpath); } } } diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index ad7a0aef09..5235f46a9d 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -591,6 +591,8 @@ "MediaInfoStreamTypeEmbeddedImage": "Embedded Image", "MediaInfoRefFrames": "Ref frames", "TabPlayback": "Playback", + "TabNotifications": "Notifications", + "TabExpert": "Expert", "HeaderSelectCustomIntrosPath": "Select Custom Intros Path", "HeaderRateAndReview": "Rate and Review", "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.", "MessageRefreshQueued": "Refresh queued", "TabDevices": "Devices", + "TabExtras": "Extras", "DeviceLastUsedByUserName": "Last used by {0}", "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.", diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index 37948cb3f4..dc74c5f860 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -42,7 +42,7 @@ "ButtonTermsOfService": "Terms of Service", "HeaderDeveloperOptions": "Developer Options", "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", "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.", @@ -53,6 +53,7 @@ "HeaderAudio": "Audio", "HeaderVideo": "Video", "HeaderPaths": "Paths", + "TitleNotifications": "Notifications", "ButtonDonateWithPayPal": "Donate with PayPal", "OptionDetectArchiveFilesAsMedia": "Detect archive files as media", "OptionDetectArchiveFilesAsMediaHelp": "If enabled, files with .rar and .zip extensions will be detected as media files.", @@ -71,6 +72,7 @@ "FolderTypeTvShows": "TV", "FolderTypeInherit": "Inherit", "LabelContentType": "Content type:", + "TitleScheduledTasks": "Scheduled Tasks", "HeaderSetupLibrary": "Setup your media library", "ButtonAddMediaFolder": "Add media folder", "LabelFolderType": "Folder type:", diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index e15b60d479..3867fc243f 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -460,19 +460,7 @@ namespace MediaBrowser.Server.Startup.Common RegisterSingleInstance(() => new SearchEngine(LogManager, LibraryManager, UserManager)); - if (IsFirstRun) - { - 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); + HttpServer = ServerFactory.CreateServer(this, LogManager, "Media Browser", "web/index.html"); RegisterSingleInstance(HttpServer, false); progress.Report(10); -- cgit v1.2.3 From de76156391655f726b5655f727e06822398827ca Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 18 Jan 2015 23:29:57 -0500 Subject: rework hosting options --- MediaBrowser.Api/Playback/BaseStreamingService.cs | 2 +- MediaBrowser.Controller/Entities/Movies/BoxSet.cs | 26 +++++ MediaBrowser.Controller/IServerApplicationHost.cs | 14 ++- MediaBrowser.Controller/Net/IHttpServer.cs | 7 +- MediaBrowser.Dlna/Main/DlnaEntryPoint.cs | 2 +- MediaBrowser.Dlna/PlayTo/PlayToManager.cs | 2 +- .../Configuration/ServerConfiguration.cs | 4 +- MediaBrowser.Model/System/SystemInfo.cs | 10 +- .../BoxSets/BoxSetMetadataService.cs | 18 +-- MediaBrowser.Providers/TV/SeriesMetadataService.cs | 13 --- .../Collections/CollectionManager.cs | 6 +- .../Connect/ConnectManager.cs | 31 +++++- .../EntryPoints/ExternalPortForwarding.cs | 80 ++++++++------ .../HttpServer/HttpListenerHost.cs | 7 +- .../SocketSharp/WebSocketSharpListener.cs | 2 +- .../Localization/JavaScript/javascript.json | 5 +- .../Localization/Server/server.json | 15 ++- MediaBrowser.Server.Mono/Program.cs | 2 +- .../ApplicationHost.cs | 122 +++++++++++---------- .../Browser/BrowserLauncher.cs | 4 +- MediaBrowser.ServerApplication/MainStartup.cs | 1 - MediaBrowser.WebDashboard/Api/PackageCreator.cs | 1 + .../MediaBrowser.WebDashboard.csproj | 6 + 23 files changed, 224 insertions(+), 156 deletions(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 9253bc369b..6d403c8986 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -858,7 +858,7 @@ namespace MediaBrowser.Api.Playback if (SupportsThrottleWithStream) { var url = "http://localhost:" + ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(UsCulture) + "/videos/" + state.Request.Id + "/stream?static=true&Throttle=true&mediaSourceId=" + state.Request.MediaSourceId; - + url += "&transcodingJobId=" + transcodingJobId; return string.Format("\"{0}\"", url); diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index 4483c7b0f2..e48b8d8457 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -1,4 +1,5 @@ using MediaBrowser.Common.Progress; +using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; @@ -93,6 +94,31 @@ namespace MediaBrowser.Controller.Entities.Movies return list; } + /// + /// Updates the official rating based on content and returns true or false indicating if it changed. + /// + /// + public bool UpdateRatingToContent() + { + var currentOfficialRating = OfficialRating; + + // Gather all possible ratings + var ratings = RecursiveChildren + .Concat(GetLinkedChildren()) + .Where(i => i is Movie || i is Series) + .Select(i => i.OfficialRating) + .Where(i => !string.IsNullOrEmpty(i)) + .Distinct(StringComparer.OrdinalIgnoreCase) + .Select(i => new Tuple(i, LocalizationManager.GetRatingLevel(i))) + .OrderBy(i => i.Item2 ?? 1000) + .Select(i => i.Item1); + + OfficialRating = ratings.FirstOrDefault() ?? currentOfficialRating; + + return !string.Equals(currentOfficialRating ?? string.Empty, OfficialRating ?? string.Empty, + StringComparison.OrdinalIgnoreCase); + } + public override IEnumerable GetChildren(User user, bool includeLinkedChildren) { var children = base.GetChildren(user, includeLinkedChildren); diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.cs index 181c14debe..0b0f6d8287 100644 --- a/MediaBrowser.Controller/IServerApplicationHost.cs +++ b/MediaBrowser.Controller/IServerApplicationHost.cs @@ -28,7 +28,19 @@ namespace MediaBrowser.Controller /// Gets the HTTP server port. /// /// The HTTP server port. - int HttpServerPort { get; } + int HttpPort { get; } + + /// + /// Gets the HTTPS port. + /// + /// The HTTPS port. + int HttpsPort { get; } + + /// + /// Gets a value indicating whether [supports HTTPS]. + /// + /// true if [supports HTTPS]; otherwise, false. + bool EnableHttps { get; } /// /// Gets a value indicating whether this instance has update available. diff --git a/MediaBrowser.Controller/Net/IHttpServer.cs b/MediaBrowser.Controller/Net/IHttpServer.cs index d56bee009e..315b48b837 100644 --- a/MediaBrowser.Controller/Net/IHttpServer.cs +++ b/MediaBrowser.Controller/Net/IHttpServer.cs @@ -1,4 +1,3 @@ -using MediaBrowser.Common.Net; using System; using System.Collections.Generic; @@ -15,6 +14,12 @@ namespace MediaBrowser.Controller.Net /// The URL prefix. IEnumerable UrlPrefixes { get; } + /// + /// Gets the certificate path. + /// + /// The certificate path. + string CertificatePath { get; } + /// /// Starts the specified server name. /// diff --git a/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs b/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs index bcb539ac8d..c75f2e40cd 100644 --- a/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs +++ b/MediaBrowser.Dlna/Main/DlnaEntryPoint.cs @@ -167,7 +167,7 @@ namespace MediaBrowser.Dlna.Main var descriptorURI = "/dlna/" + guid.ToString("N") + "/description.xml"; - var uri = new Uri(string.Format("http://{0}:{1}{2}", address, _config.Configuration.HttpServerPortNumber, descriptorURI)); + var uri = new Uri(string.Format("http://{0}:{1}{2}", address, _appHost.HttpPort, descriptorURI)); var services = new List { diff --git a/MediaBrowser.Dlna/PlayTo/PlayToManager.cs b/MediaBrowser.Dlna/PlayTo/PlayToManager.cs index a60b5efa48..5e37417c66 100644 --- a/MediaBrowser.Dlna/PlayTo/PlayToManager.cs +++ b/MediaBrowser.Dlna/PlayTo/PlayToManager.cs @@ -152,7 +152,7 @@ namespace MediaBrowser.Dlna.PlayTo "http", localIp, - _appHost.HttpServerPort + _appHost.HttpPort ); } diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index a2a909dcc5..94bd30d0b4 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -36,7 +36,7 @@ namespace MediaBrowser.Model.Configuration /// Gets or sets a value indicating whether [use HTTPS]. /// /// true if [use HTTPS]; otherwise, false. - public bool UseHttps { get; set; } + public bool EnableHttps { get; set; } /// /// Gets or sets the value pointing to the file system where the ssl certiifcate is located.. @@ -206,7 +206,7 @@ namespace MediaBrowser.Model.Configuration PublicPort = 8096; HttpServerPortNumber = 8096; HttpsPortNumber = 8920; - UseHttps = false; + EnableHttps = false; CertificatePath = null; EnableDashboardResponseCaching = true; EnableDashboardResourceMinification = true; diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs index 0d0c0cddbe..ff9d822dd1 100644 --- a/MediaBrowser.Model/System/SystemInfo.cs +++ b/MediaBrowser.Model/System/SystemInfo.cs @@ -122,11 +122,11 @@ namespace MediaBrowser.Model.System /// The HTTP server port number. public int HttpServerPortNumber { get; set; } - /// - /// Gets or sets the value pointing to the file system where the ssl certiifcate is located. - /// - /// The value pointing to the file system where the ssl certiifcate is located. - public bool UseHttps { get; set; } + /// + /// Gets or sets a value indicating whether [enable HTTPS]. + /// + /// true if [enable HTTPS]; otherwise, false. + public bool EnableHttps { get; set; } /// /// Gets or sets the HTTPS server port number. diff --git a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs index 5e16ed69cf..e195df7dd7 100644 --- a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs +++ b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs @@ -60,23 +60,7 @@ namespace MediaBrowser.Providers.BoxSets { if (!item.LockedFields.Contains(MetadataFields.OfficialRating)) { - var currentOfficialRating = item.OfficialRating; - - // Gather all possible ratings - var ratings = item.RecursiveChildren - .Concat(item.GetLinkedChildren()) - .Where(i => i is Movie || i is Series) - .Select(i => i.OfficialRating) - .Where(i => !string.IsNullOrEmpty(i)) - .Distinct(StringComparer.OrdinalIgnoreCase) - .Select(i => new Tuple(i, _iLocalizationManager.GetRatingLevel(i))) - .OrderBy(i => i.Item2 ?? 1000) - .Select(i => i.Item1); - - item.OfficialRating = ratings.FirstOrDefault() ?? item.OfficialRating; - - if (!string.Equals(currentOfficialRating ?? string.Empty, item.OfficialRating ?? string.Empty, - StringComparison.OrdinalIgnoreCase)) + if (item.UpdateRatingToContent()) { updateType = updateType | ItemUpdateType.MetadataEdit; } diff --git a/MediaBrowser.Providers/TV/SeriesMetadataService.cs b/MediaBrowser.Providers/TV/SeriesMetadataService.cs index 62e5ff4fc6..e03104a23b 100644 --- a/MediaBrowser.Providers/TV/SeriesMetadataService.cs +++ b/MediaBrowser.Providers/TV/SeriesMetadataService.cs @@ -8,8 +8,6 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; using MediaBrowser.Providers.Manager; using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; namespace MediaBrowser.Providers.TV { @@ -61,16 +59,5 @@ namespace MediaBrowser.Providers.TV target.DisplaySpecialsWithSeasons = source.DisplaySpecialsWithSeasons; } } - - protected override async Task BeforeSave(Series item, bool isFullRefresh, ItemUpdateType currentUpdateType) - { - var updateType = await base.BeforeSave(item, isFullRefresh, currentUpdateType).ConfigureAwait(false); - - //var provider = new DummySeasonProvider(ServerConfigurationManager, Logger, _localization, _libraryManager); - - //await provider.Run(item, CancellationToken.None).ConfigureAwait(false); - - return updateType; - } } } diff --git a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs index 05efcaa1c9..28f3ed89cf 100644 --- a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs +++ b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs @@ -184,8 +184,9 @@ namespace MediaBrowser.Server.Implementations.Collections collection.LinkedChildren.AddRange(list); - await collection.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); + collection.UpdateRatingToContent(); + await collection.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); await collection.RefreshMetadata(CancellationToken.None).ConfigureAwait(false); if (fireEvent) @@ -274,8 +275,9 @@ namespace MediaBrowser.Server.Implementations.Collections } } - await collection.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); + collection.UpdateRatingToContent(); + await collection.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false); await collection.RefreshMetadata(CancellationToken.None).ConfigureAwait(false); EventHelper.FireEventIfNotNull(ItemsRemovedFromCollection, this, new CollectionModifiedEventArgs diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs index 194a8a4a23..d3a29f4205 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs @@ -78,7 +78,7 @@ namespace MediaBrowser.Server.Implementations.Connect if (!ip.StartsWith("http://", StringComparison.OrdinalIgnoreCase) && !ip.StartsWith("https://", StringComparison.OrdinalIgnoreCase)) { - ip = (_config.Configuration.UseHttps ? "https://" : "http://") + ip; + ip = (_appHost.EnableHttps ? "https://" : "http://") + ip; } return ip + ":" + _config.Configuration.PublicPort.ToString(CultureInfo.InvariantCulture); @@ -90,7 +90,7 @@ namespace MediaBrowser.Server.Implementations.Connect private string XApplicationValue { - get { return "Media Browser Server/" + _appHost.ApplicationVersion; } + get { return _appHost.Name + "/" + _appHost.ApplicationVersion; } } public ConnectManager(ILogger logger, @@ -112,6 +112,7 @@ namespace MediaBrowser.Server.Implementations.Connect _providerManager = providerManager; _userManager.UserConfigurationUpdated += _userManager_UserConfigurationUpdated; + _config.ConfigurationUpdated += _config_ConfigurationUpdated; LoadCachedData(); } @@ -164,8 +165,7 @@ namespace MediaBrowser.Server.Implementations.Connect } catch (HttpException ex) { - if (!ex.StatusCode.HasValue || - !new[] { HttpStatusCode.NotFound, HttpStatusCode.Unauthorized }.Contains(ex.StatusCode.Value)) + if (!ex.StatusCode.HasValue || !new[] { HttpStatusCode.NotFound, HttpStatusCode.Unauthorized }.Contains(ex.StatusCode.Value)) { throw; } @@ -179,6 +179,8 @@ namespace MediaBrowser.Server.Implementations.Connect await CreateServerRegistration(wanApiAddress, localAddress).ConfigureAwait(false); } + _lastReportedIdentifier = GetConnectReportingIdentifier(localAddress, wanApiAddress); + await RefreshAuthorizationsInternal(true, CancellationToken.None).ConfigureAwait(false); } catch (Exception ex) @@ -187,6 +189,27 @@ namespace MediaBrowser.Server.Implementations.Connect } } + private string _lastReportedIdentifier; + private string GetConnectReportingIdentifier() + { + return GetConnectReportingIdentifier(_appHost.GetSystemInfo().LocalAddress, WanApiAddress); + } + private string GetConnectReportingIdentifier(string localAddress, string remoteAddress) + { + return (remoteAddress ?? string.Empty) + (localAddress ?? string.Empty); + } + + void _config_ConfigurationUpdated(object sender, EventArgs e) + { + // If info hasn't changed, don't report anything + if (string.Equals(_lastReportedIdentifier, GetConnectReportingIdentifier(), StringComparison.OrdinalIgnoreCase)) + { + return; + } + + UpdateConnectInfo(); + } + private async Task CreateServerRegistration(string wanApiAddress, string localAddress) { if (string.IsNullOrWhiteSpace(wanApiAddress)) diff --git a/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs b/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs index e32068905d..4371739b76 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs @@ -5,6 +5,7 @@ using MediaBrowser.Model.Logging; using Mono.Nat; using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Text; using System.Threading; @@ -17,30 +18,44 @@ namespace MediaBrowser.Server.Implementations.EntryPoints private readonly ILogger _logger; private readonly IServerConfigurationManager _config; - private bool _isStarted; - private Timer _timer; + private bool _isStarted; public ExternalPortForwarding(ILogManager logmanager, IServerApplicationHost appHost, IServerConfigurationManager config) { _logger = logmanager.GetLogger("PortMapper"); _appHost = appHost; _config = config; + } - _config.ConfigurationUpdated += _config_ConfigurationUpdated; + private string _lastConfigIdentifier; + private string GetConfigIdentifier() + { + var values = new List(); + var config = _config.Configuration; + + values.Add(config.EnableUPnP.ToString()); + values.Add(config.PublicPort.ToString(CultureInfo.InvariantCulture)); + values.Add(_appHost.HttpPort.ToString(CultureInfo.InvariantCulture)); + values.Add(_appHost.HttpsPort.ToString(CultureInfo.InvariantCulture)); + values.Add(config.EnableHttps.ToString()); + values.Add(_appHost.EnableHttps.ToString()); + + return string.Join("|", values.ToArray()); } void _config_ConfigurationUpdated(object sender, EventArgs e) { - var enable = _config.Configuration.EnableUPnP; - - if (enable && !_isStarted) - { - Reload(); - } - else if (!enable && _isStarted) + _config.ConfigurationUpdated -= _config_ConfigurationUpdated; + + if (!string.Equals(_lastConfigIdentifier, GetConfigIdentifier(), StringComparison.OrdinalIgnoreCase)) { - DisposeNat(); + if (_isStarted) + { + DisposeNat(); + } + + Run(); } } @@ -48,31 +63,36 @@ namespace MediaBrowser.Server.Implementations.EntryPoints { //NatUtility.Logger = new LogWriter(_logger); - Reload(); + if (_config.Configuration.EnableUPnP) + { + Start(); + } + + _config.ConfigurationUpdated -= _config_ConfigurationUpdated; + _config.ConfigurationUpdated += _config_ConfigurationUpdated; } - private void Reload() + private void Start() { - if (_config.Configuration.EnableUPnP) - { - _logger.Debug("Starting NAT discovery"); + _logger.Debug("Starting NAT discovery"); - NatUtility.DeviceFound += NatUtility_DeviceFound; + NatUtility.DeviceFound += NatUtility_DeviceFound; - // Mono.Nat does never rise this event. The event is there however it is useless. - // You could remove it with no risk. - NatUtility.DeviceLost += NatUtility_DeviceLost; + // Mono.Nat does never rise this event. The event is there however it is useless. + // You could remove it with no risk. + NatUtility.DeviceLost += NatUtility_DeviceLost; - // it is hard to say what one should do when an unhandled exception is raised - // because there isn't anything one can do about it. Probably save a log or ignored it. - NatUtility.UnhandledException += NatUtility_UnhandledException; - NatUtility.StartDiscovery(); + // it is hard to say what one should do when an unhandled exception is raised + // because there isn't anything one can do about it. Probably save a log or ignored it. + NatUtility.UnhandledException += NatUtility_UnhandledException; + NatUtility.StartDiscovery(); - _isStarted = true; + _timer = new Timer(s => _createdRules = new List(), null, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5)); - _timer = new Timer(s => _createdRules = new List(), null, TimeSpan.FromMinutes(10), TimeSpan.FromMinutes(10)); - } + _lastConfigIdentifier = GetConfigIdentifier(); + + _isStarted = true; } void NatUtility_UnhandledException(object sender, UnhandledExceptionEventArgs e) @@ -124,9 +144,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints { _createdRules.Add(address); - var info = _appHost.GetSystemInfo(); - - CreatePortMap(device, info.HttpServerPortNumber, _config.Configuration.PublicPort); + CreatePortMap(device, _appHost.HttpPort, _config.Configuration.PublicPort); } } @@ -136,7 +154,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints device.CreatePortMap(new Mapping(Protocol.Tcp, privatePort, publicPort) { - Description = "Media Browser Server" + Description = _appHost.Name }); } diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index 7022dc76d5..f64e29e4db 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -3,7 +3,6 @@ using MediaBrowser.Common; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Logging; -using MediaBrowser.Server.Implementations.HttpServer.NetListener; using MediaBrowser.Server.Implementations.HttpServer.SocketSharp; using ServiceStack; using ServiceStack.Api.Swagger; @@ -41,7 +40,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer private readonly ReaderWriterLockSlim _localEndpointLock = new ReaderWriterLockSlim(); - private string _certificatePath; + public string CertificatePath { get; private set; } /// /// Gets the local end points. @@ -206,7 +205,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer private IHttpListener GetListener() { - return new WebSocketSharpListener(_logger, OnRequestReceived, _certificatePath); + return new WebSocketSharpListener(_logger, OnRequestReceived, CertificatePath); } private void WebSocketHandler(WebSocketConnectEventArgs args) @@ -434,7 +433,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer public void StartServer(IEnumerable urlPrefixes, string certificatePath) { - _certificatePath = certificatePath; + CertificatePath = certificatePath; UrlPrefixes = urlPrefixes.ToList(); Start(UrlPrefixes.First()); } diff --git a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs index 1cf523ad29..0c5c9e9bf1 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SocketSharp/WebSocketSharpListener.cs @@ -3,12 +3,12 @@ using MediaBrowser.Model.Logging; using MediaBrowser.Server.Implementations.Logging; using ServiceStack; using ServiceStack.Web; +using SocketHttpListener.Net; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using SocketHttpListener.Net; namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp { diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index 5235f46a9d..8e41dda307 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -192,9 +192,10 @@ "LabelPlayMethodDirectPlay": "Direct Playing", "LabelAudioCodec": "Audio: {0}", "LabelVideoCodec": "Video: {0}", + "LabelLocalAccessUrl": "Local access: {0}", "LabelRemoteAccessUrl": "Remote access: {0}", - "LabelRunningOnPort": "Running on port {0}.", - "LabelRunningOnHttpsPort": "Running on SSL port {0}.", + "LabelRunningOnPort": "Running on http port {0}.", + "LabelRunningOnPorts": "Running on http port {0}, and https port {1}.", "HeaderLatestFromChannel": "Latest from {0}", "ButtonDownload": "Download", "LabelUnknownLanaguage": "Unknown language", diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index dc74c5f860..683a5a6392 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -519,19 +519,17 @@ "LabelLocalHttpServerPortNumberHelp": "The tcp port number that Media Browser's http server should bind to.", "LabelPublicPort": "Public port number:", "LabelPublicPortHelp": "The public port number that should be mapped to the local port.", - - "LabelUseHttps": "Enable SSL", - "LabelUseHttpsHelp": "Check to enable SSL hosting.", - "LabelHttpsPort": "Local http port:", + "LabelEnableHttps": "Enable https for remote connections", + "LabelEnableHttpsHelp": "If enabled, the server will report an https url as it's external address.", + "LabelHttpsPort": "Local https port:", "LabelHttpsPortHelp": "The tcp port number that Media Browser's https server should bind to.", "LabelCertificatePath": "SSL Certificate path:", - "LabelCertificatePathHelp": "The path on the filesystem to the ssl certificate pfx file.", - + "LabelCertificatePathHelp": "The path on the file system to the ssl certificate .pfx file.", "LabelWebSocketPortNumber": "Web socket port number:", "LabelEnableAutomaticPortMap": "Enable automatic port mapping", "LabelEnableAutomaticPortMapHelp": "Attempt to automatically map the public port to the local port via UPnP. This may not work with some router models.", - "LabelExternalDDNS": "External DDNS:", - "LabelExternalDDNSHelp": "If you have a dynamic DNS enter it here. Media Browser apps will use it when connecting remotely.", + "LabelExternalDDNS": "External WAN Address:", + "LabelExternalDDNSHelp": "If you have a dynamic DNS enter it here. Media Browser apps will use it when connecting remotely. Leave empty for automatic detection.", "TabResume": "Resume", "TabWeather": "Weather", "TitleAppSettings": "App Settings", @@ -600,6 +598,7 @@ "ButtonRestart": "Restart", "ButtonShutdown": "Shutdown", "ButtonUpdateNow": "Update Now", + "TabHosting": "Hosting", "PleaseUpdateManually": "Please shutdown the server and update manually.", "NewServerVersionAvailable": "A new version of Media Browser Server is available!", "ServerUpToDate": "Media Browser Server is up to date", diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.cs index 1cd0b5ae6b..10a6c6fb91 100644 --- a/MediaBrowser.Server.Mono/Program.cs +++ b/MediaBrowser.Server.Mono/Program.cs @@ -78,7 +78,7 @@ namespace MediaBrowser.Server.Mono var nativeApp = new NativeApp(); - _appHost = new ApplicationHost(appPaths, logManager, options, fileSystem, "MBServer.Mono", false, nativeApp); + _appHost = new ApplicationHost(appPaths, logManager, options, fileSystem, "MBServer.Mono", nativeApp); if (options.ContainsOption("-v")) { Console.WriteLine (_appHost.ApplicationVersion.ToString()); diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index b71aa2adb6..16cf4258a4 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -110,38 +110,6 @@ namespace MediaBrowser.Server.Startup.Common get { return (IServerConfigurationManager)ConfigurationManager; } } - /// - /// Gets the name of the web application that can be used for url building. - /// All api urls will be of the form {protocol}://{host}:{port}/{appname}/... - /// - /// The name of the web application. - public string WebApplicationName - { - get { return "mediabrowser"; } - } - - /// - /// Gets the HTTP server URL prefix. - /// - /// The HTTP server URL prefix. - private IEnumerable HttpServerUrlPrefixes - { - get - { - var list = new List - { - "http://+:" + ServerConfigurationManager.Configuration.HttpServerPortNumber + "/" - }; - - if (ServerConfigurationManager.Configuration.UseHttps) - { - list.Add("https://+:" + ServerConfigurationManager.Configuration.HttpsPortNumber + "/"); - } - - return list; - } - } - /// /// Gets the configuration manager. /// @@ -230,8 +198,6 @@ namespace MediaBrowser.Server.Startup.Common private readonly StartupOptions _startupOptions; private readonly string _remotePackageName; - private bool _supportsNativeWebSocket; - internal INativeApp NativeApp { get; set; } /// @@ -242,20 +208,17 @@ namespace MediaBrowser.Server.Startup.Common /// The options. /// The file system. /// Name of the remote package. - /// if set to true [supports native web socket]. /// The native application. public ApplicationHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, string remotePackageName, - bool supportsNativeWebSocket, INativeApp nativeApp) : base(applicationPaths, logManager, fileSystem) { _startupOptions = options; _remotePackageName = remotePackageName; - _supportsNativeWebSocket = supportsNativeWebSocket; NativeApp = nativeApp; SetBaseExceptionMessage(); @@ -359,6 +322,9 @@ namespace MediaBrowser.Server.Startup.Common public override async Task Init(IProgress progress) { + HttpPort = ServerConfigurationManager.Configuration.HttpServerPortNumber; + HttpsPort = ServerConfigurationManager.Configuration.HttpsPortNumber; + PerformPreInitMigrations(); await base.Init(progress).ConfigureAwait(false); @@ -586,10 +552,10 @@ namespace MediaBrowser.Server.Startup.Common new FFmpegValidator(Logger, ApplicationPaths).Validate(info); - MediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"), - JsonSerializer, - info.EncoderPath, - info.ProbePath, + MediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"), + JsonSerializer, + info.EncoderPath, + info.ProbePath, info.Version, ServerConfigurationManager, FileSystemManager, @@ -791,6 +757,21 @@ namespace MediaBrowser.Server.Startup.Common SyncManager.AddParts(GetExports()); } + private IEnumerable GetUrlPrefixes() + { + var prefixes = new List + { + "http://+:" + ServerConfigurationManager.Configuration.HttpServerPortNumber + "/" + }; + + if (!string.IsNullOrWhiteSpace(ServerConfigurationManager.Configuration.CertificatePath)) + { + prefixes.Add("https://+:" + ServerConfigurationManager.Configuration.HttpsPortNumber + "/"); + } + + return prefixes; + } + /// /// Starts the server. /// @@ -798,7 +779,7 @@ namespace MediaBrowser.Server.Startup.Common { try { - ServerManager.Start(HttpServerUrlPrefixes, ServerConfigurationManager.Configuration.CertificatePath); + ServerManager.Start(GetUrlPrefixes(), ServerConfigurationManager.Configuration.CertificatePath); } catch (Exception ex) { @@ -817,11 +798,29 @@ namespace MediaBrowser.Server.Startup.Common { base.OnConfigurationUpdated(sender, e); - if (!HttpServer.UrlPrefixes.SequenceEqual(HttpServerUrlPrefixes, StringComparer.OrdinalIgnoreCase)) + var requiresRestart = false; + + // Don't do anything if these haven't been set yet + if (HttpPort != 0 && HttpsPort != 0) + { + // Need to restart if ports have changed + if (ServerConfigurationManager.Configuration.HttpServerPortNumber != HttpPort || + ServerConfigurationManager.Configuration.HttpsPortNumber != HttpsPort) + { + ServerConfigurationManager.Configuration.IsPortAuthorized = false; + ServerConfigurationManager.SaveConfiguration(); + + requiresRestart = true; + } + } + + if (!HttpServer.UrlPrefixes.SequenceEqual(GetUrlPrefixes(), StringComparer.OrdinalIgnoreCase)) { - ServerConfigurationManager.Configuration.IsPortAuthorized = false; - ServerConfigurationManager.SaveConfiguration(); + requiresRestart = true; + } + if (requiresRestart) + { NotifyPendingRestart(); } } @@ -953,7 +952,7 @@ namespace MediaBrowser.Server.Startup.Common HasPendingRestart = HasPendingRestart, Version = ApplicationVersion.ToString(), IsNetworkDeployed = CanSelfUpdate, - WebSocketPortNumber = HttpServerPort, + WebSocketPortNumber = HttpPort, FailedPluginAssemblies = FailedAssemblies.ToList(), InProgressInstallations = InstallationManager.CurrentInstallations.Select(i => i.Item1).ToList(), CompletedInstallations = InstallationManager.CompletedInstallations.ToList(), @@ -964,9 +963,9 @@ namespace MediaBrowser.Server.Startup.Common InternalMetadataPath = ApplicationPaths.InternalMetadataPath, CachePath = ApplicationPaths.CachePath, MacAddress = GetMacAddress(), - HttpServerPortNumber = HttpServerPort, - UseHttps = this.ServerConfigurationManager.Configuration.UseHttps, - HttpsPortNumber = HttpsServerPort, + HttpServerPortNumber = HttpPort, + EnableHttps = EnableHttps, + HttpsPortNumber = HttpsPort, OperatingSystem = OperatingSystemDisplayName, CanSelfRestart = CanSelfRestart, CanSelfUpdate = CanSelfUpdate, @@ -981,6 +980,19 @@ namespace MediaBrowser.Server.Startup.Common }; } + public bool EnableHttps + { + get + { + return SupportsHttps && ServerConfigurationManager.Configuration.EnableHttps; + } + } + + public bool SupportsHttps + { + get { return !string.IsNullOrWhiteSpace(HttpServer.CertificatePath); } + } + /// /// Gets the local ip address. /// @@ -994,7 +1006,7 @@ namespace MediaBrowser.Server.Startup.Common { address = string.Format("http://{0}:{1}", address, - ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(CultureInfo.InvariantCulture)); + HttpPort.ToString(CultureInfo.InvariantCulture)); } return address; @@ -1036,15 +1048,9 @@ namespace MediaBrowser.Server.Startup.Common } } - public int HttpServerPort - { - get { return ServerConfigurationManager.Configuration.HttpServerPortNumber; } - } + public int HttpPort { get; private set; } - public int HttpsServerPort - { - get { return ServerConfigurationManager.Configuration.HttpsPortNumber; } - } + public int HttpsPort { get; private set; } /// /// Gets the mac address. diff --git a/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs b/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs index bb78cc02f8..617ff4cae2 100644 --- a/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs +++ b/MediaBrowser.Server.Startup.Common/Browser/BrowserLauncher.cs @@ -18,7 +18,7 @@ namespace MediaBrowser.Server.Startup.Common.Browser /// The logger. public static void OpenDashboardPage(string page, IServerApplicationHost appHost, ILogger logger) { - var url = "http://localhost:" + appHost.HttpServerPort + "/web/" + page; + var url = "http://localhost:" + appHost.HttpPort + "/web/" + page; OpenUrl(url, logger); } @@ -68,7 +68,7 @@ namespace MediaBrowser.Server.Startup.Common.Browser /// The logger. public static void OpenSwagger(IServerApplicationHost appHost, ILogger logger) { - OpenUrl("http://localhost:" + appHost.HttpServerPort + "/swagger-ui/index.html", logger); + OpenUrl("http://localhost:" + appHost.HttpPort + "/swagger-ui/index.html", logger); } /// diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index 7532a2edd3..6e8774eea1 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -213,7 +213,6 @@ namespace MediaBrowser.ServerApplication options, fileSystem, "MBServer", - true, nativeApp); var initProgress = new Progress(); diff --git a/MediaBrowser.WebDashboard/Api/PackageCreator.cs b/MediaBrowser.WebDashboard/Api/PackageCreator.cs index 46616043b2..aec7a539ca 100644 --- a/MediaBrowser.WebDashboard/Api/PackageCreator.cs +++ b/MediaBrowser.WebDashboard/Api/PackageCreator.cs @@ -381,6 +381,7 @@ namespace MediaBrowser.WebDashboard.Api "channelsettings.js", "connectlogin.js", "dashboardgeneral.js", + "dashboardhosting.js", "dashboardpage.js", "device.js", "devices.js", diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index dbc701b6db..90a358d5cc 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -96,6 +96,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -105,6 +108,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest -- cgit v1.2.3 From b6d59c7688fc39d4689bc9070a7a99271d5b41ee Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 6 Feb 2015 00:39:07 -0500 Subject: fixes #1001 - Support downloading --- MediaBrowser.Api/Library/LibraryService.cs | 56 +++++++++++++++------- MediaBrowser.Api/Playback/BaseStreamingService.cs | 12 ++--- .../Playback/Progressive/VideoService.cs | 1 + MediaBrowser.Controller/Channels/Channel.cs | 5 ++ .../Channels/ChannelAudioItem.cs | 7 ++- .../Channels/ChannelFolderItem.cs | 12 +++-- .../Channels/ChannelVideoItem.cs | 7 ++- .../Entities/AggregateFolder.cs | 5 ++ MediaBrowser.Controller/Entities/Audio/Audio.cs | 7 +++ .../Entities/Audio/MusicArtist.cs | 12 +++-- .../Entities/Audio/MusicGenre.cs | 5 ++ MediaBrowser.Controller/Entities/BaseItem.cs | 32 +++++++++++++ .../Entities/BasePluginFolder.cs | 5 ++ MediaBrowser.Controller/Entities/Book.cs | 8 ++++ .../Entities/CollectionFolder.cs | 5 ++ MediaBrowser.Controller/Entities/Game.cs | 9 +++- MediaBrowser.Controller/Entities/GameGenre.cs | 5 ++ MediaBrowser.Controller/Entities/Genre.cs | 5 ++ MediaBrowser.Controller/Entities/IItemByName.cs | 4 ++ MediaBrowser.Controller/Entities/Movies/BoxSet.cs | 5 ++ MediaBrowser.Controller/Entities/Person.cs | 5 ++ MediaBrowser.Controller/Entities/Studio.cs | 5 ++ MediaBrowser.Controller/Entities/UserView.cs | 5 ++ MediaBrowser.Controller/Entities/Video.cs | 13 +++++ MediaBrowser.Controller/Entities/Year.cs | 5 ++ MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs | 4 ++ .../LiveTv/LiveTvAudioRecording.cs | 6 +++ MediaBrowser.Controller/LiveTv/LiveTvChannel.cs | 9 +++- MediaBrowser.Controller/LiveTv/LiveTvProgram.cs | 13 +++-- .../LiveTv/LiveTvVideoRecording.cs | 5 ++ MediaBrowser.Controller/Playlists/Playlist.cs | 7 ++- MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs | 8 ++-- MediaBrowser.Model/Dto/BaseItemDto.cs | 2 + MediaBrowser.Model/LiveTv/RecordingInfoDto.cs | 6 +++ MediaBrowser.Model/Querying/ItemFields.cs | 13 ++++- MediaBrowser.Model/Users/UserPolicy.cs | 5 +- .../Dto/DtoService.cs | 14 ++++++ .../HttpServer/Security/AuthService.cs | 26 +++++++++- .../LiveTv/LiveTvDtoService.cs | 4 ++ .../Localization/JavaScript/javascript.json | 2 + .../Localization/Server/server.json | 13 ++--- .../Sync/SyncJobProcessor.cs | 4 +- MediaBrowser.WebDashboard/Api/PackageCreator.cs | 1 - .../MediaBrowser.WebDashboard.csproj | 6 --- 44 files changed, 322 insertions(+), 66 deletions(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index f147234fe0..a97e2b52ee 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -226,6 +226,18 @@ namespace MediaBrowser.Api.Library public string TvdbId { get; set; } } + [Route("/Items/{Id}/Download", "GET", Summary = "Downloads item media")] + [Authenticated(Roles = "download")] + public class GetDownload + { + /// + /// Gets or sets the id. + /// + /// The id. + [ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] + public string Id { get; set; } + } + /// /// Class LibraryService /// @@ -273,7 +285,7 @@ namespace MediaBrowser.Api.Library } var dtoOptions = GetDtoOptions(request); - + var result = new ItemsResult { TotalRecordCount = items.Count, @@ -289,6 +301,28 @@ namespace MediaBrowser.Api.Library Task.Run(() => _libraryManager.ValidateMediaLibrary(new Progress(), CancellationToken.None)); } + public object Get(GetDownload request) + { + var item = _libraryManager.GetItemById(request.Id); + + if (!item.CanDelete()) + { + throw new ArgumentException("Item does not support downloading"); + } + + var headers = new Dictionary(); + + // Quotes are valid in linux. They'll possibly cause issues here + var filename = Path.GetFileName(item.Path).Replace("\"", string.Empty); + headers["Content-Disposition"] = string.Format("inline; filename=\"{0}\"", filename); + + return ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions + { + Path = item.Path, + ResponseHeaders = headers + }); + } + public object Get(GetFile request) { var item = _libraryManager.GetItemById(request.Id); @@ -347,7 +381,7 @@ namespace MediaBrowser.Api.Library var dtoOptions = GetDtoOptions(request); BaseItem parent = item.Parent; - + while (parent != null) { if (user != null) @@ -458,23 +492,9 @@ namespace MediaBrowser.Api.Library var auth = _authContext.GetAuthorizationInfo(Request); var user = _userManager.GetUserById(auth.UserId); - if (item is Playlist || item is BoxSet) + if (!item.CanDelete(user)) { - // For now this is allowed if user can see the playlist - } - else if (item is ILiveTvRecording) - { - if (!user.Policy.EnableLiveTvManagement) - { - throw new UnauthorizedAccessException(); - } - } - else - { - if (!user.Policy.EnableContentDeletion) - { - throw new UnauthorizedAccessException(); - } + throw new UnauthorizedAccessException(); } var task = _libraryManager.DeleteItem(item); diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 6d555e136a..d26ca27216 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -123,7 +123,7 @@ namespace MediaBrowser.Api.Playback private string GetOutputFilePath(StreamState state) { var folder = ServerConfigurationManager.ApplicationPaths.TranscodingTempPath; - + var outputFileExtension = GetOutputFileExtension(state); var data = GetCommandLineArguments("dummy\\dummy", "dummyTranscodingId", state, false); @@ -323,13 +323,13 @@ namespace MediaBrowser.Api.Playback switch (qualitySetting) { case EncodingQuality.HighSpeed: - param += " -crf 23"; + param += " -subq 0 -crf 23"; break; case EncodingQuality.HighQuality: - param += " -crf 20"; + param += " -subq 3 -crf 20"; break; case EncodingQuality.MaxQuality: - param += " -crf 18"; + param += " -subq 6 -crf 18"; break; } } @@ -507,7 +507,7 @@ namespace MediaBrowser.Api.Playback } } - return param; + return "-pix_fmt yuv420p " + param; } protected string GetAudioFilterParam(StreamState state, bool isHls) @@ -918,7 +918,7 @@ namespace MediaBrowser.Api.Playback if (SupportsThrottleWithStream) { var url = "http://localhost:" + ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(UsCulture) + "/videos/" + state.Request.Id + "/stream?static=true&Throttle=true&mediaSourceId=" + state.Request.MediaSourceId; - + url += "&transcodingJobId=" + transcodingJobId; return string.Format("\"{0}\"", url); diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs index 8924bb38f6..7e86b867f6 100644 --- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs +++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs @@ -97,6 +97,7 @@ namespace MediaBrowser.Api.Playback.Progressive if (string.Equals(Path.GetExtension(outputPath), ".mp4", StringComparison.OrdinalIgnoreCase)) { + // Comparison: https://github.com/jansmolders86/mediacenterjs/blob/master/lib/transcoding/desktop.js format = " -f mp4 -movflags frag_keyframe+empty_moov"; } diff --git a/MediaBrowser.Controller/Channels/Channel.cs b/MediaBrowser.Controller/Channels/Channel.cs index 87d257f12e..a482f45fe0 100644 --- a/MediaBrowser.Controller/Channels/Channel.cs +++ b/MediaBrowser.Controller/Channels/Channel.cs @@ -67,5 +67,10 @@ namespace MediaBrowser.Controller.Channels { return System.IO.Path.Combine(basePath, "channels", id.ToString("N"), "metadata"); } + + public override bool CanDelete() + { + return false; + } } } diff --git a/MediaBrowser.Controller/Channels/ChannelAudioItem.cs b/MediaBrowser.Controller/Channels/ChannelAudioItem.cs index d9330f8a30..91b2407bee 100644 --- a/MediaBrowser.Controller/Channels/ChannelAudioItem.cs +++ b/MediaBrowser.Controller/Channels/ChannelAudioItem.cs @@ -3,10 +3,10 @@ using MediaBrowser.Model.Channels; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Users; using System.Collections.Generic; using System.Linq; using System.Threading; -using MediaBrowser.Model.Users; namespace MediaBrowser.Controller.Channels { @@ -89,5 +89,10 @@ namespace MediaBrowser.Controller.Channels return list; } + + public override bool CanDelete() + { + return false; + } } } diff --git a/MediaBrowser.Controller/Channels/ChannelFolderItem.cs b/MediaBrowser.Controller/Channels/ChannelFolderItem.cs index dce9840eda..7ba73d126c 100644 --- a/MediaBrowser.Controller/Channels/ChannelFolderItem.cs +++ b/MediaBrowser.Controller/Channels/ChannelFolderItem.cs @@ -1,11 +1,10 @@ -using System; -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Channels; -using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Querying; +using MediaBrowser.Model.Users; +using System; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Model.Users; namespace MediaBrowser.Controller.Channels { @@ -76,5 +75,10 @@ namespace MediaBrowser.Controller.Channels { return System.IO.Path.Combine(basePath, "channels", ChannelId, Id.ToString("N")); } + + public override bool CanDelete() + { + return false; + } } } diff --git a/MediaBrowser.Controller/Channels/ChannelVideoItem.cs b/MediaBrowser.Controller/Channels/ChannelVideoItem.cs index e3fad56e90..d7d4483cd1 100644 --- a/MediaBrowser.Controller/Channels/ChannelVideoItem.cs +++ b/MediaBrowser.Controller/Channels/ChannelVideoItem.cs @@ -4,11 +4,11 @@ using MediaBrowser.Model.Channels; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Users; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Threading; -using MediaBrowser.Model.Users; namespace MediaBrowser.Controller.Channels { @@ -119,5 +119,10 @@ namespace MediaBrowser.Controller.Channels { return System.IO.Path.Combine(basePath, "channels", ChannelId, Id.ToString("N")); } + + public override bool CanDelete() + { + return false; + } } } diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs index af2cca5e63..66a0d551b2 100644 --- a/MediaBrowser.Controller/Entities/AggregateFolder.cs +++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs @@ -32,6 +32,11 @@ namespace MediaBrowser.Controller.Entities } } + public override bool CanDelete() + { + return false; + } + /// /// The _virtual children /// diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index 2dcea37bdf..a7b91b8681 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -113,6 +113,13 @@ namespace MediaBrowser.Controller.Entities.Audio } } + public override bool CanDownload() + { + var locationType = LocationType; + return locationType != LocationType.Remote && + locationType != LocationType.Virtual; + } + /// /// Gets or sets the artist. /// diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index 038aa98aae..e65d3c0e78 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -1,14 +1,13 @@ -using System.Runtime.Serialization; -using MediaBrowser.Common.Progress; -using MediaBrowser.Controller.Providers; +using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Users; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Model.Users; namespace MediaBrowser.Controller.Entities.Audio { @@ -35,6 +34,11 @@ namespace MediaBrowser.Controller.Entities.Audio get { return true; } } + public override bool CanDelete() + { + return !IsAccessedByName; + } + protected override IEnumerable ActualChildren { get diff --git a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs index 9689d7cce2..ed09560732 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs @@ -39,6 +39,11 @@ namespace MediaBrowser.Controller.Entities.Audio } } + public override bool CanDelete() + { + return false; + } + /// /// Gets a value indicating whether this instance is owned item. /// diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 4925bcd8ad..1443d99d32 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -239,6 +239,38 @@ namespace MediaBrowser.Controller.Entities get { return this.GetImagePath(ImageType.Primary); } } + public virtual bool CanDelete() + { + var locationType = LocationType; + return locationType != LocationType.Remote && + locationType != LocationType.Virtual; + } + + public virtual bool IsAuthorizedToDelete(User user) + { + return user.Policy.EnableContentDeletion; + } + + public bool CanDelete(User user) + { + return CanDelete() && IsAuthorizedToDelete(user); + } + + public virtual bool CanDownload() + { + return false; + } + + public virtual bool IsAuthorizedToDownload(User user) + { + return user.Policy.EnableContentDownloading; + } + + public bool CanDownload(User user) + { + return CanDownload() && IsAuthorizedToDownload(user); + } + /// /// Gets or sets the date created. /// diff --git a/MediaBrowser.Controller/Entities/BasePluginFolder.cs b/MediaBrowser.Controller/Entities/BasePluginFolder.cs index b30bd81b96..785c441d37 100644 --- a/MediaBrowser.Controller/Entities/BasePluginFolder.cs +++ b/MediaBrowser.Controller/Entities/BasePluginFolder.cs @@ -11,5 +11,10 @@ namespace MediaBrowser.Controller.Entities { get { return null; } } + + public override bool CanDelete() + { + return false; + } } } diff --git a/MediaBrowser.Controller/Entities/Book.cs b/MediaBrowser.Controller/Entities/Book.cs index 381b2101d2..e59db67a6a 100644 --- a/MediaBrowser.Controller/Entities/Book.cs +++ b/MediaBrowser.Controller/Entities/Book.cs @@ -2,6 +2,7 @@ using MediaBrowser.Model.Configuration; using System.Collections.Generic; using System.Linq; +using MediaBrowser.Model.Entities; using MediaBrowser.Model.Users; namespace MediaBrowser.Controller.Entities @@ -37,6 +38,13 @@ namespace MediaBrowser.Controller.Entities Tags = new List(); } + public override bool CanDownload() + { + var locationType = LocationType; + return locationType != LocationType.Remote && + locationType != LocationType.Virtual; + } + protected override bool GetBlockUnratedValue(UserPolicy config) { return config.BlockUnratedItems.Contains(UnratedItem.Book); diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index f82934a51b..a39357f2b0 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -35,6 +35,11 @@ namespace MediaBrowser.Controller.Entities } } + public override bool CanDelete() + { + return false; + } + public string CollectionType { get; set; } /// diff --git a/MediaBrowser.Controller/Entities/Game.cs b/MediaBrowser.Controller/Entities/Game.cs index 71642ea902..899e5628f1 100644 --- a/MediaBrowser.Controller/Entities/Game.cs +++ b/MediaBrowser.Controller/Entities/Game.cs @@ -1,10 +1,10 @@ using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Users; using System; using System.Collections.Generic; using System.Linq; -using MediaBrowser.Model.Users; namespace MediaBrowser.Controller.Entities { @@ -38,6 +38,13 @@ namespace MediaBrowser.Controller.Entities public List LocalTrailerIds { get; set; } public List RemoteTrailerIds { get; set; } + public override bool CanDownload() + { + var locationType = LocationType; + return locationType != LocationType.Remote && + locationType != LocationType.Virtual; + } + /// /// Gets or sets the tags. /// diff --git a/MediaBrowser.Controller/Entities/GameGenre.cs b/MediaBrowser.Controller/Entities/GameGenre.cs index 41ce0c12ab..b246b9388f 100644 --- a/MediaBrowser.Controller/Entities/GameGenre.cs +++ b/MediaBrowser.Controller/Entities/GameGenre.cs @@ -43,6 +43,11 @@ namespace MediaBrowser.Controller.Entities } } + public override bool CanDelete() + { + return false; + } + public IEnumerable GetTaggedItems(IEnumerable inputItems) { return inputItems.Where(GetItemFilter()); diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs index f581c55e83..e17a5c1d8b 100644 --- a/MediaBrowser.Controller/Entities/Genre.cs +++ b/MediaBrowser.Controller/Entities/Genre.cs @@ -34,6 +34,11 @@ namespace MediaBrowser.Controller.Entities } } + public override bool CanDelete() + { + return false; + } + /// /// Gets a value indicating whether this instance is owned item. /// diff --git a/MediaBrowser.Controller/Entities/IItemByName.cs b/MediaBrowser.Controller/Entities/IItemByName.cs index b48ad788fc..14b69b8fde 100644 --- a/MediaBrowser.Controller/Entities/IItemByName.cs +++ b/MediaBrowser.Controller/Entities/IItemByName.cs @@ -15,6 +15,10 @@ namespace MediaBrowser.Controller.Entities /// IEnumerable{BaseItem}. IEnumerable GetTaggedItems(IEnumerable inputItems); + /// + /// Gets the item filter. + /// + /// Func<BaseItem, System.Boolean>. Func GetItemFilter(); } diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index 7f74e33793..d874046efd 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -74,6 +74,11 @@ namespace MediaBrowser.Controller.Entities.Movies } } + public override bool IsAuthorizedToDelete(User user) + { + return true; + } + /// /// Gets the trailer ids. /// diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index 25509b1530..d8cb69ca17 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -45,6 +45,11 @@ namespace MediaBrowser.Controller.Entities } } + public override bool CanDelete() + { + return false; + } + /// /// Gets a value indicating whether this instance is owned item. /// diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs index 76193d6c42..31bbaf422e 100644 --- a/MediaBrowser.Controller/Entities/Studio.cs +++ b/MediaBrowser.Controller/Entities/Studio.cs @@ -40,6 +40,11 @@ namespace MediaBrowser.Controller.Entities } } + public override bool CanDelete() + { + return false; + } + /// /// Gets a value indicating whether this instance is owned item. /// diff --git a/MediaBrowser.Controller/Entities/UserView.cs b/MediaBrowser.Controller/Entities/UserView.cs index cd179eb428..5f7ca3d3f4 100644 --- a/MediaBrowser.Controller/Entities/UserView.cs +++ b/MediaBrowser.Controller/Entities/UserView.cs @@ -40,6 +40,11 @@ namespace MediaBrowser.Controller.Entities return result.Items; } + public override bool CanDelete() + { + return false; + } + public override IEnumerable GetRecursiveChildren(User user, Func filter) { var result = GetItems(new InternalItemsQuery diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 3abaf095c8..12c377c906 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -64,6 +64,19 @@ namespace MediaBrowser.Controller.Entities LinkedAlternateVersions = new List(); } + public override bool CanDownload() + { + if (VideoType == VideoType.HdDvd || VideoType == VideoType.Dvd || + VideoType == VideoType.BluRay) + { + return false; + } + + var locationType = LocationType; + return locationType != LocationType.Remote && + locationType != LocationType.Virtual; + } + [IgnoreDataMember] public override bool SupportsAddingToPlaylist { diff --git a/MediaBrowser.Controller/Entities/Year.cs b/MediaBrowser.Controller/Entities/Year.cs index 59a4bf16d3..cf3ad3b6ab 100644 --- a/MediaBrowser.Controller/Entities/Year.cs +++ b/MediaBrowser.Controller/Entities/Year.cs @@ -34,6 +34,11 @@ namespace MediaBrowser.Controller.Entities } } + public override bool CanDelete() + { + return false; + } + /// /// Gets a value indicating whether this instance is owned item. /// diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs b/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs index ba1cb30436..784cb6ea18 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs @@ -25,5 +25,9 @@ namespace MediaBrowser.Controller.LiveTv Task RefreshMetadata(MetadataRefreshOptions options, CancellationToken cancellationToken); PlayAccess GetPlayAccess(User user); + + bool CanDelete(); + + bool CanDelete(User user); } } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs index 8faaa895c2..9815066efc 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs @@ -1,4 +1,5 @@ using System.Runtime.Serialization; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; @@ -93,5 +94,10 @@ namespace MediaBrowser.Controller.LiveTv { return System.IO.Path.Combine(basePath, "livetv", Id.ToString("N")); } + + public override bool IsAuthorizedToDelete(User user) + { + return user.Policy.EnableLiveTvManagement; + } } } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs index 1948ce0d50..eaea6cfa45 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs @@ -1,5 +1,4 @@ -using System.Runtime.Serialization; -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; @@ -8,6 +7,7 @@ using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Users; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; namespace MediaBrowser.Controller.LiveTv { @@ -135,5 +135,10 @@ namespace MediaBrowser.Controller.LiveTv { return System.IO.Path.Combine(basePath, "livetv", Id.ToString("N"), "metadata"); } + + public override bool CanDelete() + { + return false; + } } } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs index a66aaad6f8..ee85ce20b0 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs @@ -1,13 +1,13 @@ -using System.Runtime.Serialization; -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.LiveTv; +using MediaBrowser.Model.Users; using System; +using System.Linq; +using System.Runtime.Serialization; using System.Threading; using System.Threading.Tasks; -using System.Linq; -using MediaBrowser.Model.Users; namespace MediaBrowser.Controller.LiveTv { @@ -215,5 +215,10 @@ namespace MediaBrowser.Controller.LiveTv { return System.IO.Path.Combine(basePath, "livetv", Id.ToString("N")); } + + public override bool CanDelete() + { + return false; + } } } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs index 34fe757a71..207684d55d 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs @@ -92,5 +92,10 @@ namespace MediaBrowser.Controller.LiveTv { return System.IO.Path.Combine(basePath, "livetv", Id.ToString("N")); } + + public override bool IsAuthorizedToDelete(User user) + { + return user.Policy.EnableLiveTvManagement; + } } } diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index 0f0c6a97ed..3479902cbd 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -1,7 +1,5 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; -using MediaBrowser.Controller.Entities.Movies; -using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Querying; using System; @@ -40,6 +38,11 @@ namespace MediaBrowser.Controller.Playlists } } + public override bool IsAuthorizedToDelete(User user) + { + return true; + } + public override bool IsSaveLocalMetadataEnabled() { return true; diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index 344eb9fbdf..5a00c3d3fe 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -631,13 +631,13 @@ namespace MediaBrowser.MediaEncoding.Encoder switch (qualitySetting) { case EncodingQuality.HighSpeed: - param += " -crf 23"; + param += " -subq 0 -crf 23"; break; case EncodingQuality.HighQuality: - param += " -crf 20"; + param += " -subq 3 -crf 20"; break; case EncodingQuality.MaxQuality: - param += " -crf 18"; + param += " -subq 6 -crf 18"; break; } } @@ -740,7 +740,7 @@ namespace MediaBrowser.MediaEncoding.Encoder param += " -level " + state.Options.Level.Value.ToString(UsCulture); } - return param; + return "-pix_fmt yuv420p " + param; } protected string GetVideoBitrateParam(EncodingJob state, string videoCodec, bool isHls) diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs index c1a34a7f61..be3cd99be8 100644 --- a/MediaBrowser.Model/Dto/BaseItemDto.cs +++ b/MediaBrowser.Model/Dto/BaseItemDto.cs @@ -56,6 +56,8 @@ namespace MediaBrowser.Model.Dto public int? AirsBeforeEpisodeNumber { get; set; } public int? AbsoluteEpisodeNumber { get; set; } public bool? DisplaySpecialsWithSeasons { get; set; } + public bool? CanDelete { get; set; } + public bool? CanDownload { get; set; } public string PreferredMetadataLanguage { get; set; } public string PreferredMetadataCountryCode { get; set; } diff --git a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs b/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs index 15378a9af1..a6cd85d8d3 100644 --- a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs @@ -99,6 +99,12 @@ namespace MediaBrowser.Model.LiveTv /// The path. public string Path { get; set; } + /// + /// Gets or sets a value indicating whether this instance can delete. + /// + /// null if [can delete] contains no value, true if [can delete]; otherwise, false. + public bool? CanDelete { get; set; } + /// /// Overview of the recording. /// diff --git a/MediaBrowser.Model/Querying/ItemFields.cs b/MediaBrowser.Model/Querying/ItemFields.cs index 5018f8e516..7a91d77fff 100644 --- a/MediaBrowser.Model/Querying/ItemFields.cs +++ b/MediaBrowser.Model/Querying/ItemFields.cs @@ -1,5 +1,4 @@ - -namespace MediaBrowser.Model.Querying +namespace MediaBrowser.Model.Querying { /// /// Used to control the data that gets attached to DtoBaseItems @@ -26,6 +25,16 @@ namespace MediaBrowser.Model.Querying /// Budget, + /// + /// The can delete + /// + CanDelete, + + /// + /// The can download + /// + CanDownload, + /// /// The chapters /// diff --git a/MediaBrowser.Model/Users/UserPolicy.cs b/MediaBrowser.Model/Users/UserPolicy.cs index cdc5077b02..9606cbe3fe 100644 --- a/MediaBrowser.Model/Users/UserPolicy.cs +++ b/MediaBrowser.Model/Users/UserPolicy.cs @@ -42,7 +42,8 @@ namespace MediaBrowser.Model.Users public bool EnableMediaPlayback { get; set; } public bool EnableContentDeletion { get; set; } - + public bool EnableContentDownloading { get; set; } + /// /// Gets or sets a value indicating whether [enable synchronize]. /// @@ -80,6 +81,8 @@ namespace MediaBrowser.Model.Users EnabledDevices = new string[] { }; EnableAllDevices = true; + + EnableContentDownloading = true; } } } diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 7b36321f18..75bddda723 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -284,6 +284,20 @@ namespace MediaBrowser.Server.Implementations.Dto AttachLinkedChildImages(dto, playlist, user, options); } + if (fields.Contains(ItemFields.CanDelete)) + { + dto.CanDelete = user == null + ? item.CanDelete() + : item.CanDelete(user); + } + + if (fields.Contains(ItemFields.CanDownload)) + { + dto.CanDownload = user == null + ? item.CanDownload() + : item.CanDownload(user); + } + return dto; } diff --git a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs index c374a31b36..77953ee43b 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs @@ -74,7 +74,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security ValidateUserAccess(user, request, authAttribtues, auth); } - if (!IsExemptFromRoles(auth, authAttribtues)) + var info = (AuthenticationInfo)request.Items["OriginalAuthenticationInfo"]; + + if (!IsExemptFromRoles(auth, authAttribtues, info)) { var roles = authAttribtues.GetRoles().ToList(); @@ -142,7 +144,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security StringComparer.OrdinalIgnoreCase); } - private bool IsExemptFromRoles(AuthorizationInfo auth, IAuthenticationAttributes authAttribtues) + private bool IsExemptFromRoles(AuthorizationInfo auth, IAuthenticationAttributes authAttribtues, AuthenticationInfo tokenInfo) { if (!_config.Configuration.IsStartupWizardCompleted && authAttribtues.AllowBeforeStartupWizard) @@ -150,6 +152,16 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security return true; } + if (string.IsNullOrWhiteSpace(auth.Token)) + { + return true; + } + + if (tokenInfo != null && string.IsNullOrWhiteSpace(tokenInfo.UserId)) + { + return true; + } + return false; } @@ -175,6 +187,16 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security }; } } + if (roles.Contains("download", StringComparer.OrdinalIgnoreCase)) + { + if (user == null || !user.Policy.EnableContentDownloading) + { + throw new SecurityException("User does not have download access.") + { + SecurityExceptionType = SecurityExceptionType.Unauthenticated + }; + } + } } private bool IsValidConnectKey(string token) diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs index b3066b460f..f1bb5c13ae 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs @@ -229,6 +229,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv ServerId = _appHost.SystemId }; + dto.CanDelete = user == null + ? recording.CanDelete() + : recording.CanDelete(user); + dto.MediaStreams = dto.MediaSources.SelectMany(i => i.MediaStreams).ToList(); if (info.Status == RecordingStatus.InProgress) diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index 3fddf274c6..184a7f9a4e 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -48,6 +48,7 @@ "LabelFailed": "(failed)", "ButtonHelp": "Help", "ButtonSave": "Save", + "ButtonDownload": "Download", "SyncJobStatusQueued": "Queued", "SyncJobStatusConverting": "Converting", "SyncJobStatusFailed": "Failed", @@ -56,6 +57,7 @@ "SyncJobStatusReadyToTransfer": "Ready to Transfer", "SyncJobStatusTransferring": "Transferring", "SyncJobStatusCompletedWithError": "Synced with errors", + "SyncJobItemStatusReadyToTransfer": "Ready to Transfer", "LabelCollection": "Collection", "HeaderAddToCollection": "Add to Collection", "NewCollectionNameExample": "Example: Star Wars Collection", diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index aaf05d1ff5..c280b32ea2 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -285,10 +285,10 @@ "ButtonHelp": "Help", "OptionAllowUserToManageServer": "Allow this user to manage the server", "HeaderFeatureAccess": "Feature Access", - "OptionAllowMediaPlayback": "Allow media playback", - "OptionAllowBrowsingLiveTv": "Allow browsing of live tv", - "OptionAllowDeleteLibraryContent": "Allow deletion of library content", - "OptionAllowManageLiveTv": "Allow management of live tv recordings", + "OptionAllowMediaPlayback": "Media playback", + "OptionAllowBrowsingLiveTv": "Live TV", + "OptionAllowDeleteLibraryContent": "Media deletion", + "OptionAllowManageLiveTv": "Live TV recording management", "OptionAllowRemoteControlOthers": "Allow remote control of other users", "OptionAllowRemoteSharedDevices": "Allow remote control of shared devices", "OptionAllowRemoteSharedDevicesHelp": "Dlna devices are considered shared until a user begins controlling it.", @@ -1133,7 +1133,7 @@ "ViewTypeLiveTvRecordingGroups": "Recordings", "ViewTypeLiveTvChannels": "Channels", "LabelEasyPinCode": "Easy pin code:", - "EasyPasswordHelp": "Your easy pin code is used for offline access with supported Media Browser apps, and can also be used for easy in-network sign in.", + "EasyPasswordHelp": "Your easy pin code is used for offline access with supported Media Browser apps, and can also be used for easy in-network sign in.", "LabelInNetworkSignInWithEasyPassword": "Enable in-network sign in with my easy pin code", "LabelInNetworkSignInWithEasyPasswordHelp": "If enabled, you'll be able to use your easy pin code to sign in to Media Browser apps from inside your home network. Your regular password will only be needed away from home. If the pin code is left blank, you won't need a password within your home network.", "HeaderPassword": "Password", @@ -1362,7 +1362,8 @@ "LabelEnableSingleImageInDidlLimitHelp": "Some devices will not render properly if multiple images are embedded within Didl.", "TabActivity": "Activity", "TitleSync": "Sync", - "OptionAllowSyncContent": "Allow syncing media to devices", + "OptionAllowSyncContent": "Sync", + "OptionAllowContentDownloading": "Media downloading", "NameSeasonUnknown": "Season Unknown", "NameSeasonNumber": "Season {0}", "LabelNewUserNameHelp": "Usernames can contain letters (a-z), numbers (0-9), dashes (-), underscores (_), apostrophes ('), and periods (.)", diff --git a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs index e418448db7..9ecb80f3ba 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs @@ -311,8 +311,10 @@ namespace MediaBrowser.Server.Implementations.Sync var itemByName = item as IItemByName; if (itemByName != null) { + var itemByNameFilter = itemByName.GetItemFilter(); + return user.RootFolder - .GetRecursiveChildren(user, itemByName.GetItemFilter()); + .GetRecursiveChildren(user, i => !i.IsFolder && itemByNameFilter(i)); } if (item.IsFolder) diff --git a/MediaBrowser.WebDashboard/Api/PackageCreator.cs b/MediaBrowser.WebDashboard/Api/PackageCreator.cs index 3eb98e95d0..8bf0050219 100644 --- a/MediaBrowser.WebDashboard/Api/PackageCreator.cs +++ b/MediaBrowser.WebDashboard/Api/PackageCreator.cs @@ -414,7 +414,6 @@ namespace MediaBrowser.WebDashboard.Api "indexpage.js", "itembynamedetailpage.js", "itemdetailpage.js", - "itemgallery.js", "itemlistpage.js", "librarypathmapping.js", "reports.js", diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 34b0e9e88e..bc610b7b65 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -1656,9 +1656,6 @@ - - PreserveNewest - PreserveNewest @@ -1707,9 +1704,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest -- cgit v1.2.3 From 504e2099e2f11203c48dff94a67ec797a454d459 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 6 Feb 2015 22:25:23 -0500 Subject: update dlna profiles --- MediaBrowser.Api/UserLibrary/ArtistsService.cs | 4 +- MediaBrowser.Api/UserLibrary/ItemsService.cs | 45 +++++----------------- MediaBrowser.Controller/Entities/Folder.cs | 17 ++++++-- MediaBrowser.Dlna/Profiles/Xml/Default.xml | 2 - MediaBrowser.Dlna/Profiles/Xml/Denon AVR.xml | 2 - MediaBrowser.Dlna/Profiles/Xml/DirecTV HD-DVR.xml | 2 - .../Profiles/Xml/Dish Hopper-Joey.xml | 2 - MediaBrowser.Dlna/Profiles/Xml/LG Smart TV.xml | 2 - MediaBrowser.Dlna/Profiles/Xml/Linksys DMA2100.xml | 2 - MediaBrowser.Dlna/Profiles/Xml/MediaMonkey.xml | 2 - MediaBrowser.Dlna/Profiles/Xml/Panasonic Viera.xml | 2 - MediaBrowser.Dlna/Profiles/Xml/Popcorn Hour.xml | 2 - .../Profiles/Xml/Samsung Smart TV.xml | 2 - .../Profiles/Xml/Sony Blu-ray Player 2013.xml | 2 - .../Profiles/Xml/Sony Blu-ray Player.xml | 2 - .../Profiles/Xml/Sony Bravia (2010).xml | 2 - .../Profiles/Xml/Sony Bravia (2011).xml | 2 - .../Profiles/Xml/Sony Bravia (2012).xml | 2 - .../Profiles/Xml/Sony Bravia (2013).xml | 2 - .../Profiles/Xml/Sony PlayStation 3.xml | 2 - MediaBrowser.Dlna/Profiles/Xml/WDTV Live.xml | 2 - MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml | 2 - MediaBrowser.Dlna/Profiles/Xml/Xbox One.xml | 2 - MediaBrowser.Dlna/Profiles/Xml/foobar2000.xml | 2 - MediaBrowser.Model/ApiClient/IApiClient.cs | 31 +++++++++------ MediaBrowser.Model/Dlna/AudioOptions.cs | 11 ++++++ MediaBrowser.Model/Dlna/DeviceProfile.cs | 2 - MediaBrowser.Model/Dlna/StreamBuilder.cs | 9 +++-- .../HttpServer/Security/AuthService.cs | 11 +++++- .../Persistence/SqliteItemRepository.cs | 30 +++++++++++++++ .../Sync/SyncRepository.cs | 23 +++++++++++ 31 files changed, 124 insertions(+), 101 deletions(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer') diff --git a/MediaBrowser.Api/UserLibrary/ArtistsService.cs b/MediaBrowser.Api/UserLibrary/ArtistsService.cs index 2ab08fd8d3..121d395ba3 100644 --- a/MediaBrowser.Api/UserLibrary/ArtistsService.cs +++ b/MediaBrowser.Api/UserLibrary/ArtistsService.cs @@ -130,8 +130,8 @@ namespace MediaBrowser.Api.UserLibrary if (request is GetAlbumArtists) { return items + .Where(i => !i.IsFolder) .OfType() - .Where(i => !(i is MusicAlbum)) .SelectMany(i => i.AlbumArtists) .Distinct(StringComparer.OrdinalIgnoreCase) .Select(name => @@ -150,8 +150,8 @@ namespace MediaBrowser.Api.UserLibrary } return items + .Where(i => !i.IsFolder) .OfType() - .Where(i => !(i is MusicAlbum)) .SelectMany(i => i.AllArtists) .Distinct(StringComparer.OrdinalIgnoreCase) .Select(name => diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index 15b1f6dba4..9b5ef3a981 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -169,8 +169,6 @@ namespace MediaBrowser.Api.UserLibrary [ApiMember(Name = "ExcludeLocationTypes", Description = "Optional. If specified, results will be filtered based on LocationType. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] public string ExcludeLocationTypes { get; set; } - public bool IncludeIndexContainers { get; set; } - [ApiMember(Name = "IsMissing", Description = "Optional filter by items that are missing episodes or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] public bool? IsMissing { get; set; } @@ -396,52 +394,29 @@ namespace MediaBrowser.Api.UserLibrary else if (request.Recursive) { - if (user == null) - { - items = ((Folder)item).GetRecursiveChildren(); + var result = await ((Folder)item).GetItems(GetItemsQuery(request, user)).ConfigureAwait(false); - items = _libraryManager.ReplaceVideosWithPrimaryVersions(items); - } - else - { - var result = await ((Folder)item).GetItems(GetItemsQuery(request, user)); - - return new Tuple, bool>(result, true); - } + return new Tuple, bool>(result, true); } else { if (user == null) { - items = ((Folder)item).Children; + var result = await ((Folder)item).GetItems(GetItemsQuery(request, null)).ConfigureAwait(false); - items = _libraryManager.ReplaceVideosWithPrimaryVersions(items); + return new Tuple, bool>(result, true); } - else - { - var userRoot = item as UserRootFolder; - if (userRoot == null) - { - var result = await ((Folder)item).GetItems(GetItemsQuery(request, user)); + var userRoot = item as UserRootFolder; - return new Tuple, bool>(result, true); - } + if (userRoot == null) + { + var result = await ((Folder)item).GetItems(GetItemsQuery(request, user)).ConfigureAwait(false); - items = ((Folder)item).GetChildren(user, true); + return new Tuple, bool>(result, true); } - } - - if (request.IncludeIndexContainers) - { - var list = items.ToList(); - - var containers = list.Select(i => i.IndexContainer) - .Where(i => i != null); - - list.AddRange(containers); - items = list.Distinct(); + items = ((Folder)item).GetChildren(user, true); } return new Tuple, bool>(new QueryResult diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 50f33f5c06..e85dee354a 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -787,9 +787,20 @@ namespace MediaBrowser.Controller.Entities Func filter = i => UserViewBuilder.Filter(i, user, query, UserDataManager, LibraryManager); - var items = query.Recursive - ? GetRecursiveChildren(user, filter) - : GetChildren(user, true).Where(filter); + IEnumerable items; + + if (query.User == null) + { + items = query.Recursive + ? GetRecursiveChildren(filter) + : Children.Where(filter); + } + else + { + items = query.Recursive + ? GetRecursiveChildren(user, filter) + : GetChildren(user, true).Where(filter); + } var result = PostFilterAndSort(items, query); diff --git a/MediaBrowser.Dlna/Profiles/Xml/Default.xml b/MediaBrowser.Dlna/Profiles/Xml/Default.xml index b70cc10c2e..7062afc69a 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Default.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Default.xml @@ -26,8 +26,6 @@ 0 false false - false - false false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Denon AVR.xml b/MediaBrowser.Dlna/Profiles/Xml/Denon AVR.xml index 6250e0f0e6..9ff1ae8336 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Denon AVR.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Denon AVR.xml @@ -31,8 +31,6 @@ 0 false false - false - false false diff --git a/MediaBrowser.Dlna/Profiles/Xml/DirecTV HD-DVR.xml b/MediaBrowser.Dlna/Profiles/Xml/DirecTV HD-DVR.xml index 0079b5f8d8..746b7f5c40 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/DirecTV HD-DVR.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/DirecTV HD-DVR.xml @@ -32,8 +32,6 @@ 10 true true - false - false false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Dish Hopper-Joey.xml b/MediaBrowser.Dlna/Profiles/Xml/Dish Hopper-Joey.xml index d338b2b6d4..4a70e3d4c5 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Dish Hopper-Joey.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Dish Hopper-Joey.xml @@ -33,8 +33,6 @@ 0 false false - false - false false diff --git a/MediaBrowser.Dlna/Profiles/Xml/LG Smart TV.xml b/MediaBrowser.Dlna/Profiles/Xml/LG Smart TV.xml index ba72f63065..471917a13f 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/LG Smart TV.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/LG Smart TV.xml @@ -32,8 +32,6 @@ 10 false false - false - false false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Linksys DMA2100.xml b/MediaBrowser.Dlna/Profiles/Xml/Linksys DMA2100.xml index 829ce70686..5fe441945b 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Linksys DMA2100.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Linksys DMA2100.xml @@ -30,8 +30,6 @@ 0 false false - false - false false diff --git a/MediaBrowser.Dlna/Profiles/Xml/MediaMonkey.xml b/MediaBrowser.Dlna/Profiles/Xml/MediaMonkey.xml index 78ba4aba39..35775892c8 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/MediaMonkey.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/MediaMonkey.xml @@ -32,8 +32,6 @@ 0 false false - false - false false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Panasonic Viera.xml b/MediaBrowser.Dlna/Profiles/Xml/Panasonic Viera.xml index 88160b0ce3..36c5289298 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Panasonic Viera.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Panasonic Viera.xml @@ -33,8 +33,6 @@ 10 false false - false - false false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Popcorn Hour.xml b/MediaBrowser.Dlna/Profiles/Xml/Popcorn Hour.xml index d6acd65caf..0749dbeac7 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Popcorn Hour.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Popcorn Hour.xml @@ -26,8 +26,6 @@ 0 false false - false - false false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Samsung Smart TV.xml b/MediaBrowser.Dlna/Profiles/Xml/Samsung Smart TV.xml index bd113b9c7d..9e61df43ed 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Samsung Smart TV.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Samsung Smart TV.xml @@ -32,8 +32,6 @@ 0 false false - false - false false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player 2013.xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player 2013.xml index 3104f5c688..91aa767bee 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player 2013.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player 2013.xml @@ -32,8 +32,6 @@ 0 false false - false - false false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player.xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player.xml index 57a32607ed..a6ea108408 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Blu-ray Player.xml @@ -34,8 +34,6 @@ 0 false false - false - false false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2010).xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2010).xml index b7325c53ce..0c3bdc4c5f 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2010).xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2010).xml @@ -34,8 +34,6 @@ 0 false false - false - false false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2011).xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2011).xml index 59157baddd..0269c05c16 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2011).xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2011).xml @@ -34,8 +34,6 @@ 0 false false - false - false false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2012).xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2012).xml index d2d9c181ff..9aa614faae 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2012).xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2012).xml @@ -34,8 +34,6 @@ 0 false false - false - false false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2013).xml b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2013).xml index 7b3d95b9d8..231db2091f 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2013).xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Sony Bravia (2013).xml @@ -34,8 +34,6 @@ 0 false false - false - false false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Sony PlayStation 3.xml b/MediaBrowser.Dlna/Profiles/Xml/Sony PlayStation 3.xml index 454dabe5d4..153b66be81 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Sony PlayStation 3.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Sony PlayStation 3.xml @@ -34,8 +34,6 @@ 0 false false - false - false false diff --git a/MediaBrowser.Dlna/Profiles/Xml/WDTV Live.xml b/MediaBrowser.Dlna/Profiles/Xml/WDTV Live.xml index 2829bfb473..d51669cfb8 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/WDTV Live.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/WDTV Live.xml @@ -33,8 +33,6 @@ 5 false false - false - false false diff --git a/MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml b/MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml index 76e4a6c31f..96b728bdc1 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Xbox 360.xml @@ -33,8 +33,6 @@ 40 true true - false - false true diff --git a/MediaBrowser.Dlna/Profiles/Xml/Xbox One.xml b/MediaBrowser.Dlna/Profiles/Xml/Xbox One.xml index c8c0a52024..063cebebc3 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/Xbox One.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/Xbox One.xml @@ -33,8 +33,6 @@ 40 false false - false - false false diff --git a/MediaBrowser.Dlna/Profiles/Xml/foobar2000.xml b/MediaBrowser.Dlna/Profiles/Xml/foobar2000.xml index 7a8f3a09d4..de7c03c481 100644 --- a/MediaBrowser.Dlna/Profiles/Xml/foobar2000.xml +++ b/MediaBrowser.Dlna/Profiles/Xml/foobar2000.xml @@ -32,8 +32,6 @@ 0 false false - false - false false diff --git a/MediaBrowser.Model/ApiClient/IApiClient.cs b/MediaBrowser.Model/ApiClient/IApiClient.cs index 03802fc28f..8b489453ec 100644 --- a/MediaBrowser.Model/ApiClient/IApiClient.cs +++ b/MediaBrowser.Model/ApiClient/IApiClient.cs @@ -41,7 +41,7 @@ namespace MediaBrowser.Model.ApiClient /// Occurs when [authenticated]. /// event EventHandler> Authenticated; - + /// /// Gets the API URL. /// @@ -201,7 +201,7 @@ namespace MediaBrowser.Model.ApiClient /// The cancellation token. /// Task<HttpResponse>. Task GetResponse(string url, CancellationToken cancellationToken = default(CancellationToken)); - + /// /// Updates the user configuration. /// @@ -225,7 +225,7 @@ namespace MediaBrowser.Model.ApiClient /// The query. /// Task<QueryResult<BaseItemDto>>. Task GetLatestItems(LatestItemsQuery query); - + /// /// Gets the intros async. /// @@ -324,7 +324,7 @@ namespace MediaBrowser.Model.ApiClient /// The cancellation token. /// Task<ItemsResult>. Task GetUserViews(string userId, CancellationToken cancellationToken = default(CancellationToken)); - + /// /// Gets the instant mix from song async. /// @@ -563,7 +563,7 @@ namespace MediaBrowser.Model.ApiClient /// The identifier. /// Task<UserDto>. Task GetOfflineUserAsync(string id); - + /// /// Gets the parental ratings async. /// @@ -761,7 +761,7 @@ namespace MediaBrowser.Model.ApiClient /// The password. /// Task. /// userId - Task AuthenticateUserAsync(string username, + Task AuthenticateUserAsync(string username, string password); /// @@ -874,7 +874,7 @@ namespace MediaBrowser.Model.ApiClient /// The access token. /// The user identifier. void SetAuthenticationInfo(string accessToken, string userId); - + /// /// Sets the authentication information. /// @@ -921,7 +921,7 @@ namespace MediaBrowser.Model.ApiClient /// /// Task. Task StopReceivingSyncJobsUpdates(); - + /// /// Starts the receiving session updates. /// @@ -934,7 +934,7 @@ namespace MediaBrowser.Model.ApiClient /// /// Task. Task StopReceivingSessionUpdates(); - + /// /// Gets the image URL. /// @@ -1378,7 +1378,7 @@ namespace MediaBrowser.Model.ApiClient /// The file. /// The cancellation token. /// Task. - Task UploadFile(Stream stream, + Task UploadFile(Stream stream, LocalFileInfo file, CancellationToken cancellationToken); @@ -1439,7 +1439,7 @@ namespace MediaBrowser.Model.ApiClient /// The cancellation token. /// Task<Stream>. Task GetSyncJobItemAdditionalFile(string id, string name, CancellationToken cancellationToken); - + /// /// Opens the web socket. /// @@ -1503,5 +1503,14 @@ namespace MediaBrowser.Model.ApiClient /// The identifier. /// Task. Task EnableCancelledSyncJobItem(string id); + /// + /// Gets the synchronize options. + /// + /// The user identifier. + /// The item ids. + /// The parent identifier. + /// The category. + /// Task<SyncOptions>. + Task GetSyncOptions(IEnumerable itemIds, string userId, string parentId = null, SyncCategory? category = null); } } \ No newline at end of file diff --git a/MediaBrowser.Model/Dlna/AudioOptions.cs b/MediaBrowser.Model/Dlna/AudioOptions.cs index dd6dad2610..cddfd89559 100644 --- a/MediaBrowser.Model/Dlna/AudioOptions.cs +++ b/MediaBrowser.Model/Dlna/AudioOptions.cs @@ -47,6 +47,17 @@ namespace MediaBrowser.Model.Dlna /// The audio transcoding bitrate. public int? AudioTranscodingBitrate { get; set; } + /// + /// Gets or sets a value indicating whether [supports direct remote content]. + /// + /// true if [supports direct remote content]; otherwise, false. + public bool SupportsDirectRemoteContent { get; set; } + /// + /// Gets or sets a value indicating whether [supports custom HTTP headers]. + /// + /// true if [supports custom HTTP headers]; otherwise, false. + public bool SupportsCustomHttpHeaders { get; set; } + /// /// Gets the maximum bitrate. /// diff --git a/MediaBrowser.Model/Dlna/DeviceProfile.cs b/MediaBrowser.Model/Dlna/DeviceProfile.cs index 3bbef28c57..4b137a268c 100644 --- a/MediaBrowser.Model/Dlna/DeviceProfile.cs +++ b/MediaBrowser.Model/Dlna/DeviceProfile.cs @@ -76,8 +76,6 @@ namespace MediaBrowser.Model.Dlna public bool RequiresPlainVideoItems { get; set; } public bool RequiresPlainFolders { get; set; } - public bool SupportsDirectRemoteContent { get; set; } - public bool SupportsCustomHttpHeaders { get; set; } public bool EnableMSMediaReceiverRegistrar { get; set; } public XmlAttribute[] XmlRootAttributes { get; set; } diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index 8b929425a1..6076637b44 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -258,7 +258,7 @@ namespace MediaBrowser.Model.Dlna if (IsEligibleForDirectPlay(item, maxBitrateSetting, subtitleStream, options)) { // See if it can be direct played - var directPlay = GetVideoDirectPlayProfile(options.Profile, item, videoStream, audioStream); + var directPlay = GetVideoDirectPlayProfile(options, options.Profile, item, videoStream, audioStream); if (directPlay != null) { @@ -380,7 +380,8 @@ namespace MediaBrowser.Model.Dlna return 128000; } - private PlayMethod? GetVideoDirectPlayProfile(DeviceProfile profile, + private PlayMethod? GetVideoDirectPlayProfile(VideoOptions options, + DeviceProfile profile, MediaSourceInfo mediaSource, MediaStream videoStream, MediaStream audioStream) @@ -504,12 +505,12 @@ namespace MediaBrowser.Model.Dlna if (mediaSource.Protocol == MediaProtocol.Http) { - if (!profile.SupportsDirectRemoteContent) + if (!options.SupportsDirectRemoteContent) { return null; } - if (mediaSource.RequiredHttpHeaders.Count > 0 && !profile.SupportsCustomHttpHeaders) + if (mediaSource.RequiredHttpHeaders.Count > 0 && !options.SupportsCustomHttpHeaders) { return null; } diff --git a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs index 77953ee43b..3903c62b1e 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs @@ -74,7 +74,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security ValidateUserAccess(user, request, authAttribtues, auth); } - var info = (AuthenticationInfo)request.Items["OriginalAuthenticationInfo"]; + var info = GetTokenInfo(request); if (!IsExemptFromRoles(auth, authAttribtues, info)) { @@ -199,6 +199,13 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security } } + private AuthenticationInfo GetTokenInfo(IServiceRequest request) + { + object info; + request.Items.TryGetValue("OriginalAuthenticationInfo", out info); + return info as AuthenticationInfo; + } + private bool IsValidConnectKey(string token) { if (string.IsNullOrEmpty(token)) @@ -216,7 +223,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security throw new SecurityException("Access token is invalid or expired."); } - var info = (AuthenticationInfo)request.Items["OriginalAuthenticationInfo"]; + var info = GetTokenInfo(request); if (info == null) { diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index 99c59abc5d..3ffe31ed18 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -203,6 +203,8 @@ namespace MediaBrowser.Server.Implementations.Persistence cancellationToken.ThrowIfCancellationRequested(); + CheckDisposed(); + await _writeLock.WaitAsync(cancellationToken).ConfigureAwait(false); IDbTransaction transaction = null; @@ -271,6 +273,8 @@ namespace MediaBrowser.Server.Implementations.Persistence throw new ArgumentNullException("id"); } + CheckDisposed(); + using (var cmd = _connection.CreateCommand()) { cmd.CommandText = "select type,data from TypedBaseItems where guid = @guid"; @@ -355,6 +359,7 @@ namespace MediaBrowser.Server.Implementations.Persistence /// id public IEnumerable GetChapters(Guid id) { + CheckDisposed(); return _chapterRepository.GetChapters(id); } @@ -367,6 +372,7 @@ namespace MediaBrowser.Server.Implementations.Persistence /// id public ChapterInfo GetChapter(Guid id, int index) { + CheckDisposed(); return _chapterRepository.GetChapter(id, index); } @@ -386,6 +392,7 @@ namespace MediaBrowser.Server.Implementations.Persistence /// public Task SaveChapters(Guid id, IEnumerable chapters, CancellationToken cancellationToken) { + CheckDisposed(); return _chapterRepository.SaveChapters(id, chapters, cancellationToken); } @@ -400,6 +407,15 @@ namespace MediaBrowser.Server.Implementations.Persistence private readonly object _disposeLock = new object(); + private bool _disposed; + private void CheckDisposed() + { + if (_disposed) + { + throw new ObjectDisposedException(GetType().Name + " has been disposed and cannot be accessed."); + } + } + /// /// Releases unmanaged and - optionally - managed resources. /// @@ -408,6 +424,8 @@ namespace MediaBrowser.Server.Implementations.Persistence { if (dispose) { + _disposed = true; + try { lock (_disposeLock) @@ -456,6 +474,8 @@ namespace MediaBrowser.Server.Implementations.Persistence throw new ArgumentNullException("parentId"); } + CheckDisposed(); + using (var cmd = _connection.CreateCommand()) { cmd.CommandText = "select ItemId from ChildrenIds where ParentId = @ParentId"; @@ -479,6 +499,8 @@ namespace MediaBrowser.Server.Implementations.Persistence throw new ArgumentNullException("parentId"); } + CheckDisposed(); + using (var cmd = _connection.CreateCommand()) { cmd.CommandText = "select type,data from TypedBaseItems where guid in (select ItemId from ChildrenIds where ParentId = @ParentId)"; @@ -507,6 +529,8 @@ namespace MediaBrowser.Server.Implementations.Persistence throw new ArgumentNullException("type"); } + CheckDisposed(); + using (var cmd = _connection.CreateCommand()) { cmd.CommandText = "select type,data from TypedBaseItems where type = @type"; @@ -535,6 +559,8 @@ namespace MediaBrowser.Server.Implementations.Persistence throw new ArgumentNullException("id"); } + CheckDisposed(); + await _writeLock.WaitAsync(cancellationToken).ConfigureAwait(false); IDbTransaction transaction = null; @@ -598,6 +624,8 @@ namespace MediaBrowser.Server.Implementations.Persistence throw new ArgumentNullException("children"); } + CheckDisposed(); + await _writeLock.WaitAsync(cancellationToken).ConfigureAwait(false); IDbTransaction transaction = null; @@ -659,11 +687,13 @@ namespace MediaBrowser.Server.Implementations.Persistence public IEnumerable GetMediaStreams(MediaStreamQuery query) { + CheckDisposed(); return _mediaStreamsRepository.GetMediaStreams(query); } public Task SaveMediaStreams(Guid id, IEnumerable streams, CancellationToken cancellationToken) { + CheckDisposed(); return _mediaStreamsRepository.SaveMediaStreams(id, streams, cancellationToken); } } diff --git a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs index 5a07a41e9c..05d804cbb6 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs @@ -172,6 +172,8 @@ namespace MediaBrowser.Server.Implementations.Sync throw new ArgumentNullException("id"); } + CheckDisposed(); + var guid = new Guid(id); if (guid == Guid.Empty) @@ -277,6 +279,8 @@ namespace MediaBrowser.Server.Implementations.Sync throw new ArgumentNullException("job"); } + CheckDisposed(); + await _writeLock.WaitAsync().ConfigureAwait(false); IDbTransaction transaction = null; @@ -348,6 +352,8 @@ namespace MediaBrowser.Server.Implementations.Sync throw new ArgumentNullException("id"); } + CheckDisposed(); + await _writeLock.WaitAsync().ConfigureAwait(false); IDbTransaction transaction = null; @@ -407,6 +413,8 @@ namespace MediaBrowser.Server.Implementations.Sync throw new ArgumentNullException("query"); } + CheckDisposed(); + using (var cmd = _connection.CreateCommand()) { cmd.CommandText = BaseJobSelectText; @@ -491,6 +499,8 @@ namespace MediaBrowser.Server.Implementations.Sync throw new ArgumentNullException("id"); } + CheckDisposed(); + var guid = new Guid(id); using (var cmd = _connection.CreateCommand()) @@ -618,6 +628,8 @@ namespace MediaBrowser.Server.Implementations.Sync throw new ArgumentNullException("jobItem"); } + CheckDisposed(); + await _writeLock.WaitAsync().ConfigureAwait(false); IDbTransaction transaction = null; @@ -764,6 +776,15 @@ namespace MediaBrowser.Server.Implementations.Sync GC.SuppressFinalize(this); } + private bool _disposed; + private void CheckDisposed() + { + if (_disposed) + { + throw new ObjectDisposedException(GetType().Name + " has been disposed and cannot be accessed."); + } + } + private readonly object _disposeLock = new object(); /// @@ -774,6 +795,8 @@ namespace MediaBrowser.Server.Implementations.Sync { if (dispose) { + _disposed = true; + try { lock (_disposeLock) -- cgit v1.2.3