From 6146b57e7c908d301f5aee3a8cdd996b395db363 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 22 Sep 2013 12:49:55 -0400 Subject: update to servicestack 3.9.62 --- .../MediaBrowser.Server.Implementations.csproj | 18 +++++++++--------- MediaBrowser.Server.Implementations/packages.config | 6 +++--- .../swagger-ui/index.html | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index f84c02c1f8..423f27c4a3 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -49,21 +49,21 @@ False ..\packages\morelinq.1.0.16006\lib\net35\MoreLinq.dll - + False - ..\packages\ServiceStack.3.9.59\lib\net35\ServiceStack.dll + ..\packages\ServiceStack.3.9.62\lib\net35\ServiceStack.dll False ..\packages\ServiceStack.Api.Swagger.3.9.59\lib\net35\ServiceStack.Api.Swagger.dll - + False - ..\packages\ServiceStack.Common.3.9.59\lib\net35\ServiceStack.Common.dll + ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Common.dll - + False - ..\packages\ServiceStack.Common.3.9.59\lib\net35\ServiceStack.Interfaces.dll + ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Interfaces.dll False @@ -73,13 +73,13 @@ False ..\packages\ServiceStack.Redis.3.9.43\lib\net35\ServiceStack.Redis.dll - + False - ..\packages\ServiceStack.3.9.59\lib\net35\ServiceStack.ServiceInterface.dll + ..\packages\ServiceStack.3.9.62\lib\net35\ServiceStack.ServiceInterface.dll False - ..\packages\ServiceStack.Text.3.9.59\lib\net35\ServiceStack.Text.dll + ..\packages\ServiceStack.Text.3.9.62\lib\net35\ServiceStack.Text.dll diff --git a/MediaBrowser.Server.Implementations/packages.config b/MediaBrowser.Server.Implementations/packages.config index 14e7ed2f4a..5d94634084 100644 --- a/MediaBrowser.Server.Implementations/packages.config +++ b/MediaBrowser.Server.Implementations/packages.config @@ -7,12 +7,12 @@ - + - + - + \ No newline at end of file diff --git a/MediaBrowser.Server.Implementations/swagger-ui/index.html b/MediaBrowser.Server.Implementations/swagger-ui/index.html index 49f983a723..0fcc069596 100644 --- a/MediaBrowser.Server.Implementations/swagger-ui/index.html +++ b/MediaBrowser.Server.Implementations/swagger-ui/index.html @@ -20,7 +20,7 @@ $(function () { window.swaggerUi = new SwaggerUi({ discoveryUrl: "../resources", - apiKey: "special-key", + apiKey:"special-key", dom_id:"swagger-ui-container", supportHeaderParams: false, supportedSubmitMethods: ['get', 'post', 'put'], -- cgit v1.2.3 From 1c7c71075af5f87a00047a56e3cef80fc9791828 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 22 Sep 2013 14:21:55 -0400 Subject: pass current server version into installation manager to get update list --- MediaBrowser.Api/PackageService.cs | 4 ++-- .../Updates/InstallationManager.cs | 25 +++++++++++----------- .../Updates/IInstallationManager.cs | 9 +++++--- MediaBrowser.Controller/Entities/Folder.cs | 2 +- .../ScheduledTasks/PluginUpdateTask.cs | 15 ++++++------- MediaBrowser.ServerApplication/ApplicationHost.cs | 3 +-- 6 files changed, 29 insertions(+), 29 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Api/PackageService.cs b/MediaBrowser.Api/PackageService.cs index 563625a544..0c6ee20f79 100644 --- a/MediaBrowser.Api/PackageService.cs +++ b/MediaBrowser.Api/PackageService.cs @@ -132,7 +132,7 @@ namespace MediaBrowser.Api if (request.PackageType == PackageType.UserInstalled || request.PackageType == PackageType.All) { - result.AddRange(_installationManager.GetAvailablePluginUpdates(false, CancellationToken.None).Result.ToList()); + result.AddRange(_installationManager.GetAvailablePluginUpdates(_appHost.ApplicationVersion, false, CancellationToken.None).Result.ToList()); } else if (request.PackageType == PackageType.System || request.PackageType == PackageType.All) @@ -194,7 +194,7 @@ namespace MediaBrowser.Api public void Post(InstallPackage request) { var package = string.IsNullOrEmpty(request.Version) ? - _installationManager.GetLatestCompatibleVersion(request.Name, request.UpdateClass).Result : + _installationManager.GetLatestCompatibleVersion(request.Name, _appHost.ApplicationVersion, request.UpdateClass).Result : _installationManager.GetPackage(request.Name, request.UpdateClass, Version.Parse(request.Version)).Result; if (package == null) diff --git a/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs b/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs index 732a108934..e1757afd5a 100644 --- a/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs +++ b/MediaBrowser.Common.Implementations/Updates/InstallationManager.cs @@ -225,9 +225,9 @@ namespace MediaBrowser.Common.Implementations.Updates /// Determines whether [is package version up to date] [the specified package version info]. /// /// The package version info. - /// The application version. + /// The current server version. /// true if [is package version up to date] [the specified package version info]; otherwise, false. - private bool IsPackageVersionUpToDate(PackageVersionInfo packageVersionInfo, Version applicationVersion) + private bool IsPackageVersionUpToDate(PackageVersionInfo packageVersionInfo, Version currentServerVersion) { if (string.IsNullOrEmpty(packageVersionInfo.requiredVersionStr)) { @@ -236,7 +236,7 @@ namespace MediaBrowser.Common.Implementations.Updates Version requiredVersion; - return Version.TryParse(packageVersionInfo.requiredVersionStr, out requiredVersion) && applicationVersion >= requiredVersion; + return Version.TryParse(packageVersionInfo.requiredVersionStr, out requiredVersion) && currentServerVersion >= requiredVersion; } /// @@ -264,13 +264,14 @@ namespace MediaBrowser.Common.Implementations.Updates /// Gets the latest compatible version. /// /// The name. + /// The current server version. /// The classification. /// Task{PackageVersionInfo}. - public async Task GetLatestCompatibleVersion(string name, PackageVersionClass classification = PackageVersionClass.Release) + public async Task GetLatestCompatibleVersion(string name, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release) { var packages = await GetAvailablePackages(CancellationToken.None).ConfigureAwait(false); - return GetLatestCompatibleVersion(packages, name, classification); + return GetLatestCompatibleVersion(packages, name, currentServerVersion, classification); } /// @@ -278,9 +279,10 @@ namespace MediaBrowser.Common.Implementations.Updates /// /// The available packages. /// The name. + /// The current server version. /// The classification. /// PackageVersionInfo. - public PackageVersionInfo GetLatestCompatibleVersion(IEnumerable availablePackages, string name, PackageVersionClass classification = PackageVersionClass.Release) + public PackageVersionInfo GetLatestCompatibleVersion(IEnumerable availablePackages, string name, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release) { var package = availablePackages.FirstOrDefault(p => p.name.Equals(name, StringComparison.OrdinalIgnoreCase)); @@ -291,23 +293,20 @@ namespace MediaBrowser.Common.Implementations.Updates return package.versions .OrderByDescending(v => v.version) - .FirstOrDefault(v => v.classification <= classification && IsPackageVersionUpToDate(v, _applicationHost.ApplicationVersion)); + .FirstOrDefault(v => v.classification <= classification && IsPackageVersionUpToDate(v, currentServerVersion)); } /// /// Gets the available plugin updates. /// + /// The current server version. /// if set to true [with auto update enabled]. /// The cancellation token. /// Task{IEnumerable{PackageVersionInfo}}. - public async Task> GetAvailablePluginUpdates(bool withAutoUpdateEnabled, CancellationToken cancellationToken) + public async Task> GetAvailablePluginUpdates(Version currentServerVersion, bool withAutoUpdateEnabled, CancellationToken cancellationToken) { var catalog = await GetAvailablePackagesWithoutRegistrationInfo(cancellationToken).ConfigureAwait(false); - return FilterCatalog(catalog, withAutoUpdateEnabled); - } - protected IEnumerable FilterCatalog(IEnumerable catalog, bool withAutoUpdateEnabled) - { var plugins = _applicationHost.Plugins.ToList(); if (withAutoUpdateEnabled) @@ -320,7 +319,7 @@ namespace MediaBrowser.Common.Implementations.Updates // Figure out what needs to be installed var packages = plugins.Select(p => { - var latestPluginInfo = GetLatestCompatibleVersion(catalog, p.Name, p.Configuration.UpdateClass); + var latestPluginInfo = GetLatestCompatibleVersion(catalog, p.Name, currentServerVersion, p.Configuration.UpdateClass); return latestPluginInfo != null && latestPluginInfo.version != null && latestPluginInfo.version > p.Version ? latestPluginInfo : null; diff --git a/MediaBrowser.Common/Updates/IInstallationManager.cs b/MediaBrowser.Common/Updates/IInstallationManager.cs index 95eca6e29f..143a90b856 100644 --- a/MediaBrowser.Common/Updates/IInstallationManager.cs +++ b/MediaBrowser.Common/Updates/IInstallationManager.cs @@ -76,26 +76,29 @@ namespace MediaBrowser.Common.Updates /// Gets the latest compatible version. /// /// The name. + /// The current server version. /// The classification. /// Task{PackageVersionInfo}. - Task GetLatestCompatibleVersion(string name, PackageVersionClass classification = PackageVersionClass.Release); + Task GetLatestCompatibleVersion(string name, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release); /// /// Gets the latest compatible version. /// /// The available packages. /// The name. + /// The current server version. /// The classification. /// PackageVersionInfo. - PackageVersionInfo GetLatestCompatibleVersion(IEnumerable availablePackages, string name, PackageVersionClass classification = PackageVersionClass.Release); + PackageVersionInfo GetLatestCompatibleVersion(IEnumerable availablePackages, string name, Version currentServerVersion, PackageVersionClass classification = PackageVersionClass.Release); /// /// Gets the available plugin updates. /// + /// The current server version. /// if set to true [with auto update enabled]. /// The cancellation token. /// Task{IEnumerable{PackageVersionInfo}}. - Task> GetAvailablePluginUpdates(bool withAutoUpdateEnabled, CancellationToken cancellationToken); + Task> GetAvailablePluginUpdates(Version currentServerVersion, bool withAutoUpdateEnabled, CancellationToken cancellationToken); /// /// Installs the package. diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index a724067d5b..e68d4be8e6 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -1004,7 +1004,7 @@ namespace MediaBrowser.Controller.Entities throw new ArgumentNullException(); } - var list = new List(10000); + var list = new List(_children.Count); AddRecursiveChildrenInternal(user, includeLinkedChildren, list); diff --git a/MediaBrowser.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs b/MediaBrowser.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs index 2936520075..e4f7134d7e 100644 --- a/MediaBrowser.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs +++ b/MediaBrowser.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.ScheduledTasks; +using MediaBrowser.Common; +using MediaBrowser.Common.ScheduledTasks; using MediaBrowser.Common.Updates; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Net; @@ -23,15 +24,13 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks private readonly IInstallationManager _installationManager; - /// - /// Initializes a new instance of the class. - /// - /// The logger. - /// The installation manager. - public PluginUpdateTask(ILogger logger, IInstallationManager installationManager) + private readonly IApplicationHost _appHost; + + public PluginUpdateTask(ILogger logger, IInstallationManager installationManager, IApplicationHost appHost) { _logger = logger; _installationManager = installationManager; + _appHost = appHost; } /// @@ -60,7 +59,7 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks { progress.Report(0); - var packagesToInstall = (await _installationManager.GetAvailablePluginUpdates(true, cancellationToken).ConfigureAwait(false)).ToList(); + var packagesToInstall = (await _installationManager.GetAvailablePluginUpdates(_appHost.ApplicationVersion, true, cancellationToken).ConfigureAwait(false)).ToList(); progress.Report(10); diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 4715258167..2d19260dc2 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -60,7 +60,6 @@ using System.Net.Http; using System.Reflection; using System.Threading; using System.Threading.Tasks; -using System.Windows; namespace MediaBrowser.ServerApplication { @@ -708,7 +707,7 @@ namespace MediaBrowser.ServerApplication { var availablePackages = await InstallationManager.GetAvailablePackagesWithoutRegistrationInfo(cancellationToken).ConfigureAwait(false); - var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MbServerPkgName, ConfigurationManager.CommonConfiguration.SystemUpdateLevel); + var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MbServerPkgName, ApplicationVersion, ConfigurationManager.CommonConfiguration.SystemUpdateLevel); return version != null ? new CheckForUpdateResult { AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version } : new CheckForUpdateResult { AvailableVersion = ApplicationVersion, IsUpdateAvailable = false }; -- cgit v1.2.3 From b54240f6798d463d30b1465e376cea748f2d8655 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 23 Sep 2013 10:02:56 -0400 Subject: fixes #553 - Support locking OfficialRating field --- .../Providers/BaseMetadataProvider.cs | 12 ++++++++++ MediaBrowser.Model/Entities/MetadataFields.cs | 6 ++++- .../MediaInfo/FFProbeVideoInfoProvider.cs | 5 ++++- MediaBrowser.Providers/Movies/MovieDbProvider.cs | 26 +++++++++++++--------- MediaBrowser.Providers/TV/RemoteSeriesProvider.cs | 14 +++++++++++- .../Providers/ProviderManager.cs | 2 +- 6 files changed, 50 insertions(+), 15 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs b/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs index 39c999e82a..a8dc8788f1 100644 --- a/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs +++ b/MediaBrowser.Controller/Providers/BaseMetadataProvider.cs @@ -202,6 +202,18 @@ namespace MediaBrowser.Controller.Providers return NeedsRefreshInternal(item, data); } + /// + /// Gets a value indicating whether [enforce dont fetch metadata]. + /// + /// true if [enforce dont fetch metadata]; otherwise, false. + public virtual bool EnforceDontFetchMetadata + { + get + { + return true; + } + } + /// /// Needses the refresh internal. /// diff --git a/MediaBrowser.Model/Entities/MetadataFields.cs b/MediaBrowser.Model/Entities/MetadataFields.cs index a432e11248..85f2da31e0 100644 --- a/MediaBrowser.Model/Entities/MetadataFields.cs +++ b/MediaBrowser.Model/Entities/MetadataFields.cs @@ -37,6 +37,10 @@ namespace MediaBrowser.Model.Entities /// /// The runtime /// - Runtime + Runtime, + /// + /// The official rating + /// + OfficialRating } } diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.cs index 59c3d75e52..690c9b3ffe 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.cs @@ -384,7 +384,10 @@ namespace MediaBrowser.Providers.MediaInfo if (!string.IsNullOrWhiteSpace(officialRating)) { - video.OfficialRating = officialRating; + if (!video.LockedFields.Contains(MetadataFields.OfficialRating)) + { + video.OfficialRating = officialRating; + } } } diff --git a/MediaBrowser.Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Providers/Movies/MovieDbProvider.cs index 751712c71e..4741008555 100644 --- a/MediaBrowser.Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbProvider.cs @@ -317,7 +317,7 @@ namespace MediaBrowser.Providers.Movies var boxset = item as BoxSet; if (boxset != null) { - // See if any movies have a collection id already + // See if any movies have a collection id already var collId = boxset.Children.Concat(boxset.GetLinkedChildren()).OfType /// The fields. - [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, ItemCounts, IndexOptions, MediaStreams, Overview, OverviewHtml, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines, TrailerUrls", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] + [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, OverviewHtml, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines, TrailerUrls", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] public string Fields { get; set; } /// diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.cs index e62959bee3..fcddd2ca65 100644 --- a/MediaBrowser.Api/TvShowsService.cs +++ b/MediaBrowser.Api/TvShowsService.cs @@ -43,7 +43,7 @@ namespace MediaBrowser.Api /// Fields to return within the items, in addition to basic information /// /// The fields. - [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, ItemCounts, IndexOptions, MediaStreams, Overview, OverviewHtml, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines, TrailerUrls", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] + [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, OverviewHtml, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines, TrailerUrls", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] public string Fields { get; set; } /// diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs index f92b7da450..eba36d8568 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.Api.UserLibrary /// Fields to return within the items, in addition to basic information /// /// The fields. - [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, ItemCounts, IndexOptions, MediaStreams, Overview, OverviewHtml, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines, TrailerUrls", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] + [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, OverviewHtml, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines, TrailerUrls", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] public string Fields { get; set; } /// diff --git a/MediaBrowser.Model/Querying/ItemFields.cs b/MediaBrowser.Model/Querying/ItemFields.cs index 8b0910acc8..71c3d59cd9 100644 --- a/MediaBrowser.Model/Querying/ItemFields.cs +++ b/MediaBrowser.Model/Querying/ItemFields.cs @@ -51,11 +51,6 @@ namespace MediaBrowser.Model.Querying /// HomePageUrl, - /// - /// Child count, recursive child count, etc - /// - ItemCounts, - /// /// The fields that the server supports indexing on /// diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 99878e2ec4..e5260004a6 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -107,13 +107,10 @@ namespace MediaBrowser.Server.Implementations.Dto .ToArray(); } - if (fields.Contains(ItemFields.ItemCounts)) + var itemByName = item as IItemByName; + if (itemByName != null) { - var itemByName = item as IItemByName; - if (itemByName != null) - { - AttachItemByNameCounts(dto, itemByName, user); - } + AttachItemByNameCounts(dto, itemByName, user); } return dto; @@ -166,18 +163,13 @@ namespace MediaBrowser.Server.Implementations.Dto { if (item.IsFolder) { - var hasItemCounts = fields.Contains(ItemFields.ItemCounts); + var folder = (Folder)item; - if (hasItemCounts || fields.Contains(ItemFields.CumulativeRunTimeTicks)) - { - var folder = (Folder)item; + dto.ChildCount = folder.GetChildren(user, true).Count(); - if (hasItemCounts) - { - dto.ChildCount = folder.GetChildren(user, true).Count(); - } - - SetSpecialCounts(folder, user, dto); + if (!(folder is UserRootFolder)) + { + SetSpecialCounts(folder, user, dto, fields); } } @@ -1068,8 +1060,9 @@ namespace MediaBrowser.Server.Implementations.Dto /// The folder. /// The user. /// The dto. + /// The fields. /// Task. - private void SetSpecialCounts(Folder folder, User user, BaseItemDto dto) + private void SetSpecialCounts(Folder folder, User user, BaseItemDto dto, List fields) { var rcentlyAddedItemCount = 0; var recursiveItemCount = 0; @@ -1127,7 +1120,7 @@ namespace MediaBrowser.Server.Implementations.Dto dto.PlayedPercentage = totalPercentPlayed / recursiveItemCount; } - if (runtime > 0) + if (runtime > 0 && fields.Contains(ItemFields.CumulativeRunTimeTicks)) { dto.CumulativeRunTimeTicks = runtime; } diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs index aa30cee26f..035c0e9dce 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs @@ -356,6 +356,12 @@ namespace MediaBrowser.Server.Implementations.HttpServer try { ProcessRequest(context); + + var url = context.Request.Url.ToString(); + var endPoint = context.Request.RemoteEndPoint; + + LogResponse(context, url, endPoint); + } catch (Exception ex) { @@ -433,9 +439,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer var httpRes = new HttpListenerResponseWrapper(context.Response); var handler = ServiceStackHttpHandlerFactory.GetHandler(httpReq); - var url = context.Request.Url.ToString(); - var endPoint = context.Request.RemoteEndPoint; - var serviceStackHandler = handler as IServiceStackHttpHandler; if (serviceStackHandler != null) @@ -446,7 +449,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer httpReq.OperationName = operationName = restHandler.RestPath.RequestType.Name; } serviceStackHandler.ProcessRequest(httpReq, httpRes, operationName); - LogResponse(context, url, endPoint); return; } @@ -529,7 +531,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer { new ClientWebSocket(); - _supportsNativeWebSocket = true; + _supportsNativeWebSocket = false; } catch (PlatformNotSupportedException) { -- cgit v1.2.3 From 946a5c49d060c818cb333095f8f488635a7f5e86 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 23 Sep 2013 11:37:50 -0400 Subject: #429 - Extract ffmpeg from core product --- .../MediaBrowser.Server.Implementations.csproj | 2 - .../MediaEncoder/MediaEncoder.cs | 232 +-------------------- .../MediaEncoder/ffmpeg20130904.zip.REMOVED.git-id | 1 - .../MediaEncoder/readme.txt | 5 - MediaBrowser.ServerApplication/ApplicationHost.cs | 15 +- .../Implementations/FFMpegDownloader.cs | 205 ++++++++++++++++++ .../ffmpeg20130904.zip.REMOVED.git-id | 1 + .../Implementations/readme.txt | 5 + .../MediaBrowser.ServerApplication.csproj | 5 + 9 files changed, 239 insertions(+), 232 deletions(-) delete mode 100644 MediaBrowser.Server.Implementations/MediaEncoder/ffmpeg20130904.zip.REMOVED.git-id delete mode 100644 MediaBrowser.Server.Implementations/MediaEncoder/readme.txt create mode 100644 MediaBrowser.ServerApplication/Implementations/FFMpegDownloader.cs create mode 100644 MediaBrowser.ServerApplication/Implementations/ffmpeg20130904.zip.REMOVED.git-id create mode 100644 MediaBrowser.ServerApplication/Implementations/readme.txt (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 423f27c4a3..9d2fc8c6b3 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -254,10 +254,8 @@ - - diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs index 5792806d84..b24c9a5cae 100644 --- a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs +++ b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs @@ -1,9 +1,7 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Common.IO; using MediaBrowser.Common.MediaInfo; -using MediaBrowser.Common.Net; using MediaBrowser.Model.Entities; -using MediaBrowser.Model.IO; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Serialization; using System; @@ -13,7 +11,6 @@ using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; -using System.Reflection; using System.Runtime.InteropServices; using System.Text; using System.Threading; @@ -26,12 +23,6 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder /// public class MediaEncoder : IMediaEncoder, IDisposable { - /// - /// Gets or sets the zip client. - /// - /// The zip client. - private readonly IZipClient _zipClient; - /// /// The _logger /// @@ -48,8 +39,6 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder /// The json serializer. private readonly IJsonSerializer _jsonSerializer; - private readonly IHttpClient _httpClient; - /// /// The video image resource pool /// @@ -70,50 +59,25 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder /// private readonly SemaphoreSlim _ffProbeResourcePool = new SemaphoreSlim(2, 2); - /// - /// Gets or sets the versioned directory path. - /// - /// The versioned directory path. - private string VersionedDirectoryPath { get; set; } + public string FFMpegPath { get; private set; } - /// - /// Initializes a new instance of the class. - /// - /// The logger. - /// The zip client. - /// The app paths. - /// The json serializer. - public MediaEncoder(ILogger logger, IZipClient zipClient, IApplicationPaths appPaths, - IJsonSerializer jsonSerializer, IHttpClient httpClient) + public string FFProbePath { get; private set; } + + public string Version { get; private set; } + + public MediaEncoder(ILogger logger, IApplicationPaths appPaths, + IJsonSerializer jsonSerializer, string ffMpegPath, string ffProbePath, string version) { _logger = logger; - _zipClient = zipClient; _appPaths = appPaths; _jsonSerializer = jsonSerializer; - _httpClient = httpClient; + Version = version; + FFProbePath = ffProbePath; + FFMpegPath = ffMpegPath; // Not crazy about this but it's the only way to suppress ffmpeg crash dialog boxes SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOALIGNMENTFAULTEXCEPT | ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_NOOPENFILEERRORBOX); - - Task.Run(() => VersionedDirectoryPath = GetVersionedDirectoryPath()); - } - - /// - /// Gets the media tools path. - /// - /// if set to true [create]. - /// System.String. - private string GetMediaToolsPath(bool create) - { - var path = Path.Combine(_appPaths.ProgramDataPath, "ffmpeg"); - - if (create && !Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } - - return path; } /// @@ -125,182 +89,6 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder get { return FFMpegPath; } } - /// - /// The _ FF MPEG path - /// - private string _FFMpegPath; - - /// - /// Gets the path to ffmpeg.exe - /// - /// The FF MPEG path. - public string FFMpegPath - { - get { return _FFMpegPath ?? (_FFMpegPath = Path.Combine(VersionedDirectoryPath, "ffmpeg.exe")); } - } - - /// - /// The _ FF probe path - /// - private string _FFProbePath; - - /// - /// Gets the path to ffprobe.exe - /// - /// The FF probe path. - private string FFProbePath - { - get { return _FFProbePath ?? (_FFProbePath = Path.Combine(VersionedDirectoryPath, "ffprobe.exe")); } - } - - /// - /// Gets the version. - /// - /// The version. - public string Version - { - get { return Path.GetFileNameWithoutExtension(VersionedDirectoryPath); } - } - - /// - /// Gets the versioned directory path. - /// - /// System.String. - private string GetVersionedDirectoryPath() - { - var assembly = GetType().Assembly; - - var prefix = GetType().Namespace + "."; - - var srch = prefix + "ffmpeg"; - - var resource = assembly.GetManifestResourceNames().First(r => r.StartsWith(srch)); - - var filename = - resource.Substring(resource.IndexOf(prefix, StringComparison.OrdinalIgnoreCase) + prefix.Length); - - var versionedDirectoryPath = Path.Combine(GetMediaToolsPath(true), - Path.GetFileNameWithoutExtension(filename)); - - if (!Directory.Exists(versionedDirectoryPath)) - { - Directory.CreateDirectory(versionedDirectoryPath); - } - - ExtractTools(assembly, resource, versionedDirectoryPath); - - return versionedDirectoryPath; - } - - /// - /// Extracts the tools. - /// - /// The assembly. - /// The zip file resource path. - /// The target path. - private async void ExtractTools(Assembly assembly, string zipFileResourcePath, string targetPath) - { - using (var resourceStream = assembly.GetManifestResourceStream(zipFileResourcePath)) - { - _zipClient.ExtractAll(resourceStream, targetPath, false); - } - - try - { - await DownloadFonts(targetPath).ConfigureAwait(false); - } - catch (Exception ex) - { - _logger.ErrorException("Error getting ffmpeg font files", ex); - } - } - - private const string FontUrl = "https://www.dropbox.com/s/9nb76tybcsw5xrk/ARIALUNI.zip?dl=1"; - - /// - /// Extracts the fonts. - /// - /// The target path. - private async Task DownloadFonts(string targetPath) - { - var fontsDirectory = Path.Combine(targetPath, "fonts"); - - if (!Directory.Exists(fontsDirectory)) - { - Directory.CreateDirectory(fontsDirectory); - } - - const string fontFilename = "ARIALUNI.TTF"; - - var fontFile = Path.Combine(fontsDirectory, fontFilename); - - if (!File.Exists(fontFile)) - { - await DownloadFontFile(fontsDirectory, fontFilename).ConfigureAwait(false); - } - - await WriteFontConfigFile(fontsDirectory).ConfigureAwait(false); - } - - private async Task DownloadFontFile(string fontsDirectory, string fontFilename) - { - var existingFile = Directory - .EnumerateFiles(_appPaths.ProgramDataPath, fontFilename, SearchOption.AllDirectories) - .FirstOrDefault(); - - if (existingFile != null) - { - try - { - File.Copy(existingFile, Path.Combine(fontsDirectory, fontFilename), true); - return; - } - catch (IOException ex) - { - // Log this, but don't let it fail the operation - _logger.ErrorException("Error copying file", ex); - } - } - - var tempFile = await _httpClient.GetTempFile(new HttpRequestOptions - { - Url = FontUrl, - Progress = new Progress() - }); - - _zipClient.ExtractAll(tempFile, fontsDirectory, true); - - try - { - File.Delete(tempFile); - } - catch (IOException ex) - { - // Log this, but don't let it fail the operation - _logger.ErrorException("Error deleting temp file {0}", ex, tempFile); - } - } - - private async Task WriteFontConfigFile(string fontsDirectory) - { - const string fontConfigFilename = "fonts.conf"; - var fontConfigFile = Path.Combine(fontsDirectory, fontConfigFilename); - - if (!File.Exists(fontConfigFile)) - { - var contents = string.Format("{0}ArialArial Unicode MS", fontsDirectory); - - var bytes = Encoding.UTF8.GetBytes(contents); - - using (var fileStream = new FileStream(fontConfigFile, FileMode.Create, FileAccess.Write, - FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, - FileOptions.Asynchronous)) - { - await fileStream.WriteAsync(bytes, 0, bytes.Length); - } - } - } - /// /// Gets the media info. /// diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/ffmpeg20130904.zip.REMOVED.git-id b/MediaBrowser.Server.Implementations/MediaEncoder/ffmpeg20130904.zip.REMOVED.git-id deleted file mode 100644 index e99d115a48..0000000000 --- a/MediaBrowser.Server.Implementations/MediaEncoder/ffmpeg20130904.zip.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -3496b2cde22e7c4cb56b480dd2da637167d51e78 \ No newline at end of file diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/readme.txt b/MediaBrowser.Server.Implementations/MediaEncoder/readme.txt deleted file mode 100644 index b32dd9aec0..0000000000 --- a/MediaBrowser.Server.Implementations/MediaEncoder/readme.txt +++ /dev/null @@ -1,5 +0,0 @@ -This is the 32-bit static build of ffmpeg, located at: - -http://ffmpeg.zeranoe.com/builds/ - -The zip file contains both ffmpeg and ffprobe, and is suffixed with the date of the build. \ No newline at end of file diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 2d19260dc2..5cae997850 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -284,8 +284,7 @@ namespace MediaBrowser.ServerApplication RegisterSingleInstance(() => new LuceneSearchEngine(ApplicationPaths, LogManager, LibraryManager)); - MediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"), ZipClient, ApplicationPaths, JsonSerializer, HttpClient); - RegisterSingleInstance(MediaEncoder); + await RegisterMediaEncoder().ConfigureAwait(false); var clientConnectionManager = new SessionManager(UserDataRepository, ServerConfigurationManager, Logger, UserRepository); RegisterSingleInstance(clientConnectionManager); @@ -316,6 +315,18 @@ namespace MediaBrowser.ServerApplication SetKernelProperties(); } + /// + /// Registers the media encoder. + /// + /// Task. + private async Task RegisterMediaEncoder() + { + var info = await new FFMpegDownloader(Logger, ApplicationPaths, HttpClient, ZipClient).GetFFMpegInfo().ConfigureAwait(false); + + MediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"), ApplicationPaths, JsonSerializer, info.Path, info.ProbePath, info.Version); + RegisterSingleInstance(MediaEncoder); + } + /// /// Sets the kernel properties. /// diff --git a/MediaBrowser.ServerApplication/Implementations/FFMpegDownloader.cs b/MediaBrowser.ServerApplication/Implementations/FFMpegDownloader.cs new file mode 100644 index 0000000000..7fd0acddd2 --- /dev/null +++ b/MediaBrowser.ServerApplication/Implementations/FFMpegDownloader.cs @@ -0,0 +1,205 @@ +using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.IO; +using MediaBrowser.Common.Net; +using MediaBrowser.Model.IO; +using MediaBrowser.Model.Logging; +using System; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace MediaBrowser.ServerApplication.Implementations +{ + public class FFMpegDownloader + { + private readonly IZipClient _zipClient; + private readonly IHttpClient _httpClient; + private readonly IApplicationPaths _appPaths; + private readonly ILogger _logger; + + public FFMpegDownloader(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient, IZipClient zipClient) + { + _logger = logger; + _appPaths = appPaths; + _httpClient = httpClient; + _zipClient = zipClient; + } + + public async Task GetFFMpegInfo() + { + var assembly = GetType().Assembly; + + var prefix = GetType().Namespace + "."; + + var srch = prefix + "ffmpeg"; + + var resource = assembly.GetManifestResourceNames().First(r => r.StartsWith(srch)); + + var filename = + resource.Substring(resource.IndexOf(prefix, StringComparison.OrdinalIgnoreCase) + prefix.Length); + + var versionedDirectoryPath = Path.Combine(GetMediaToolsPath(true), + Path.GetFileNameWithoutExtension(filename)); + + if (!Directory.Exists(versionedDirectoryPath)) + { + Directory.CreateDirectory(versionedDirectoryPath); + } + + await ExtractTools(assembly, resource, versionedDirectoryPath).ConfigureAwait(false); + + return new FFMpegInfo + { + ProbePath = Path.Combine(versionedDirectoryPath, "ffprobe.exe"), + Path = Path.Combine(versionedDirectoryPath, "ffmpeg.exe"), + Version = Path.GetFileNameWithoutExtension(versionedDirectoryPath) + }; + } + + /// + /// Extracts the tools. + /// + /// The assembly. + /// The zip file resource path. + /// The target path. + private async Task ExtractTools(Assembly assembly, string zipFileResourcePath, string targetPath) + { + using (var resourceStream = assembly.GetManifestResourceStream(zipFileResourcePath)) + { + _zipClient.ExtractAll(resourceStream, targetPath, false); + } + + try + { + await DownloadFonts(targetPath).ConfigureAwait(false); + } + catch (Exception ex) + { + _logger.ErrorException("Error getting ffmpeg font files", ex); + } + } + + private const string FontUrl = "https://www.dropbox.com/s/9nb76tybcsw5xrk/ARIALUNI.zip?dl=1"; + + /// + /// Extracts the fonts. + /// + /// The target path. + private async Task DownloadFonts(string targetPath) + { + var fontsDirectory = Path.Combine(targetPath, "fonts"); + + if (!Directory.Exists(fontsDirectory)) + { + Directory.CreateDirectory(fontsDirectory); + } + + const string fontFilename = "ARIALUNI.TTF"; + + var fontFile = Path.Combine(fontsDirectory, fontFilename); + + if (!File.Exists(fontFile)) + { + await DownloadFontFile(fontsDirectory, fontFilename).ConfigureAwait(false); + } + + await WriteFontConfigFile(fontsDirectory).ConfigureAwait(false); + } + + /// + /// Downloads the font file. + /// + /// The fonts directory. + /// The font filename. + /// Task. + private async Task DownloadFontFile(string fontsDirectory, string fontFilename) + { + var existingFile = Directory + .EnumerateFiles(_appPaths.ProgramDataPath, fontFilename, SearchOption.AllDirectories) + .FirstOrDefault(); + + if (existingFile != null) + { + try + { + File.Copy(existingFile, Path.Combine(fontsDirectory, fontFilename), true); + return; + } + catch (IOException ex) + { + // Log this, but don't let it fail the operation + _logger.ErrorException("Error copying file", ex); + } + } + + var tempFile = await _httpClient.GetTempFile(new HttpRequestOptions + { + Url = FontUrl, + Progress = new Progress() + }); + + _zipClient.ExtractAll(tempFile, fontsDirectory, true); + + try + { + File.Delete(tempFile); + } + catch (IOException ex) + { + // Log this, but don't let it fail the operation + _logger.ErrorException("Error deleting temp file {0}", ex, tempFile); + } + } + + /// + /// Writes the font config file. + /// + /// The fonts directory. + /// Task. + private async Task WriteFontConfigFile(string fontsDirectory) + { + const string fontConfigFilename = "fonts.conf"; + var fontConfigFile = Path.Combine(fontsDirectory, fontConfigFilename); + + if (!File.Exists(fontConfigFile)) + { + var contents = string.Format("{0}ArialArial Unicode MS", fontsDirectory); + + var bytes = Encoding.UTF8.GetBytes(contents); + + using (var fileStream = new FileStream(fontConfigFile, FileMode.Create, FileAccess.Write, + FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, + FileOptions.Asynchronous)) + { + await fileStream.WriteAsync(bytes, 0, bytes.Length); + } + } + } + + /// + /// Gets the media tools path. + /// + /// if set to true [create]. + /// System.String. + private string GetMediaToolsPath(bool create) + { + var path = Path.Combine(_appPaths.ProgramDataPath, "ffmpeg"); + + if (create && !Directory.Exists(path)) + { + Directory.CreateDirectory(path); + } + + return path; + } + } + + public class FFMpegInfo + { + public string Path { get; set; } + public string ProbePath { get; set; } + public string Version { get; set; } + } +} diff --git a/MediaBrowser.ServerApplication/Implementations/ffmpeg20130904.zip.REMOVED.git-id b/MediaBrowser.ServerApplication/Implementations/ffmpeg20130904.zip.REMOVED.git-id new file mode 100644 index 0000000000..e99d115a48 --- /dev/null +++ b/MediaBrowser.ServerApplication/Implementations/ffmpeg20130904.zip.REMOVED.git-id @@ -0,0 +1 @@ +3496b2cde22e7c4cb56b480dd2da637167d51e78 \ No newline at end of file diff --git a/MediaBrowser.ServerApplication/Implementations/readme.txt b/MediaBrowser.ServerApplication/Implementations/readme.txt new file mode 100644 index 0000000000..b32dd9aec0 --- /dev/null +++ b/MediaBrowser.ServerApplication/Implementations/readme.txt @@ -0,0 +1,5 @@ +This is the 32-bit static build of ffmpeg, located at: + +http://ffmpeg.zeranoe.com/builds/ + +The zip file contains both ffmpeg and ffprobe, and is suffixed with the date of the build. \ No newline at end of file diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index f19ffe5b01..043d5c18f1 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -210,6 +210,7 @@ + Component @@ -277,6 +278,7 @@ Resources.Designer.cs + SettingsSingleFileGenerator @@ -388,6 +390,9 @@ + + + if $(ConfigurationName) == Release ( -- cgit v1.2.3 From cacba5ca11d600ed9d496c566807be92b228de7e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 23 Sep 2013 11:40:47 -0400 Subject: removed test code --- MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs index 035c0e9dce..f6547dec17 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpServer.cs @@ -531,7 +531,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer { new ClientWebSocket(); - _supportsNativeWebSocket = false; + _supportsNativeWebSocket = true; } catch (PlatformNotSupportedException) { -- cgit v1.2.3