aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations')
-rw-r--r--MediaBrowser.Server.Implementations/EntryPoints/Notifications/RemoteNotifications.cs2
-rw-r--r--MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs13
-rw-r--r--MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj2
-rw-r--r--MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs103
-rw-r--r--MediaBrowser.Server.Implementations/MediaEncoder/fonts/fonts.conf9
5 files changed, 74 insertions, 55 deletions
diff --git a/MediaBrowser.Server.Implementations/EntryPoints/Notifications/RemoteNotifications.cs b/MediaBrowser.Server.Implementations/EntryPoints/Notifications/RemoteNotifications.cs
index e98a0a2c59..cb60975046 100644
--- a/MediaBrowser.Server.Implementations/EntryPoints/Notifications/RemoteNotifications.cs
+++ b/MediaBrowser.Server.Implementations/EntryPoints/Notifications/RemoteNotifications.cs
@@ -27,7 +27,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications
private readonly INotificationsRepository _notificationsRepo;
private readonly IUserManager _userManager;
- private readonly TimeSpan _frequency = TimeSpan.FromHours(3);
+ private readonly TimeSpan _frequency = TimeSpan.FromHours(6);
private readonly TimeSpan _maxAge = TimeSpan.FromDays(31);
public RemoteNotifications(IApplicationPaths appPaths, ILogger logger, IHttpClient httpClient, IJsonSerializer json, INotificationsRepository notificationsRepo, IUserManager userManager)
diff --git a/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs b/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs
index f6e5af7b51..c2e87cbd70 100644
--- a/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs
+++ b/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs
@@ -35,6 +35,15 @@ namespace MediaBrowser.Server.Implementations.Library
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
public bool ShouldIgnore(ItemResolveArgs args)
{
+ var filename = args.FileInfo.Name;
+
+ // Handle mac .DS_Store
+ // https://github.com/MediaBrowser/MediaBrowser/issues/427
+ if (filename.IndexOf("._", StringComparison.OrdinalIgnoreCase) == 0)
+ {
+ return true;
+ }
+
// Ignore hidden files and folders
if (args.IsHidden)
{
@@ -71,8 +80,6 @@ namespace MediaBrowser.Server.Implementations.Library
if (args.IsDirectory)
{
- var filename = args.FileInfo.Name;
-
// Ignore any folders in our list
if (IgnoreFolders.ContainsKey(filename))
{
@@ -100,8 +107,6 @@ namespace MediaBrowser.Server.Implementations.Library
{
if (args.Parent != null)
{
- var filename = args.FileInfo.Name;
-
if (string.Equals(Path.GetFileNameWithoutExtension(filename), BaseItem.ThemeSongFilename) && EntityResolutionHelper.IsAudioFile(filename))
{
return true;
diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
index d408e082ac..4991db8e2d 100644
--- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
+++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
@@ -230,8 +230,6 @@
<EmbeddedResource Include="MediaEncoder\readme.txt" />
</ItemGroup>
<ItemGroup>
- <EmbeddedResource Include="MediaEncoder\fonts\ARIALUNI.TTF" />
- <EmbeddedResource Include="MediaEncoder\fonts\fonts.conf" />
<EmbeddedResource Include="MediaEncoder\ffmpeg20130813.zip" />
<None Include="packages.config" />
</ItemGroup>
diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
index f5b5ea6c07..1eeade08dc 100644
--- a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
+++ b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
@@ -1,6 +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;
@@ -47,6 +48,8 @@ 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>
@@ -81,12 +84,13 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
/// <param name="appPaths">The app paths.</param>
/// <param name="jsonSerializer">The json serializer.</param>
public MediaEncoder(ILogger logger, IZipClient zipClient, IApplicationPaths appPaths,
- IJsonSerializer jsonSerializer)
+ IJsonSerializer jsonSerializer, IHttpClient httpClient)
{
_logger = logger;
_zipClient = zipClient;
_appPaths = appPaths;
_jsonSerializer = jsonSerializer;
+ _httpClient = httpClient;
// Not crazy about this but it's the only way to suppress ffmpeg crash dialog boxes
SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOALIGNMENTFAULTEXCEPT |
@@ -194,22 +198,30 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
/// <param name="assembly">The assembly.</param>
/// <param name="zipFileResourcePath">The zip file resource path.</param>
/// <param name="targetPath">The target path.</param>
- private void ExtractTools(Assembly assembly, string zipFileResourcePath, string targetPath)
+ private async void ExtractTools(Assembly assembly, string zipFileResourcePath, string targetPath)
{
using (var resourceStream = assembly.GetManifestResourceStream(zipFileResourcePath))
{
_zipClient.ExtractAll(resourceStream, targetPath, false);
}
- ExtractFonts(assembly, targetPath);
+ 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="assembly">The assembly.</param>
/// <param name="targetPath">The target path.</param>
- private async void ExtractFonts(Assembly assembly, string targetPath)
+ private async Task DownloadFonts(string targetPath)
{
var fontsDirectory = Path.Combine(targetPath, "fonts");
@@ -224,54 +236,67 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
if (!File.Exists(fontFile))
{
- using (var stream = assembly.GetManifestResourceStream(GetType().Namespace + ".fonts." + fontFilename))
+ 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
{
- using (
- var fileStream = new FileStream(fontFile, FileMode.Create, FileAccess.Write, FileShare.Read,
- StreamDefaults.DefaultFileStreamBufferSize,
- FileOptions.Asynchronous))
- {
- await stream.CopyToAsync(fileStream).ConfigureAwait(false);
- }
+ 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);
}
}
- await ExtractFontConfigFile(assembly, fontsDirectory).ConfigureAwait(false);
+ 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);
+ }
}
- /// <summary>
- /// Extracts the font config file.
- /// </summary>
- /// <param name="assembly">The assembly.</param>
- /// <param name="fontsDirectory">The fonts directory.</param>
- /// <returns>Task.</returns>
- private async Task ExtractFontConfigFile(Assembly assembly, string fontsDirectory)
+ private async Task WriteFontConfigFile(string fontsDirectory)
{
const string fontConfigFilename = "fonts.conf";
var fontConfigFile = Path.Combine(fontsDirectory, fontConfigFilename);
if (!File.Exists(fontConfigFile))
{
- using (
- var stream = assembly.GetManifestResourceStream(GetType().Namespace + ".fonts." + fontConfigFilename)
- )
- {
- using (var streamReader = new StreamReader(stream))
- {
- var contents = await streamReader.ReadToEndAsync().ConfigureAwait(false);
+ var contents = string.Format("<?xml version=\"1.0\"?><fontconfig><dir>{0}</dir><alias><family>Arial</family><prefer>Arial Unicode MS</prefer></alias></fontconfig>", fontsDirectory);
- contents = contents.Replace("<dir></dir>", "<dir>" + fontsDirectory + "</dir>");
+ var bytes = Encoding.UTF8.GetBytes(contents);
- 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);
- }
- }
+ using (var fileStream = new FileStream(fontConfigFile, FileMode.Create, FileAccess.Write,
+ FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize,
+ FileOptions.Asynchronous))
+ {
+ await fileStream.WriteAsync(bytes, 0, bytes.Length);
}
}
}
diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/fonts/fonts.conf b/MediaBrowser.Server.Implementations/MediaEncoder/fonts/fonts.conf
deleted file mode 100644
index 648bdb7b28..0000000000
--- a/MediaBrowser.Server.Implementations/MediaEncoder/fonts/fonts.conf
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0"?>
-<fontconfig>
-
-<dir></dir>
- <alias>
- <family>Arial</family>
- <prefer>Arial Unicode MS</prefer>
- </alias>
-</fontconfig> \ No newline at end of file