diff --git a/Emby.Drawing/Emby.Drawing.csproj b/Emby.Drawing/Emby.Drawing.csproj
index 8aba4263c..ab53f7550 100644
--- a/Emby.Drawing/Emby.Drawing.csproj
+++ b/Emby.Drawing/Emby.Drawing.csproj
@@ -69,7 +69,6 @@
-
diff --git a/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs b/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs
index 78633472b..6ff40d1cf 100644
--- a/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs
+++ b/Emby.Drawing/ImageMagick/ImageMagickEncoder.cs
@@ -1,11 +1,13 @@
-using System.Linq;
+using System.Threading.Tasks;
using ImageMagickSharp;
using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Model.Drawing;
using MediaBrowser.Model.Logging;
using System;
using System.IO;
+using System.Linq;
namespace Emby.Drawing.ImageMagick
{
@@ -13,11 +15,13 @@ namespace Emby.Drawing.ImageMagick
{
private readonly ILogger _logger;
private readonly IApplicationPaths _appPaths;
+ private readonly IHttpClient _httpClient;
- public ImageMagickEncoder(ILogger logger, IApplicationPaths appPaths)
+ public ImageMagickEncoder(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient)
{
_logger = logger;
_appPaths = appPaths;
+ _httpClient = httpClient;
LogImageMagickVersion();
}
@@ -177,7 +181,8 @@ namespace Emby.Drawing.ImageMagick
{
var currentImageSize = new ImageSize(imageWidth, imageHeight);
- new PlayedIndicatorDrawer(_appPaths).DrawPlayedIndicator(wand, currentImageSize);
+ var task = new PlayedIndicatorDrawer(_appPaths, _httpClient).DrawPlayedIndicator(wand, currentImageSize);
+ Task.WaitAll(task);
}
else if (options.UnplayedCount.HasValue)
{
diff --git a/Emby.Drawing/ImageMagick/PlayedIndicatorDrawer.cs b/Emby.Drawing/ImageMagick/PlayedIndicatorDrawer.cs
index 5eeb15771..1c751de1f 100644
--- a/Emby.Drawing/ImageMagick/PlayedIndicatorDrawer.cs
+++ b/Emby.Drawing/ImageMagick/PlayedIndicatorDrawer.cs
@@ -1,8 +1,10 @@
using ImageMagickSharp;
using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Net;
using MediaBrowser.Model.Drawing;
using System;
using System.IO;
+using System.Threading.Tasks;
namespace Emby.Drawing.ImageMagick
{
@@ -12,13 +14,15 @@ namespace Emby.Drawing.ImageMagick
private const int OffsetFromTopRightCorner = 38;
private readonly IApplicationPaths _appPaths;
+ private readonly IHttpClient _iHttpClient;
- public PlayedIndicatorDrawer(IApplicationPaths appPaths)
+ public PlayedIndicatorDrawer(IApplicationPaths appPaths, IHttpClient iHttpClient)
{
_appPaths = appPaths;
+ _iHttpClient = iHttpClient;
}
- public void DrawPlayedIndicator(MagickWand wand, ImageSize imageSize)
+ public async Task DrawPlayedIndicator(MagickWand wand, ImageSize imageSize)
{
var x = imageSize.Width - OffsetFromTopRightCorner;
@@ -34,7 +38,7 @@ namespace Emby.Drawing.ImageMagick
pixel.Opacity = 0;
pixel.Color = "white";
draw.FillColor = pixel;
- draw.Font = ExtractFont("webdings.ttf", _appPaths);
+ draw.Font = await DownloadFont("webdings.ttf", "https://github.com/MediaBrowser/Emby.Resources/raw/master/fonts/webdings.ttf", _appPaths, _iHttpClient).ConfigureAwait(false);
draw.FontSize = FontSize;
draw.FontStyle = FontStyleType.NormalStyle;
draw.TextAlignment = TextAlignType.CenterAlign;
@@ -77,7 +81,37 @@ namespace Emby.Drawing.ImageMagick
}
catch (IOException)
{
-
+
+ }
+
+ return tempPath;
+ }
+
+ internal static async Task DownloadFont(string name, string url, IApplicationPaths paths, IHttpClient httpClient)
+ {
+ var filePath = Path.Combine(paths.ProgramDataPath, "fonts", name);
+
+ if (File.Exists(filePath))
+ {
+ return filePath;
+ }
+
+ var tempPath = await httpClient.GetTempFile(new HttpRequestOptions
+ {
+ Url = url,
+ Progress = new Progress()
+
+ }).ConfigureAwait(false);
+
+ Directory.CreateDirectory(Path.GetDirectoryName(filePath));
+
+ try
+ {
+ File.Copy(tempPath, filePath, false);
+ }
+ catch (IOException)
+ {
+
}
return tempPath;
diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs
index d4b5be584..564cfa93a 100644
--- a/MediaBrowser.Api/BaseApiService.cs
+++ b/MediaBrowser.Api/BaseApiService.cs
@@ -1,5 +1,4 @@
-using System.Threading.Tasks;
-using MediaBrowser.Controller.Dto;
+using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
@@ -12,6 +11,7 @@ using ServiceStack.Web;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Threading.Tasks;
namespace MediaBrowser.Api
{
@@ -344,9 +344,7 @@ namespace MediaBrowser.Api
return name;
}
- return libraryManager.RootFolder
- .GetRecursiveChildren()
- .SelectMany(i => i.People)
+ return libraryManager.GetAllPeople()
.Select(i => i.Name)
.DistinctNames()
.FirstOrDefault(i =>
@@ -364,7 +362,8 @@ namespace MediaBrowser.Api
var first = pathInfo.GetArgumentValue(0);
// backwards compatibility
- if (string.Equals(first, "mediabrowser", StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(first, "mediabrowser", StringComparison.OrdinalIgnoreCase) ||
+ string.Equals(first, "emby", StringComparison.OrdinalIgnoreCase))
{
index++;
}
diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs
index 8f7edabbb..b8ae9392a 100644
--- a/MediaBrowser.Api/ItemUpdateService.cs
+++ b/MediaBrowser.Api/ItemUpdateService.cs
@@ -218,6 +218,11 @@ namespace MediaBrowser.Api
await item.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
+ if (request.People != null)
+ {
+ await _libraryManager.UpdatePeople(item, request.People.Select(x => new PersonInfo { Name = x.Name, Role = x.Role, Type = x.Type }).ToList());
+ }
+
if (isLockedChanged && item.IsFolder)
{
var folder = (Folder)item;
@@ -303,11 +308,6 @@ namespace MediaBrowser.Api
item.Studios = request.Studios.Select(x => x.Name).ToList();
}
- if (request.People != null)
- {
- item.People = request.People.Select(x => new PersonInfo { Name = x.Name, Role = x.Role, Type = x.Type }).ToList();
- }
-
if (request.DateCreated.HasValue)
{
item.DateCreated = NormalizeDateTime(request.DateCreated.Value);
diff --git a/MediaBrowser.Api/Movies/MoviesService.cs b/MediaBrowser.Api/Movies/MoviesService.cs
index 513bde871..17eb448bc 100644
--- a/MediaBrowser.Api/Movies/MoviesService.cs
+++ b/MediaBrowser.Api/Movies/MoviesService.cs
@@ -165,7 +165,7 @@ namespace MediaBrowser.Api.Movies
return ToOptimizedResult(result);
}
- private async Task GetSimilarItemsResult(BaseGetSimilarItemsFromItem request, Func includeInSearch, Func getSimilarityScore)
+ private async Task GetSimilarItemsResult(BaseGetSimilarItemsFromItem request, Func includeInSearch, Func getSimilarityScore)
{
var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null;
@@ -214,7 +214,7 @@ namespace MediaBrowser.Api.Movies
}
}
- var items = SimilarItemsHelper.GetSimilaritems(item, list, getSimilarityScore).ToList();
+ var items = SimilarItemsHelper.GetSimilaritems(item, _libraryManager, list, getSimilarityScore).ToList();
IEnumerable returnItems = items;
@@ -339,7 +339,7 @@ namespace MediaBrowser.Api.Movies
foreach (var director in directors)
{
var items = allMovies
- .Where(i => i.People.Any(p => string.Equals(p.Type, PersonType.Director, StringComparison.OrdinalIgnoreCase) && string.Equals(p.Name, director, StringComparison.OrdinalIgnoreCase)))
+ .Where(i => _libraryManager.GetPeople(i).Any(p => string.Equals(p.Type, PersonType.Director, StringComparison.OrdinalIgnoreCase) && string.Equals(p.Name, director, StringComparison.OrdinalIgnoreCase)))
.Take(itemLimit)
.ToList();
@@ -363,7 +363,7 @@ namespace MediaBrowser.Api.Movies
foreach (var name in names)
{
var items = allMovies
- .Where(i => i.People.Any(p => string.Equals(p.Name, name, StringComparison.OrdinalIgnoreCase)))
+ .Where(i => _libraryManager.GetPeople(i).Any(p => string.Equals(p.Name, name, StringComparison.OrdinalIgnoreCase)))
.Take(itemLimit)
.ToList();
@@ -387,7 +387,7 @@ namespace MediaBrowser.Api.Movies
foreach (var item in baselineItems)
{
var similar = SimilarItemsHelper
- .GetSimilaritems(item, allMovies, SimilarItemsHelper.GetSimiliarityScore)
+ .GetSimilaritems(item, _libraryManager, allMovies, SimilarItemsHelper.GetSimiliarityScore)
.Take(itemLimit)
.ToList();
@@ -408,7 +408,7 @@ namespace MediaBrowser.Api.Movies
{
// Get the two leading actors for all movies
return items
- .SelectMany(i => i.People.Where(p => !string.Equals(PersonType.Director, p.Type, StringComparison.OrdinalIgnoreCase)).Take(2))
+ .SelectMany(i => _libraryManager.GetPeople(i).Where(p => !string.Equals(PersonType.Director, p.Type, StringComparison.OrdinalIgnoreCase)).Take(2))
.Select(i => i.Name)
.DistinctNames();
}
@@ -416,7 +416,7 @@ namespace MediaBrowser.Api.Movies
private IEnumerable GetDirectors(IEnumerable items)
{
return items
- .Select(i => i.People.FirstOrDefault(p => string.Equals(PersonType.Director, p.Type, StringComparison.OrdinalIgnoreCase)))
+ .Select(i => _libraryManager.GetPeople(i).FirstOrDefault(p => string.Equals(PersonType.Director, p.Type, StringComparison.OrdinalIgnoreCase)))
.Where(i => i != null)
.Select(i => i.Name)
.DistinctNames();
diff --git a/MediaBrowser.Api/Music/AlbumsService.cs b/MediaBrowser.Api/Music/AlbumsService.cs
index 37f79bf20..3dc459bd2 100644
--- a/MediaBrowser.Api/Music/AlbumsService.cs
+++ b/MediaBrowser.Api/Music/AlbumsService.cs
@@ -69,10 +69,11 @@ namespace MediaBrowser.Api.Music
///
/// The item1.
/// The item2.
+ /// The library manager.
/// System.Int32.
- private int GetAlbumSimilarityScore(BaseItem item1, BaseItem item2)
+ private int GetAlbumSimilarityScore(BaseItem item1, BaseItem item2, ILibraryManager libraryManager)
{
- var points = SimilarItemsHelper.GetSimiliarityScore(item1, item2);
+ var points = SimilarItemsHelper.GetSimiliarityScore(item1, item2, libraryManager);
var album1 = (MusicAlbum)item1;
var album2 = (MusicAlbum)item2;
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs
index 71ef689a7..41d785a34 100644
--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs
+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs
@@ -772,6 +772,11 @@ namespace MediaBrowser.Api.Playback
? null
: audioStream.Channels;
+ if (inputChannels <= 0)
+ {
+ inputChannels = null;
+ }
+
var codec = outputAudioCodec ?? string.Empty;
if (codec.IndexOf("wma", StringComparison.OrdinalIgnoreCase) != -1)
diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
index ccbf182fe..ab57e561f 100644
--- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
+++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
@@ -294,6 +294,10 @@ namespace MediaBrowser.Api.Playback.Hls
}
}
}
+ }
+ catch (DirectoryNotFoundException)
+ {
+
}
catch (FileNotFoundException)
{
diff --git a/MediaBrowser.Api/Reports/ReportsService.cs b/MediaBrowser.Api/Reports/ReportsService.cs
index 2c0728719..ebf5183c5 100644
--- a/MediaBrowser.Api/Reports/ReportsService.cs
+++ b/MediaBrowser.Api/Reports/ReportsService.cs
@@ -24,1219 +24,1139 @@ using System.Text;
namespace MediaBrowser.Api.Reports
{
- /// The reports service.
- ///
- public class ReportsService : BaseApiService
- {
- #region [Constructors]
+ /// The reports service.
+ ///
+ public class ReportsService : BaseApiService
+ {
- ///
- /// Initializes a new instance of the MediaBrowser.Api.Reports.ReportsService class.
- /// Manager for user.
- /// Manager for library.
- /// The localization.
- /// Manager for activity.
- public ReportsService(IUserManager userManager, ILibraryManager libraryManager, ILocalizationManager localization, IActivityManager activityManager, IActivityRepository repo)
- {
- _userManager = userManager;
- _libraryManager = libraryManager;
- _localization = localization;
- _activityManager = activityManager;
- _repo = repo;
- }
- #endregion
+ /// Manager for user.
+ private readonly IUserManager _userManager;
- #region [Private Fields]
+ /// Manager for library.
+ private readonly ILibraryManager _libraryManager;
+ /// The localization.
+ private readonly ILocalizationManager _localization;
- private readonly IActivityManager _activityManager; ///< Manager for activity
+ ///
+ /// Initializes a new instance of the MediaBrowser.Api.Reports.ReportsService class.
+ /// Manager for user.
+ /// Manager for library.
+ /// The localization.
+ public ReportsService(IUserManager userManager, ILibraryManager libraryManager, ILocalizationManager localization)
+ {
+ _userManager = userManager;
+ _libraryManager = libraryManager;
+ _localization = localization;
+ }
- /// Manager for library.
- private readonly ILibraryManager _libraryManager; ///< Manager for library
- /// The localization.
+ /// Gets the given request.
+ /// The request.
+ /// A Task<object>
+ public async Task
+
+
+