diff options
Diffstat (limited to 'MediaBrowser.Api')
17 files changed, 150 insertions, 77 deletions
diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index 1a57ff62dd..0f1d240d0c 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -174,14 +174,15 @@ namespace MediaBrowser.Api return options; } - protected MusicArtist GetArtist(string name, ILibraryManager libraryManager) + protected MusicArtist GetArtist(string name, ILibraryManager libraryManager, DtoOptions dtoOptions) { if (name.IndexOf(BaseItem.SlugChar) != -1) { var result = libraryManager.GetItemList(new InternalItemsQuery { SlugName = name, - IncludeItemTypes = new[] { typeof(MusicArtist).Name } + IncludeItemTypes = new[] { typeof(MusicArtist).Name }, + DtoOptions = dtoOptions }).OfType<MusicArtist>().FirstOrDefault(); @@ -191,17 +192,18 @@ namespace MediaBrowser.Api } } - return libraryManager.GetArtist(name); + return libraryManager.GetArtist(name, dtoOptions); } - protected Studio GetStudio(string name, ILibraryManager libraryManager) + protected Studio GetStudio(string name, ILibraryManager libraryManager, DtoOptions dtoOptions) { if (name.IndexOf(BaseItem.SlugChar) != -1) { var result = libraryManager.GetItemList(new InternalItemsQuery { SlugName = name, - IncludeItemTypes = new[] { typeof(Studio).Name } + IncludeItemTypes = new[] { typeof(Studio).Name }, + DtoOptions = dtoOptions }).OfType<Studio>().FirstOrDefault(); @@ -214,14 +216,15 @@ namespace MediaBrowser.Api return libraryManager.GetStudio(name); } - protected Genre GetGenre(string name, ILibraryManager libraryManager) + protected Genre GetGenre(string name, ILibraryManager libraryManager, DtoOptions dtoOptions) { if (name.IndexOf(BaseItem.SlugChar) != -1) { var result = libraryManager.GetItemList(new InternalItemsQuery { SlugName = name, - IncludeItemTypes = new[] { typeof(Genre).Name } + IncludeItemTypes = new[] { typeof(Genre).Name }, + DtoOptions = dtoOptions }).OfType<Genre>().FirstOrDefault(); @@ -234,14 +237,15 @@ namespace MediaBrowser.Api return libraryManager.GetGenre(name); } - protected MusicGenre GetMusicGenre(string name, ILibraryManager libraryManager) + protected MusicGenre GetMusicGenre(string name, ILibraryManager libraryManager, DtoOptions dtoOptions) { if (name.IndexOf(BaseItem.SlugChar) != -1) { var result = libraryManager.GetItemList(new InternalItemsQuery { SlugName = name, - IncludeItemTypes = new[] { typeof(MusicGenre).Name } + IncludeItemTypes = new[] { typeof(MusicGenre).Name }, + DtoOptions = dtoOptions }).OfType<MusicGenre>().FirstOrDefault(); @@ -254,14 +258,15 @@ namespace MediaBrowser.Api return libraryManager.GetMusicGenre(name); } - protected GameGenre GetGameGenre(string name, ILibraryManager libraryManager) + protected GameGenre GetGameGenre(string name, ILibraryManager libraryManager, DtoOptions dtoOptions) { if (name.IndexOf(BaseItem.SlugChar) != -1) { var result = libraryManager.GetItemList(new InternalItemsQuery { SlugName = name, - IncludeItemTypes = new[] { typeof(GameGenre).Name } + IncludeItemTypes = new[] { typeof(GameGenre).Name }, + DtoOptions = dtoOptions }).OfType<GameGenre>().FirstOrDefault(); @@ -274,14 +279,15 @@ namespace MediaBrowser.Api return libraryManager.GetGameGenre(name); } - protected Person GetPerson(string name, ILibraryManager libraryManager) + protected Person GetPerson(string name, ILibraryManager libraryManager, DtoOptions dtoOptions) { if (name.IndexOf(BaseItem.SlugChar) != -1) { var result = libraryManager.GetItemList(new InternalItemsQuery { SlugName = name, - IncludeItemTypes = new[] { typeof(Person).Name } + IncludeItemTypes = new[] { typeof(Person).Name }, + DtoOptions = dtoOptions }).OfType<Person>().FirstOrDefault(); @@ -329,37 +335,33 @@ namespace MediaBrowser.Api /// <summary> /// Gets the name of the item by. /// </summary> - /// <param name="name">The name.</param> - /// <param name="type">The type.</param> - /// <param name="libraryManager">The library manager.</param> - /// <returns>Task{BaseItem}.</returns> - protected BaseItem GetItemByName(string name, string type, ILibraryManager libraryManager) + protected BaseItem GetItemByName(string name, string type, ILibraryManager libraryManager, DtoOptions dtoOptions) { BaseItem item; if (type.IndexOf("Person", StringComparison.OrdinalIgnoreCase) == 0) { - item = GetPerson(name, libraryManager); + item = GetPerson(name, libraryManager, dtoOptions); } else if (type.IndexOf("Artist", StringComparison.OrdinalIgnoreCase) == 0) { - item = GetArtist(name, libraryManager); + item = GetArtist(name, libraryManager, dtoOptions); } else if (type.IndexOf("Genre", StringComparison.OrdinalIgnoreCase) == 0) { - item = GetGenre(name, libraryManager); + item = GetGenre(name, libraryManager, dtoOptions); } else if (type.IndexOf("MusicGenre", StringComparison.OrdinalIgnoreCase) == 0) { - item = GetMusicGenre(name, libraryManager); + item = GetMusicGenre(name, libraryManager, dtoOptions); } else if (type.IndexOf("GameGenre", StringComparison.OrdinalIgnoreCase) == 0) { - item = GetGameGenre(name, libraryManager); + item = GetGameGenre(name, libraryManager, dtoOptions); } else if (type.IndexOf("Studio", StringComparison.OrdinalIgnoreCase) == 0) { - item = GetStudio(name, libraryManager); + item = GetStudio(name, libraryManager, dtoOptions); } else if (type.IndexOf("Year", StringComparison.OrdinalIgnoreCase) == 0) { diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs index cbbaa82b80..6c4cc22170 100644 --- a/MediaBrowser.Api/Images/ImageService.cs +++ b/MediaBrowser.Api/Images/ImageService.cs @@ -15,6 +15,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common.IO; +using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; using MediaBrowser.Model.Services; @@ -406,7 +407,7 @@ namespace MediaBrowser.Api.Images { var type = GetPathValue(0); - var item = GetItemByName(request.Name, type, _libraryManager); + var item = GetItemByName(request.Name, type, _libraryManager, new DtoOptions(false)); return GetImage(request, item, false); } @@ -415,7 +416,7 @@ namespace MediaBrowser.Api.Images { var type = GetPathValue(0); - var item = GetItemByName(request.Name, type, _libraryManager); + var item = GetItemByName(request.Name, type, _libraryManager, new DtoOptions(false)); return GetImage(request, item, true); } diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index 3494754d0a..a90c8d9e78 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -22,6 +22,7 @@ using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.IO; using MediaBrowser.Model.Services; +using MediaBrowser.Model.System; namespace MediaBrowser.Api.LiveTv { @@ -698,8 +699,9 @@ namespace MediaBrowser.Api.LiveTv private readonly IFileSystem _fileSystem; private readonly IAuthorizationContext _authContext; private readonly ISessionContext _sessionContext; + private readonly IEnvironmentInfo _environment; - public LiveTvService(ILiveTvManager liveTvManager, IUserManager userManager, IServerConfigurationManager config, IHttpClient httpClient, ILibraryManager libraryManager, IDtoService dtoService, IFileSystem fileSystem, IAuthorizationContext authContext, ISessionContext sessionContext) + public LiveTvService(ILiveTvManager liveTvManager, IUserManager userManager, IServerConfigurationManager config, IHttpClient httpClient, ILibraryManager libraryManager, IDtoService dtoService, IFileSystem fileSystem, IAuthorizationContext authContext, ISessionContext sessionContext, IEnvironmentInfo environment) { _liveTvManager = liveTvManager; _userManager = userManager; @@ -710,6 +712,7 @@ namespace MediaBrowser.Api.LiveTv _fileSystem = fileSystem; _authContext = authContext; _sessionContext = sessionContext; + _environment = environment; } public object Get(GetTunerHostTypes request) @@ -731,7 +734,7 @@ namespace MediaBrowser.Api.LiveTv outputHeaders["Content-Type"] = Model.Net.MimeTypes.GetMimeType(path); - return new ProgressiveFileCopier(_fileSystem, path, outputHeaders, null, Logger, CancellationToken.None) + return new ProgressiveFileCopier(_fileSystem, path, outputHeaders, null, Logger, _environment, CancellationToken.None) { AllowEndOfFile = false }; @@ -750,7 +753,7 @@ namespace MediaBrowser.Api.LiveTv outputHeaders["Content-Type"] = Model.Net.MimeTypes.GetMimeType("file." + request.Container); - return new ProgressiveFileCopier(directStreamProvider, outputHeaders, null, Logger, CancellationToken.None) + return new ProgressiveFileCopier(directStreamProvider, outputHeaders, null, Logger, _environment, CancellationToken.None) { AllowEndOfFile = false }; diff --git a/MediaBrowser.Api/Music/InstantMixService.cs b/MediaBrowser.Api/Music/InstantMixService.cs index 797edd9402..3cb29de072 100644 --- a/MediaBrowser.Api/Music/InstantMixService.cs +++ b/MediaBrowser.Api/Music/InstantMixService.cs @@ -171,7 +171,7 @@ namespace MediaBrowser.Api.Music public Task<object> Get(GetInstantMixFromArtist request) { var user = _userManager.GetUserById(request.UserId); - var artist = _libraryManager.GetArtist(request.Name); + var artist = _libraryManager.GetArtist(request.Name, new DtoOptions(false)); var dtoOptions = GetDtoOptions(_authContext, request); diff --git a/MediaBrowser.Api/Playback/Progressive/AudioService.cs b/MediaBrowser.Api/Playback/Progressive/AudioService.cs index f0386d5ba1..c0257b0079 100644 --- a/MediaBrowser.Api/Playback/Progressive/AudioService.cs +++ b/MediaBrowser.Api/Playback/Progressive/AudioService.cs @@ -14,6 +14,7 @@ using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Net; using MediaBrowser.Model.IO; using MediaBrowser.Model.Services; +using MediaBrowser.Model.System; namespace MediaBrowser.Api.Playback.Progressive { @@ -35,6 +36,10 @@ namespace MediaBrowser.Api.Playback.Progressive //[Authenticated] public class AudioService : BaseProgressiveStreamingService { + public AudioService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext, IImageProcessor imageProcessor, IEnvironmentInfo environmentInfo) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer, authorizationContext, imageProcessor, environmentInfo) + { + } + /// <summary> /// Gets the specified request. /// </summary> @@ -61,9 +66,5 @@ namespace MediaBrowser.Api.Playback.Progressive return EncodingHelper.GetProgressiveAudioFullCommandLine(state, encodingOptions, outputPath); } - - public AudioService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext, IImageProcessor imageProcessor) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer, authorizationContext, imageProcessor) - { - } } } diff --git a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs index 646a91c275..db5c78a2f2 100644 --- a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs +++ b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs @@ -16,6 +16,7 @@ using System.IO; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.Services; +using MediaBrowser.Model.System; namespace MediaBrowser.Api.Playback.Progressive { @@ -25,10 +26,12 @@ namespace MediaBrowser.Api.Playback.Progressive public abstract class BaseProgressiveStreamingService : BaseStreamingService { protected readonly IImageProcessor ImageProcessor; + protected readonly IEnvironmentInfo EnvironmentInfo; - public BaseProgressiveStreamingService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext, IImageProcessor imageProcessor) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer, authorizationContext) + public BaseProgressiveStreamingService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext, IImageProcessor imageProcessor, IEnvironmentInfo environmentInfo) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer, authorizationContext) { ImageProcessor = imageProcessor; + EnvironmentInfo = environmentInfo; } /// <summary> @@ -130,7 +133,7 @@ namespace MediaBrowser.Api.Playback.Progressive // TODO: Don't hardcode this outputHeaders["Content-Type"] = MediaBrowser.Model.Net.MimeTypes.GetMimeType("file.ts"); - return new ProgressiveFileCopier(state.DirectStreamProvider, outputHeaders, null, Logger, CancellationToken.None) + return new ProgressiveFileCopier(state.DirectStreamProvider, outputHeaders, null, Logger, EnvironmentInfo, CancellationToken.None) { AllowEndOfFile = false }; @@ -174,7 +177,7 @@ namespace MediaBrowser.Api.Playback.Progressive outputHeaders["Content-Type"] = contentType; - return new ProgressiveFileCopier(FileSystem, state.MediaPath, outputHeaders, null, Logger, CancellationToken.None) + return new ProgressiveFileCopier(FileSystem, state.MediaPath, outputHeaders, null, Logger, EnvironmentInfo, CancellationToken.None) { AllowEndOfFile = false }; @@ -398,7 +401,7 @@ namespace MediaBrowser.Api.Playback.Progressive outputHeaders[item.Key] = item.Value; } - return new ProgressiveFileCopier(FileSystem, outputPath, outputHeaders, job, Logger, CancellationToken.None); + return new ProgressiveFileCopier(FileSystem, outputPath, outputHeaders, job, Logger, EnvironmentInfo, CancellationToken.None); } finally { diff --git a/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs b/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs index a33fbcbcfd..d4d4689134 100644 --- a/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs +++ b/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs @@ -10,6 +10,7 @@ using MediaBrowser.Common.IO; using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Library; using MediaBrowser.Model.Services; +using MediaBrowser.Model.System; namespace MediaBrowser.Api.Playback.Progressive { @@ -22,16 +23,16 @@ namespace MediaBrowser.Api.Playback.Progressive private readonly CancellationToken _cancellationToken; private readonly Dictionary<string, string> _outputHeaders; - // 256k - private const int BufferSize = 81920; + const int StreamCopyToBufferSize = 81920; private long _bytesWritten = 0; public long StartPosition { get; set; } public bool AllowEndOfFile = true; private readonly IDirectStreamProvider _directStreamProvider; + private readonly IEnvironmentInfo _environment; - public ProgressiveFileCopier(IFileSystem fileSystem, string path, Dictionary<string, string> outputHeaders, TranscodingJob job, ILogger logger, CancellationToken cancellationToken) + public ProgressiveFileCopier(IFileSystem fileSystem, string path, Dictionary<string, string> outputHeaders, TranscodingJob job, ILogger logger, IEnvironmentInfo environment, CancellationToken cancellationToken) { _fileSystem = fileSystem; _path = path; @@ -39,15 +40,17 @@ namespace MediaBrowser.Api.Playback.Progressive _job = job; _logger = logger; _cancellationToken = cancellationToken; + _environment = environment; } - public ProgressiveFileCopier(IDirectStreamProvider directStreamProvider, Dictionary<string, string> outputHeaders, TranscodingJob job, ILogger logger, CancellationToken cancellationToken) + public ProgressiveFileCopier(IDirectStreamProvider directStreamProvider, Dictionary<string, string> outputHeaders, TranscodingJob job, ILogger logger, IEnvironmentInfo environment, CancellationToken cancellationToken) { _directStreamProvider = directStreamProvider; _outputHeaders = outputHeaders; _job = job; _logger = logger; _cancellationToken = cancellationToken; + _environment = environment; } public IDictionary<string, string> Headers @@ -58,33 +61,55 @@ namespace MediaBrowser.Api.Playback.Progressive } } - private Stream GetInputStream() + private Stream GetInputStream(bool allowAsyncFileRead) { - return _fileSystem.GetFileStream(_path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite, true); + var fileOpenOptions = StartPosition > 0 + ? FileOpenOptions.RandomAccess + : FileOpenOptions.SequentialScan; + + if (allowAsyncFileRead) + { + fileOpenOptions |= FileOpenOptions.Asynchronous; + } + + return _fileSystem.GetFileStream(_path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite, fileOpenOptions); } public async Task WriteToAsync(Stream outputStream, CancellationToken cancellationToken) { + cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, _cancellationToken).Token; + try { if (_directStreamProvider != null) { - await _directStreamProvider.CopyToAsync(outputStream, _cancellationToken).ConfigureAwait(false); + await _directStreamProvider.CopyToAsync(outputStream, cancellationToken).ConfigureAwait(false); return; } var eofCount = 0; - using (var inputStream = GetInputStream()) + // use non-async filestream along with read due to https://github.com/dotnet/corefx/issues/6039 + var allowAsyncFileRead = _environment.OperatingSystem != OperatingSystem.Windows; + + using (var inputStream = GetInputStream(allowAsyncFileRead)) { if (StartPosition > 0) { inputStream.Position = StartPosition; } - while (eofCount < 15 || !AllowEndOfFile) + while (eofCount < 20 || !AllowEndOfFile) { - var bytesRead = await CopyToAsyncInternal(inputStream, outputStream, BufferSize, _cancellationToken).ConfigureAwait(false); + int bytesRead; + if (allowAsyncFileRead) + { + bytesRead = await CopyToInternalAsync(inputStream, outputStream, cancellationToken).ConfigureAwait(false); + } + else + { + bytesRead = await CopyToInternalAsyncWithSyncRead(inputStream, outputStream, cancellationToken).ConfigureAwait(false); + } //var position = fs.Position; //_logger.Debug("Streamed {0} bytes to position {1} from file {2}", bytesRead, position, path); @@ -95,7 +120,7 @@ namespace MediaBrowser.Api.Playback.Progressive { eofCount++; } - await Task.Delay(100, _cancellationToken).ConfigureAwait(false); + await Task.Delay(100, cancellationToken).ConfigureAwait(false); } else { @@ -113,22 +138,54 @@ namespace MediaBrowser.Api.Playback.Progressive } } - private async Task<int> CopyToAsyncInternal(Stream source, Stream destination, Int32 bufferSize, CancellationToken cancellationToken) + private async Task<int> CopyToInternalAsyncWithSyncRead(Stream source, Stream destination, CancellationToken cancellationToken) { - byte[] buffer = new byte[bufferSize]; + var array = new byte[StreamCopyToBufferSize]; int bytesRead; int totalBytesRead = 0; - while ((bytesRead = await source.ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false)) != 0) + while ((bytesRead = source.Read(array, 0, array.Length)) != 0) { - await destination.WriteAsync(buffer, 0, bytesRead, cancellationToken).ConfigureAwait(false); + var bytesToWrite = bytesRead; + + if (bytesToWrite > 0) + { + await destination.WriteAsync(array, 0, Convert.ToInt32(bytesToWrite), cancellationToken).ConfigureAwait(false); - _bytesWritten += bytesRead; - totalBytesRead += bytesRead; + _bytesWritten += bytesRead; + totalBytesRead += bytesRead; - if (_job != null) + if (_job != null) + { + _job.BytesDownloaded = Math.Max(_job.BytesDownloaded ?? _bytesWritten, _bytesWritten); + } + } + } + + return totalBytesRead; + } + + private async Task<int> CopyToInternalAsync(Stream source, Stream destination, CancellationToken cancellationToken) + { + var array = new byte[StreamCopyToBufferSize]; + int bytesRead; + int totalBytesRead = 0; + + while ((bytesRead = await source.ReadAsync(array, 0, array.Length, cancellationToken).ConfigureAwait(false)) != 0) + { + var bytesToWrite = bytesRead; + + if (bytesToWrite > 0) { - _job.BytesDownloaded = Math.Max(_job.BytesDownloaded ?? _bytesWritten, _bytesWritten); + await destination.WriteAsync(array, 0, Convert.ToInt32(bytesToWrite), cancellationToken).ConfigureAwait(false); + + _bytesWritten += bytesRead; + totalBytesRead += bytesRead; + + if (_job != null) + { + _job.BytesDownloaded = Math.Max(_job.BytesDownloaded ?? _bytesWritten, _bytesWritten); + } } } diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs index c36a27690a..5e21f6a841 100644 --- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs +++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs @@ -9,6 +9,7 @@ using MediaBrowser.Model.Serialization; using System.Threading.Tasks; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Services; +using MediaBrowser.Model.System; namespace MediaBrowser.Api.Playback.Progressive { @@ -66,7 +67,7 @@ namespace MediaBrowser.Api.Playback.Progressive //[Authenticated] public class VideoService : BaseProgressiveStreamingService { - public VideoService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext, IImageProcessor imageProcessor) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer, authorizationContext, imageProcessor) + public VideoService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext, IImageProcessor imageProcessor, IEnvironmentInfo environmentInfo) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer, authorizationContext, imageProcessor, environmentInfo) { } diff --git a/MediaBrowser.Api/Playback/UniversalAudioService.cs b/MediaBrowser.Api/Playback/UniversalAudioService.cs index ae64623df9..c28014f9bc 100644 --- a/MediaBrowser.Api/Playback/UniversalAudioService.cs +++ b/MediaBrowser.Api/Playback/UniversalAudioService.cs @@ -18,6 +18,7 @@ using MediaBrowser.Model.IO; using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Services; +using MediaBrowser.Model.System; namespace MediaBrowser.Api.Playback { @@ -63,7 +64,7 @@ namespace MediaBrowser.Api.Playback //[Authenticated] public class UniversalAudioService : BaseApiService { - public UniversalAudioService(IServerConfigurationManager serverConfigurationManager, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, IDeviceManager deviceManager, ISubtitleEncoder subtitleEncoder, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext, IImageProcessor imageProcessor, INetworkManager networkManager) + public UniversalAudioService(IServerConfigurationManager serverConfigurationManager, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, IDeviceManager deviceManager, ISubtitleEncoder subtitleEncoder, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext, IImageProcessor imageProcessor, INetworkManager networkManager, IEnvironmentInfo environmentInfo) { ServerConfigurationManager = serverConfigurationManager; UserManager = userManager; @@ -80,6 +81,7 @@ namespace MediaBrowser.Api.Playback AuthorizationContext = authorizationContext; ImageProcessor = imageProcessor; NetworkManager = networkManager; + EnvironmentInfo = environmentInfo; } protected IServerConfigurationManager ServerConfigurationManager { get; private set; } @@ -97,6 +99,7 @@ namespace MediaBrowser.Api.Playback protected IAuthorizationContext AuthorizationContext { get; private set; } protected IImageProcessor ImageProcessor { get; private set; } protected INetworkManager NetworkManager { get; private set; } + protected IEnvironmentInfo EnvironmentInfo { get; private set; } public Task<object> Get(GetUniversalAudioStream request) { @@ -263,7 +266,8 @@ namespace MediaBrowser.Api.Playback ZipClient, JsonSerializer, AuthorizationContext, - ImageProcessor) + ImageProcessor, + EnvironmentInfo) { Request = Request }; diff --git a/MediaBrowser.Api/UserLibrary/ArtistsService.cs b/MediaBrowser.Api/UserLibrary/ArtistsService.cs index 5bbd96c7c3..7c1519e9fd 100644 --- a/MediaBrowser.Api/UserLibrary/ArtistsService.cs +++ b/MediaBrowser.Api/UserLibrary/ArtistsService.cs @@ -68,10 +68,10 @@ namespace MediaBrowser.Api.UserLibrary /// <returns>Task{BaseItemDto}.</returns> private BaseItemDto GetItem(GetArtist request) { - var item = GetArtist(request.Name, LibraryManager); - var dtoOptions = GetDtoOptions(AuthorizationContext, request); + var item = GetArtist(request.Name, LibraryManager, dtoOptions); + if (!string.IsNullOrWhiteSpace(request.UserId)) { var user = UserManager.GetUserById(request.UserId); diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs index daef97915a..d79fafd321 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs @@ -267,7 +267,8 @@ namespace MediaBrowser.Api.UserLibrary { ExcludeItemTypes = excludeItemTypes, IncludeItemTypes = includeItemTypes, - MediaTypes = mediaTypes + MediaTypes = mediaTypes, + DtoOptions = dtoOptions }; Func<BaseItem, bool> filter = i => FilterItem(request, i, excludeItemTypes, includeItemTypes, mediaTypes); diff --git a/MediaBrowser.Api/UserLibrary/GameGenresService.cs b/MediaBrowser.Api/UserLibrary/GameGenresService.cs index 2eef1ab2fd..56730c1b20 100644 --- a/MediaBrowser.Api/UserLibrary/GameGenresService.cs +++ b/MediaBrowser.Api/UserLibrary/GameGenresService.cs @@ -56,10 +56,10 @@ namespace MediaBrowser.Api.UserLibrary /// <returns>Task{BaseItemDto}.</returns> private BaseItemDto GetItem(GetGameGenre request) { - var item = GetGameGenre(request.Name, LibraryManager); - var dtoOptions = GetDtoOptions(AuthorizationContext, request); - + + var item = GetGameGenre(request.Name, LibraryManager, dtoOptions); + if (!string.IsNullOrWhiteSpace(request.UserId)) { var user = UserManager.GetUserById(request.UserId); diff --git a/MediaBrowser.Api/UserLibrary/GenresService.cs b/MediaBrowser.Api/UserLibrary/GenresService.cs index 664efac14c..fc387e5e39 100644 --- a/MediaBrowser.Api/UserLibrary/GenresService.cs +++ b/MediaBrowser.Api/UserLibrary/GenresService.cs @@ -66,10 +66,10 @@ namespace MediaBrowser.Api.UserLibrary /// <returns>Task{BaseItemDto}.</returns> private BaseItemDto GetItem(GetGenre request) { - var item = GetGenre(request.Name, LibraryManager); - - var dtoOptions = GetDtoOptions(AuthorizationContext ,request); + var dtoOptions = GetDtoOptions(AuthorizationContext, request); + var item = GetGenre(request.Name, LibraryManager, dtoOptions); + if (!string.IsNullOrWhiteSpace(request.UserId)) { var user = UserManager.GetUserById(request.UserId); diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index da5c5c763c..b7bb758c3f 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -358,7 +358,7 @@ namespace MediaBrowser.Api.UserLibrary { try { - return _libraryManager.GetArtist(i); + return _libraryManager.GetArtist(i, new DtoOptions(false)); } catch { diff --git a/MediaBrowser.Api/UserLibrary/MusicGenresService.cs b/MediaBrowser.Api/UserLibrary/MusicGenresService.cs index 305c136dfb..d1d4aa634b 100644 --- a/MediaBrowser.Api/UserLibrary/MusicGenresService.cs +++ b/MediaBrowser.Api/UserLibrary/MusicGenresService.cs @@ -57,10 +57,10 @@ namespace MediaBrowser.Api.UserLibrary /// <returns>Task{BaseItemDto}.</returns> private BaseItemDto GetItem(GetMusicGenre request) { - var item = GetMusicGenre(request.Name, LibraryManager); - var dtoOptions = GetDtoOptions(AuthorizationContext, request); + var item = GetMusicGenre(request.Name, LibraryManager, dtoOptions); + if (!string.IsNullOrWhiteSpace(request.UserId)) { var user = UserManager.GetUserById(request.UserId); diff --git a/MediaBrowser.Api/UserLibrary/PersonsService.cs b/MediaBrowser.Api/UserLibrary/PersonsService.cs index dbce22578b..21f416025e 100644 --- a/MediaBrowser.Api/UserLibrary/PersonsService.cs +++ b/MediaBrowser.Api/UserLibrary/PersonsService.cs @@ -64,10 +64,10 @@ namespace MediaBrowser.Api.UserLibrary /// <returns>Task{BaseItemDto}.</returns> private BaseItemDto GetItem(GetPerson request) { - var item = GetPerson(request.Name, LibraryManager); - var dtoOptions = GetDtoOptions(AuthorizationContext, request); + var item = GetPerson(request.Name, LibraryManager, dtoOptions); + if (!string.IsNullOrWhiteSpace(request.UserId)) { var user = UserManager.GetUserById(request.UserId); diff --git a/MediaBrowser.Api/UserLibrary/StudiosService.cs b/MediaBrowser.Api/UserLibrary/StudiosService.cs index f4debcf48a..7ac1264e8f 100644 --- a/MediaBrowser.Api/UserLibrary/StudiosService.cs +++ b/MediaBrowser.Api/UserLibrary/StudiosService.cs @@ -66,10 +66,10 @@ namespace MediaBrowser.Api.UserLibrary /// <returns>Task{BaseItemDto}.</returns> private BaseItemDto GetItem(GetStudio request) { - var item = GetStudio(request.Name, LibraryManager); - var dtoOptions = GetDtoOptions(AuthorizationContext, request); - + + var item = GetStudio(request.Name, LibraryManager, dtoOptions); + if (!string.IsNullOrWhiteSpace(request.UserId)) { var user = UserManager.GetUserById(request.UserId); |
