diff options
| author | Eric Reed <ebr@mediabrowser3.com> | 2013-09-23 12:28:44 -0400 |
|---|---|---|
| committer | Eric Reed <ebr@mediabrowser3.com> | 2013-09-23 12:28:44 -0400 |
| commit | c6e57c6448c04998bcae5a906e7a064300542e75 (patch) | |
| tree | 548e46418f25b2dc65b78c1a96083c5ca2b9c81a /MediaBrowser.Server.Implementations | |
| parent | d9fecd78a54453a7656f649a6fcfc654f74dbdf6 (diff) | |
| parent | cacba5ca11d600ed9d496c566807be92b228de7e (diff) | |
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
Diffstat (limited to 'MediaBrowser.Server.Implementations')
10 files changed, 48 insertions, 274 deletions
diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 99878e2ec..e5260004a 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 /// <param name="folder">The folder.</param> /// <param name="user">The user.</param> /// <param name="dto">The dto.</param> + /// <param name="fields">The fields.</param> /// <returns>Task.</returns> - private void SetSpecialCounts(Folder folder, User user, BaseItemDto dto) + private void SetSpecialCounts(Folder folder, User user, BaseItemDto dto, List<ItemFields> 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 aa30cee26..f6547dec1 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; } diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index f84c02c1f..9d2fc8c6b 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -49,21 +49,21 @@ <SpecificVersion>False</SpecificVersion> <HintPath>..\packages\morelinq.1.0.16006\lib\net35\MoreLinq.dll</HintPath> </Reference> - <Reference Include="ServiceStack, Version=3.9.59.0, Culture=neutral, processorArchitecture=MSIL"> + <Reference Include="ServiceStack, Version=3.9.60.0, Culture=neutral, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> - <HintPath>..\packages\ServiceStack.3.9.59\lib\net35\ServiceStack.dll</HintPath> + <HintPath>..\packages\ServiceStack.3.9.62\lib\net35\ServiceStack.dll</HintPath> </Reference> <Reference Include="ServiceStack.Api.Swagger, Version=3.9.59.0, Culture=neutral, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\packages\ServiceStack.Api.Swagger.3.9.59\lib\net35\ServiceStack.Api.Swagger.dll</HintPath> </Reference> - <Reference Include="ServiceStack.Common, Version=3.9.59.0, Culture=neutral, processorArchitecture=MSIL"> + <Reference Include="ServiceStack.Common, Version=3.9.60.0, Culture=neutral, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> - <HintPath>..\packages\ServiceStack.Common.3.9.59\lib\net35\ServiceStack.Common.dll</HintPath> + <HintPath>..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Common.dll</HintPath> </Reference> - <Reference Include="ServiceStack.Interfaces, Version=3.9.59.0, Culture=neutral, processorArchitecture=MSIL"> + <Reference Include="ServiceStack.Interfaces, Version=3.9.60.0, Culture=neutral, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> - <HintPath>..\packages\ServiceStack.Common.3.9.59\lib\net35\ServiceStack.Interfaces.dll</HintPath> + <HintPath>..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Interfaces.dll</HintPath> </Reference> <Reference Include="ServiceStack.OrmLite.SqlServer, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> @@ -73,13 +73,13 @@ <SpecificVersion>False</SpecificVersion> <HintPath>..\packages\ServiceStack.Redis.3.9.43\lib\net35\ServiceStack.Redis.dll</HintPath> </Reference> - <Reference Include="ServiceStack.ServiceInterface, Version=3.9.59.0, Culture=neutral, processorArchitecture=MSIL"> + <Reference Include="ServiceStack.ServiceInterface, Version=3.9.60.0, Culture=neutral, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> - <HintPath>..\packages\ServiceStack.3.9.59\lib\net35\ServiceStack.ServiceInterface.dll</HintPath> + <HintPath>..\packages\ServiceStack.3.9.62\lib\net35\ServiceStack.ServiceInterface.dll</HintPath> </Reference> <Reference Include="ServiceStack.Text, Version=3.9.59.0, Culture=neutral, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> - <HintPath>..\packages\ServiceStack.Text.3.9.59\lib\net35\ServiceStack.Text.dll</HintPath> + <HintPath>..\packages\ServiceStack.Text.3.9.62\lib\net35\ServiceStack.Text.dll</HintPath> </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> @@ -254,10 +254,8 @@ <EmbeddedResource Include="Localization\Ratings\kz.txt" /> <EmbeddedResource Include="Localization\Ratings\nz.txt" /> <EmbeddedResource Include="Localization\Ratings\ru.txt" /> - <EmbeddedResource Include="MediaEncoder\readme.txt" /> </ItemGroup> <ItemGroup> - <EmbeddedResource Include="MediaEncoder\ffmpeg20130904.zip" /> <None Include="packages.config" /> </ItemGroup> <ItemGroup> diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs index 5792806d8..b24c9a5ca 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; @@ -27,12 +24,6 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder public class MediaEncoder : IMediaEncoder, IDisposable { /// <summary> - /// Gets or sets the zip client. - /// </summary> - /// <value>The zip client.</value> - private readonly IZipClient _zipClient; - - /// <summary> /// The _logger /// </summary> private readonly ILogger _logger; @@ -48,8 +39,6 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder /// <value>The json serializer.</value> private readonly IJsonSerializer _jsonSerializer; - private readonly IHttpClient _httpClient; - /// <summary> /// The video image resource pool /// </summary> @@ -70,50 +59,25 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder /// </summary> private readonly SemaphoreSlim _ffProbeResourcePool = new SemaphoreSlim(2, 2); - /// <summary> - /// Gets or sets the versioned directory path. - /// </summary> - /// <value>The versioned directory path.</value> - private string VersionedDirectoryPath { get; set; } + public string FFMpegPath { get; private set; } - /// <summary> - /// Initializes a new instance of the <see cref="MediaEncoder" /> class. - /// </summary> - /// <param name="logger">The logger.</param> - /// <param name="zipClient">The zip client.</param> - /// <param name="appPaths">The app paths.</param> - /// <param name="jsonSerializer">The json serializer.</param> - 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()); - } - - /// <summary> - /// Gets the media tools path. - /// </summary> - /// <param name="create">if set to <c>true</c> [create].</param> - /// <returns>System.String.</returns> - private string GetMediaToolsPath(bool create) - { - var path = Path.Combine(_appPaths.ProgramDataPath, "ffmpeg"); - - if (create && !Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } - - return path; } /// <summary> @@ -126,182 +90,6 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder } /// <summary> - /// The _ FF MPEG path - /// </summary> - private string _FFMpegPath; - - /// <summary> - /// Gets the path to ffmpeg.exe - /// </summary> - /// <value>The FF MPEG path.</value> - public string FFMpegPath - { - get { return _FFMpegPath ?? (_FFMpegPath = Path.Combine(VersionedDirectoryPath, "ffmpeg.exe")); } - } - - /// <summary> - /// The _ FF probe path - /// </summary> - private string _FFProbePath; - - /// <summary> - /// Gets the path to ffprobe.exe - /// </summary> - /// <value>The FF probe path.</value> - private string FFProbePath - { - get { return _FFProbePath ?? (_FFProbePath = Path.Combine(VersionedDirectoryPath, "ffprobe.exe")); } - } - - /// <summary> - /// Gets the version. - /// </summary> - /// <value>The version.</value> - public string Version - { - get { return Path.GetFileNameWithoutExtension(VersionedDirectoryPath); } - } - - /// <summary> - /// Gets the versioned directory path. - /// </summary> - /// <returns>System.String.</returns> - 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; - } - - /// <summary> - /// Extracts the tools. - /// </summary> - /// <param name="assembly">The assembly.</param> - /// <param name="zipFileResourcePath">The zip file resource path.</param> - /// <param name="targetPath">The target path.</param> - 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"; - - /// <summary> - /// Extracts the fonts. - /// </summary> - /// <param name="targetPath">The target path.</param> - 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<double>() - }); - - _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("<?xml version=\"1.0\"?><fontconfig><dir>{0}</dir><alias><family>Arial</family><prefer>Arial Unicode MS</prefer></alias></fontconfig>", 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); - } - } - } - - /// <summary> /// Gets the media info. /// </summary> /// <param name="inputFiles">The input files.</param> 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 e99d115a4..000000000 --- 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 b32dd9aec..000000000 --- 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.Server.Implementations/Providers/ProviderManager.cs b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs index 927631144..7d5a581d5 100644 --- a/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs +++ b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs @@ -128,7 +128,7 @@ namespace MediaBrowser.Server.Implementations.Providers // Put this check below the await because the needs refresh of the next tier of providers may depend on the previous ones running // This is the case for the fan art provider which depends on the movie and tv providers having run before them - if (provider.RequiresInternet && item.DontFetchMeta) + if (provider.RequiresInternet && item.DontFetchMeta && provider.EnforceDontFetchMetadata) { continue; } diff --git a/MediaBrowser.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs b/MediaBrowser.Server.Implementations/ScheduledTasks/PluginUpdateTask.cs index 293652007..e4f7134d7 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; - /// <summary> - /// Initializes a new instance of the <see cref="PluginUpdateTask" /> class. - /// </summary> - /// <param name="logger">The logger.</param> - /// <param name="installationManager">The installation manager.</param> - public PluginUpdateTask(ILogger logger, IInstallationManager installationManager) + private readonly IApplicationHost _appHost; + + public PluginUpdateTask(ILogger logger, IInstallationManager installationManager, IApplicationHost appHost) { _logger = logger; _installationManager = installationManager; + _appHost = appHost; } /// <summary> @@ -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.Server.Implementations/packages.config b/MediaBrowser.Server.Implementations/packages.config index 14e7ed2f4..5d9463408 100644 --- a/MediaBrowser.Server.Implementations/packages.config +++ b/MediaBrowser.Server.Implementations/packages.config @@ -7,12 +7,12 @@ <package id="Rx-Core" version="2.1.30214.0" targetFramework="net45" /> <package id="Rx-Interfaces" version="2.1.30214.0" targetFramework="net45" /> <package id="Rx-Linq" version="2.1.30214.0" targetFramework="net45" /> - <package id="ServiceStack" version="3.9.59" targetFramework="net45" /> + <package id="ServiceStack" version="3.9.62" targetFramework="net45" /> <package id="ServiceStack.Api.Swagger" version="3.9.59" targetFramework="net45" /> - <package id="ServiceStack.Common" version="3.9.59" targetFramework="net45" /> + <package id="ServiceStack.Common" version="3.9.62" targetFramework="net45" /> <package id="ServiceStack.OrmLite.SqlServer" version="3.9.43" targetFramework="net45" /> <package id="ServiceStack.Redis" version="3.9.43" targetFramework="net45" /> - <package id="ServiceStack.Text" version="3.9.59" targetFramework="net45" /> + <package id="ServiceStack.Text" version="3.9.62" targetFramework="net45" /> <package id="SharpZipLib" version="0.86.0" targetFramework="net45" /> <package id="System.Data.SQLite.x86" version="1.0.88.0" targetFramework="net45" /> </packages>
\ 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 49f983a72..0fcc06959 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'], |
