From bd31c0175d87ec00a675b92ae9a92af569228775 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 18 Aug 2017 15:34:41 -0400 Subject: [PATCH 1/5] move LnkShortcutHandler --- Emby.Server.Implementations/ApplicationHost.cs | 5 ----- .../Emby.Server.Implementations.csproj | 1 - Emby.Server.Implementations/Logging/SimpleLogManager.cs | 2 +- .../MediaBrowser.ServerApplication.csproj | 1 + .../Native}/LnkShortcutHandler.cs | 2 +- MediaBrowser.ServerApplication/WindowsAppHost.cs | 1 + 6 files changed, 4 insertions(+), 8 deletions(-) rename {Emby.Server.Implementations/IO => MediaBrowser.ServerApplication/Native}/LnkShortcutHandler.cs (99%) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index bc88d652c..39b554afe 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -424,11 +424,6 @@ namespace Emby.Server.Implementations SetBaseExceptionMessage(); - if (environmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows) - { - fileSystem.AddShortcutHandler(new LnkShortcutHandler()); - } - fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem)); } diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 1e897016e..2a45fb315 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -133,7 +133,6 @@ - diff --git a/Emby.Server.Implementations/Logging/SimpleLogManager.cs b/Emby.Server.Implementations/Logging/SimpleLogManager.cs index 5c83766fe..6d1c5b837 100644 --- a/Emby.Server.Implementations/Logging/SimpleLogManager.cs +++ b/Emby.Server.Implementations/Logging/SimpleLogManager.cs @@ -122,7 +122,7 @@ namespace Emby.Server.Implementations.Logging { Directory.CreateDirectory(Path.GetDirectoryName(path)); - _fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read); + _fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read, 32768); _cancellationTokenSource = new CancellationTokenSource(); Task.Factory.StartNew(LogInternal, _cancellationTokenSource.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default); diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index 2ee2acfc2..15abaaa62 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -122,6 +122,7 @@ + diff --git a/Emby.Server.Implementations/IO/LnkShortcutHandler.cs b/MediaBrowser.ServerApplication/Native/LnkShortcutHandler.cs similarity index 99% rename from Emby.Server.Implementations/IO/LnkShortcutHandler.cs rename to MediaBrowser.ServerApplication/Native/LnkShortcutHandler.cs index 093d57aa4..e53a79670 100644 --- a/Emby.Server.Implementations/IO/LnkShortcutHandler.cs +++ b/MediaBrowser.ServerApplication/Native/LnkShortcutHandler.cs @@ -5,7 +5,7 @@ using System.Runtime.InteropServices.ComTypes; using System.Text; using MediaBrowser.Model.IO; -namespace Emby.Server.Implementations.IO +namespace MediaBrowser.ServerApplication.Native { public class LnkShortcutHandler :IShortcutHandler { diff --git a/MediaBrowser.ServerApplication/WindowsAppHost.cs b/MediaBrowser.ServerApplication/WindowsAppHost.cs index d72bd532e..a6664c42f 100644 --- a/MediaBrowser.ServerApplication/WindowsAppHost.cs +++ b/MediaBrowser.ServerApplication/WindowsAppHost.cs @@ -28,6 +28,7 @@ namespace MediaBrowser.ServerApplication public WindowsAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, MediaBrowser.Common.Net.INetworkManager networkManager) : base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, networkManager) { + fileSystem.AddShortcutHandler(new LnkShortcutHandler()); } public override bool IsRunningAsService From 1ad990ad720931309afadd9f7912d66595dcc04e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 19 Aug 2017 15:43:35 -0400 Subject: [PATCH 2/5] update live tv data transfer --- Emby.Dlna/ContentDirectory/ControlHandler.cs | 25 +++ Emby.Dlna/Didl/DidlBuilder.cs | 4 +- Emby.Dlna/PlayTo/PlayToController.cs | 5 +- Emby.Dlna/PlayTo/PlayToManager.cs | 2 +- .../ApplicationHost.cs | 6 +- .../Channels/ChannelManager.cs | 32 ++-- .../Collections/CollectionManager.cs | 22 +-- .../Data/SqliteItemRepository.cs | 3 +- .../Devices/DeviceRepository.cs | 6 +- Emby.Server.Implementations/Dto/DtoService.cs | 32 ++-- .../EntryPoints/LibraryChangedNotifier.cs | 10 +- .../EntryPoints/UserDataChangeNotifier.cs | 2 +- .../HttpServer/HttpListenerHost.cs | 2 +- .../IO/LibraryMonitor.cs | 6 +- .../Library/LibraryManager.cs | 6 +- .../Library/SearchEngine.cs | 2 +- .../Library/UserDataManager.cs | 4 +- .../Library/UserViewManager.cs | 5 +- .../LiveTv/EmbyTV/EmbyTV.cs | 14 +- .../LiveTv/LiveTvDtoService.cs | 51 ++---- .../LiveTv/LiveTvManager.cs | 95 +++++----- .../LiveTv/RefreshChannelsScheduledTask.cs | 2 +- .../LiveTv/TunerHosts/MulticastStream.cs | 10 +- .../LiveTv/TunerHosts/QueueStream.cs | 24 +-- .../Localization/LocalizationManager.cs | 18 +- .../MediaEncoder/EncodingManager.cs | 2 +- .../Notifications/CoreNotificationTypes.cs | 32 ++-- .../Notifications/NotificationManager.cs | 2 +- .../Playlists/PlaylistManager.cs | 2 +- .../Services/ServiceController.cs | 40 +---- .../Session/SessionManager.cs | 81 +++++---- .../TV/TVSeriesManager.cs | 6 +- .../Updates/InstallationManager.cs | 52 +++--- MediaBrowser.Api/BaseApiService.cs | 24 ++- MediaBrowser.Api/ChannelService.cs | 6 +- MediaBrowser.Api/ConfigurationService.cs | 4 +- MediaBrowser.Api/Dlna/DlnaService.cs | 5 +- MediaBrowser.Api/EnvironmentService.cs | 9 +- MediaBrowser.Api/FilterService.cs | 2 +- MediaBrowser.Api/GamesService.cs | 60 +------ MediaBrowser.Api/IHasItemFields.cs | 4 +- MediaBrowser.Api/Images/RemoteImageService.cs | 10 +- MediaBrowser.Api/ItemUpdateService.cs | 8 +- MediaBrowser.Api/Library/LibraryService.cs | 8 +- MediaBrowser.Api/LiveTv/LiveTvService.cs | 20 ++- MediaBrowser.Api/LocalizationService.cs | 12 +- MediaBrowser.Api/MediaBrowser.Api.csproj | 1 - MediaBrowser.Api/Movies/CollectionService.cs | 8 +- MediaBrowser.Api/Movies/MoviesService.cs | 8 +- MediaBrowser.Api/Movies/TrailersService.cs | 3 +- MediaBrowser.Api/Music/InstantMixService.cs | 12 +- MediaBrowser.Api/NotificationsService.cs | 2 +- MediaBrowser.Api/PackageReviewService.cs | 162 ------------------ MediaBrowser.Api/PackageService.cs | 27 +-- MediaBrowser.Api/PlaylistService.cs | 8 +- MediaBrowser.Api/PluginService.cs | 11 +- .../ScheduledTasks/ScheduledTaskService.cs | 4 +- MediaBrowser.Api/Session/SessionsService.cs | 8 +- MediaBrowser.Api/SimilarItemsHelper.cs | 8 +- MediaBrowser.Api/Subtitles/SubtitleService.cs | 6 +- MediaBrowser.Api/SuggestionsService.cs | 2 +- MediaBrowser.Api/System/SystemService.cs | 6 +- MediaBrowser.Api/TvShowsService.cs | 63 ++++--- .../UserLibrary/BaseItemsByNameService.cs | 16 +- .../UserLibrary/BaseItemsRequest.cs | 4 +- MediaBrowser.Api/UserLibrary/ItemsService.cs | 21 +-- .../UserLibrary/UserLibraryService.cs | 29 ++-- .../UserLibrary/UserViewsService.cs | 21 +-- MediaBrowser.Api/UserService.cs | 6 +- MediaBrowser.Api/VideosService.cs | 4 +- .../Updates/IInstallationManager.cs | 4 +- .../Channels/IChannelManager.cs | 2 +- .../Channels/InternalChannelFeatures.cs | 9 - .../Collections/CollectionCreationOptions.cs | 8 +- .../Collections/ICollectionManager.cs | 4 +- MediaBrowser.Controller/Dto/DtoOptions.cs | 24 +-- MediaBrowser.Controller/Dto/IDtoService.cs | 9 +- MediaBrowser.Controller/Entities/BaseItem.cs | 2 +- MediaBrowser.Controller/Entities/Folder.cs | 20 +-- .../Entities/IHasUserData.cs | 2 +- .../Entities/Movies/BoxSet.cs | 8 +- MediaBrowser.Controller/Entities/TV/Season.cs | 10 +- MediaBrowser.Controller/Entities/TV/Series.cs | 39 ++--- .../Entities/UserRootFolder.cs | 2 +- MediaBrowser.Controller/Entities/UserView.cs | 4 +- .../Entities/UserViewBuilder.cs | 8 +- MediaBrowser.Controller/Entities/Video.cs | 20 +-- .../Library/IUserDataManager.cs | 2 +- .../Library/IUserViewManager.cs | 2 +- .../LiveTv/ILiveTvManager.cs | 6 +- .../MediaEncoding/EncodingHelper.cs | 6 +- .../MediaEncoding/EncodingJobInfo.cs | 10 +- .../MediaEncoding/MediaEncoderHelpers.cs | 21 +-- .../MediaEncoding/MediaInfoRequest.cs | 4 +- .../Notifications/INotificationManager.cs | 2 +- MediaBrowser.Controller/Playlists/Playlist.cs | 2 +- .../Providers/IProviderManager.cs | 2 +- .../Session/SessionInfo.cs | 12 +- .../Subtitles/ISubtitleManager.cs | 6 +- MediaBrowser.Controller/Sync/ISyncManager.cs | 18 +- MediaBrowser.Controller/Sync/ISyncProvider.cs | 4 +- .../Images/LocalImageProvider.cs | 83 ++++++--- .../Channels/AllChannelMediaQuery.cs | 4 +- .../Channels/ChannelFeatures.cs | 12 +- .../Configuration/MetadataOptions.cs | 3 +- .../Configuration/MetadataPluginSummary.cs | 8 +- .../Devices/ContentUploadHistory.cs | 4 +- MediaBrowser.Model/Dlna/AudioOptions.cs | 2 +- MediaBrowser.Model/Dlna/CodecProfile.cs | 19 +- MediaBrowser.Model/Dlna/ContainerProfile.cs | 20 ++- MediaBrowser.Model/Dlna/DeviceProfile.cs | 22 +-- MediaBrowser.Model/Dlna/DirectPlayProfile.cs | 18 +- .../Dlna/MediaFormatProfileResolver.cs | 60 +++---- .../Dlna/ResolutionNormalizer.cs | 4 +- MediaBrowser.Model/Dlna/ResponseProfile.cs | 20 +-- MediaBrowser.Model/Dlna/StreamBuilder.cs | 58 +++---- MediaBrowser.Model/Dlna/StreamInfoSorter.cs | 4 +- MediaBrowser.Model/Dlna/SubtitleProfile.cs | 13 +- MediaBrowser.Model/Dlna/TranscodingProfile.cs | 9 +- MediaBrowser.Model/Dto/BaseItemDto.cs | 2 +- MediaBrowser.Model/Dto/GameSystemSummary.cs | 4 +- MediaBrowser.Model/Dto/ItemLayout.cs | 72 -------- MediaBrowser.Model/Dto/MediaSourceInfo.cs | 4 +- MediaBrowser.Model/Dto/MetadataEditorInfo.cs | 20 +-- .../Entities/LibraryUpdateInfo.cs | 23 ++- .../Entities/VirtualFolderInfo.cs | 4 +- MediaBrowser.Model/Extensions/ListHelper.cs | 9 - .../Globalization/ILocalizationManager.cs | 8 +- MediaBrowser.Model/Health/IHealthMonitor.cs | 12 -- MediaBrowser.Model/LiveTv/BaseTimerInfoDto.cs | 2 +- MediaBrowser.Model/LiveTv/ChannelInfoDto.cs | 4 +- MediaBrowser.Model/LiveTv/LiveTvInfo.cs | 8 +- MediaBrowser.Model/LiveTv/LiveTvOptions.cs | 8 +- .../LiveTv/LiveTvServiceInfo.cs | 4 +- .../LiveTv/LiveTvTunerInfoDto.cs | 4 +- .../LiveTv/SeriesTimerInfoDto.cs | 14 +- MediaBrowser.Model/MediaBrowser.Model.csproj | 3 - .../MediaInfo/BlurayDiscInfo.cs | 6 +- MediaBrowser.Model/MediaInfo/MediaInfo.cs | 20 +-- .../MediaInfo/PlaybackInfoResponse.cs | 4 +- .../MediaInfo/SubtitleTrackInfo.cs | 4 +- MediaBrowser.Model/Net/MimeTypes.cs | 2 +- .../Notifications/NotificationTypeInfo.cs | 4 +- .../Playlists/PlaylistCreationRequest.cs | 4 +- .../Providers/ImageProviderInfo.cs | 4 +- .../Providers/RemoteImageResult.cs | 4 +- MediaBrowser.Model/Querying/ItemsResult.cs | 11 -- MediaBrowser.Model/Querying/QueryResult.cs | 3 - .../Querying/ThemeMediaResult.cs | 5 +- .../Session/ClientCapabilities.cs | 12 +- MediaBrowser.Model/Session/SessionInfoDto.cs | 12 +- MediaBrowser.Model/Session/TranscodingInfo.cs | 4 +- .../Session/UserDataChangeInfo.cs | 2 +- .../Sync/CompleteSyncJobInfo.cs | 4 +- MediaBrowser.Model/Sync/LocalItem.cs | 8 +- MediaBrowser.Model/Sync/SyncDataRequest.cs | 10 +- MediaBrowser.Model/Sync/SyncDataResponse.cs | 9 +- MediaBrowser.Model/Sync/SyncDialogOptions.cs | 16 +- MediaBrowser.Model/Sync/SyncJob.cs | 4 +- .../Sync/SyncJobCreationResult.cs | 4 +- MediaBrowser.Model/Sync/SyncJobItem.cs | 4 +- MediaBrowser.Model/Sync/SyncJobRequest.cs | 4 +- MediaBrowser.Model/Sync/SyncedItem.cs | 4 +- MediaBrowser.Model/System/SystemInfo.cs | 12 +- MediaBrowser.Model/Updates/PackageInfo.cs | 4 +- .../Manager/ProviderManager.cs | 19 +- .../MediaInfo/FFProbeAudioInfo.cs | 2 +- .../MediaInfo/FFProbeVideoInfo.cs | 18 +- .../Subtitles/SubtitleManager.cs | 40 ++--- .../TV/SeasonMetadataService.cs | 8 +- .../MediaEncoding/Subtitles/AssParserTests.cs | 6 +- .../MediaEncoding/Subtitles/SrtParserTests.cs | 6 +- .../MediaEncoding/Subtitles/VttWriterTest.cs | 2 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 175 files changed, 997 insertions(+), 1351 deletions(-) delete mode 100644 MediaBrowser.Api/PackageReviewService.cs delete mode 100644 MediaBrowser.Model/Dto/ItemLayout.cs delete mode 100644 MediaBrowser.Model/Health/IHealthMonitor.cs delete mode 100644 MediaBrowser.Model/Querying/ItemsResult.cs diff --git a/Emby.Dlna/ContentDirectory/ControlHandler.cs b/Emby.Dlna/ContentDirectory/ControlHandler.cs index 96b282d04..5ce1d1925 100644 --- a/Emby.Dlna/ContentDirectory/ControlHandler.cs +++ b/Emby.Dlna/ContentDirectory/ControlHandler.cs @@ -487,6 +487,11 @@ namespace Emby.Dlna.ContentDirectory return GetMusicArtistItems(item, null, user, sort, startIndex, limit); } + if (item is Genre) + { + return GetGenreItems(item, null, user, sort, startIndex, limit); + } + var collectionFolder = item as ICollectionFolder; if (collectionFolder != null && string.Equals(CollectionType.Music, collectionFolder.CollectionType, StringComparison.OrdinalIgnoreCase)) { @@ -1173,6 +1178,26 @@ namespace Emby.Dlna.ContentDirectory return ToResult(result); } + private QueryResult GetGenreItems(BaseItem item, Guid? parentId, User user, SortCriteria sort, int? startIndex, int? limit) + { + var query = new InternalItemsQuery(user) + { + Recursive = true, + ParentId = parentId, + GenreIds = new[] { item.Id.ToString("N") }, + IncludeItemTypes = new[] { typeof(Movie).Name, typeof(Series).Name }, + Limit = limit, + StartIndex = startIndex, + DtoOptions = GetDtoOptions() + }; + + SetSorting(query, sort, false); + + var result = _libraryManager.GetItemsResult(query); + + return ToResult(result); + } + private QueryResult GetMusicGenreItems(BaseItem item, Guid? parentId, User user, SortCriteria sort, int? startIndex, int? limit) { var query = new InternalItemsQuery(user) diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs index 64e76276c..65410bd67 100644 --- a/Emby.Dlna/Didl/DidlBuilder.cs +++ b/Emby.Dlna/Didl/DidlBuilder.cs @@ -198,7 +198,7 @@ namespace Emby.Dlna.Didl streamInfo = new StreamBuilder(_mediaEncoder, GetStreamBuilderLogger(options)).BuildVideoItem(new VideoOptions { ItemId = GetClientId(video), - MediaSources = sources, + MediaSources = sources.ToArray(sources.Count), Profile = _profile, DeviceId = deviceId, MaxBitrate = _profile.MaxStreamingBitrate @@ -513,7 +513,7 @@ namespace Emby.Dlna.Didl streamInfo = new StreamBuilder(_mediaEncoder, GetStreamBuilderLogger(options)).BuildAudioItem(new AudioOptions { ItemId = GetClientId(audio), - MediaSources = sources, + MediaSources = sources.ToArray(sources.Count), Profile = _profile, DeviceId = deviceId }); diff --git a/Emby.Dlna/PlayTo/PlayToController.cs b/Emby.Dlna/PlayTo/PlayToController.cs index 7164cf598..d563b5add 100644 --- a/Emby.Dlna/PlayTo/PlayToController.cs +++ b/Emby.Dlna/PlayTo/PlayToController.cs @@ -20,6 +20,7 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Model.Events; using MediaBrowser.Model.Globalization; +using MediaBrowser.Model.Extensions; namespace Emby.Dlna.PlayTo { @@ -589,7 +590,7 @@ namespace Emby.Dlna.PlayTo StreamInfo = new StreamBuilder(_mediaEncoder, GetStreamBuilderLogger()).BuildVideoItem(new VideoOptions { ItemId = item.Id.ToString("N"), - MediaSources = mediaSources, + MediaSources = mediaSources.ToArray(mediaSources.Count), Profile = profile, DeviceId = deviceId, MaxBitrate = profile.MaxStreamingBitrate, @@ -609,7 +610,7 @@ namespace Emby.Dlna.PlayTo StreamInfo = new StreamBuilder(_mediaEncoder, GetStreamBuilderLogger()).BuildAudioItem(new AudioOptions { ItemId = item.Id.ToString("N"), - MediaSources = mediaSources, + MediaSources = mediaSources.ToArray(mediaSources.Count), Profile = profile, DeviceId = deviceId, MaxBitrate = profile.MaxStreamingBitrate, diff --git a/Emby.Dlna/PlayTo/PlayToManager.cs b/Emby.Dlna/PlayTo/PlayToManager.cs index 32f542e73..e29ef78a8 100644 --- a/Emby.Dlna/PlayTo/PlayToManager.cs +++ b/Emby.Dlna/PlayTo/PlayToManager.cs @@ -182,7 +182,7 @@ namespace Emby.Dlna.PlayTo { PlayableMediaTypes = profile.GetSupportedMediaTypes(), - SupportedCommands = new List + SupportedCommands = new string[] { GeneralCommandType.VolumeDown.ToString(), GeneralCommandType.VolumeUp.ToString(), diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 39b554afe..ea6c2aaf5 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -1853,9 +1853,9 @@ namespace Emby.Server.Implementations HasPendingRestart = HasPendingRestart, Version = ApplicationVersion.ToString(), WebSocketPortNumber = HttpPort, - FailedPluginAssemblies = FailedAssemblies.ToList(), - InProgressInstallations = InstallationManager.CurrentInstallations.Select(i => i.Item1).ToList(), - CompletedInstallations = InstallationManager.CompletedInstallations.ToList(), + FailedPluginAssemblies = FailedAssemblies.ToArray(), + InProgressInstallations = InstallationManager.CurrentInstallations.Select(i => i.Item1).ToArray(), + CompletedInstallations = InstallationManager.CompletedInstallations.ToArray(), Id = SystemId, ProgramDataPath = ApplicationPaths.ProgramDataPath, LogPath = ApplicationPaths.LogDirectoryPath, diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index e41e0ea87..28a150370 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -182,10 +182,8 @@ namespace Emby.Server.Implementations.Channels { }; - var returnList = (await _dtoService.GetBaseItemDtos(internalResult.Items, dtoOptions, user) + var returnItems = (await _dtoService.GetBaseItemDtos(internalResult.Items, dtoOptions, user) .ConfigureAwait(false)); - var returnItems = returnList - .ToArray(returnList.Count); var result = new QueryResult { @@ -464,14 +462,14 @@ namespace Emby.Server.Implementations.Channels return _libraryManager.GetItemById(id) as Channel; } - public IEnumerable GetAllChannelFeatures() + public ChannelFeatures[] GetAllChannelFeatures() { return _libraryManager.GetItemIds(new InternalItemsQuery { IncludeItemTypes = new[] { typeof(Channel).Name }, SortBy = new[] { ItemSortBy.SortName } - }).Select(i => GetChannelFeatures(i.ToString("N"))); + }).Select(i => GetChannelFeatures(i.ToString("N"))).ToArray(); } public ChannelFeatures GetChannelFeatures(string id) @@ -511,10 +509,10 @@ namespace Emby.Server.Implementations.Channels { CanFilter = !features.MaxPageSize.HasValue, CanSearch = provider is ISearchableChannel, - ContentTypes = features.ContentTypes, - DefaultSortFields = features.DefaultSortFields, + ContentTypes = features.ContentTypes.ToArray(), + DefaultSortFields = features.DefaultSortFields.ToArray(), MaxPageSize = features.MaxPageSize, - MediaTypes = features.MediaTypes, + MediaTypes = features.MediaTypes.ToArray(), SupportsSortOrderToggle = features.SupportsSortOrderToggle, SupportsLatestMedia = supportsLatest, Name = channel.Name, @@ -566,12 +564,10 @@ namespace Emby.Server.Implementations.Channels var dtoOptions = new DtoOptions() { - Fields = query.Fields.ToList() + Fields = query.Fields }; - var returnList = (await _dtoService.GetBaseItemDtos(items, dtoOptions, user).ConfigureAwait(false)); - var returnItems = returnList - .ToArray(returnList.Count); + var returnItems = (await _dtoService.GetBaseItemDtos(items, dtoOptions, user).ConfigureAwait(false)); var result = new QueryResult { @@ -833,13 +829,11 @@ namespace Emby.Server.Implementations.Channels var dtoOptions = new DtoOptions() { - Fields = query.Fields.ToList() + Fields = query.Fields }; - var returnList = (await _dtoService.GetBaseItemDtos(internalResult.Items, dtoOptions, user) + var returnItems = (await _dtoService.GetBaseItemDtos(internalResult.Items, dtoOptions, user) .ConfigureAwait(false)); - var returnItems = returnList - .ToArray(returnList.Count); var result = new QueryResult { @@ -987,13 +981,11 @@ namespace Emby.Server.Implementations.Channels var dtoOptions = new DtoOptions() { - Fields = query.Fields.ToList() + Fields = query.Fields }; - var returnList = (await _dtoService.GetBaseItemDtos(internalResult.Items, dtoOptions, user) + var returnItems = (await _dtoService.GetBaseItemDtos(internalResult.Items, dtoOptions, user) .ConfigureAwait(false)); - var returnItems = returnList - .ToArray(returnList.Count); var result = new QueryResult { diff --git a/Emby.Server.Implementations/Collections/CollectionManager.cs b/Emby.Server.Implementations/Collections/CollectionManager.cs index 5b168f6cc..18823fa9d 100644 --- a/Emby.Server.Implementations/Collections/CollectionManager.cs +++ b/Emby.Server.Implementations/Collections/CollectionManager.cs @@ -84,7 +84,7 @@ namespace Emby.Server.Implementations.Collections ProviderIds = options.ProviderIds, Shares = options.UserIds.Select(i => new Share { - UserId = i.ToString("N"), + UserId = i, CanEdit = true }).ToList() @@ -92,7 +92,7 @@ namespace Emby.Server.Implementations.Collections await parentFolder.AddChild(collection, CancellationToken.None).ConfigureAwait(false); - if (options.ItemIdList.Count > 0) + if (options.ItemIdList.Length > 0) { await AddToCollection(collection.Id, options.ItemIdList, false, new MetadataRefreshOptions(_fileSystem) { @@ -149,12 +149,12 @@ namespace Emby.Server.Implementations.Collections return GetCollectionsFolder(string.Empty); } - public Task AddToCollection(Guid collectionId, IEnumerable ids) + public Task AddToCollection(Guid collectionId, string[] ids) { return AddToCollection(collectionId, ids, true, new MetadataRefreshOptions(_fileSystem)); } - private async Task AddToCollection(Guid collectionId, IEnumerable ids, bool fireEvent, MetadataRefreshOptions refreshOptions) + private async Task AddToCollection(Guid collectionId, string[] ids, bool fireEvent, MetadataRefreshOptions refreshOptions) { var collection = _libraryManager.GetItemById(collectionId) as BoxSet; @@ -165,11 +165,12 @@ namespace Emby.Server.Implementations.Collections var list = new List(); var itemList = new List(); - var currentLinkedChildren = collection.GetLinkedChildren().ToList(); + var currentLinkedChildrenIds = collection.GetLinkedChildren().Select(i => i.Id).ToList(); foreach (var itemId in ids) { - var item = _libraryManager.GetItemById(itemId); + var guidId = new Guid(itemId); + var item = _libraryManager.GetItemById(guidId); if (string.IsNullOrWhiteSpace(item.Path)) { @@ -183,7 +184,7 @@ namespace Emby.Server.Implementations.Collections itemList.Add(item); - if (currentLinkedChildren.All(i => i.Id != itemId)) + if (!currentLinkedChildrenIds.Contains(guidId)) { list.Add(LinkedChild.Create(item)); } @@ -213,7 +214,7 @@ namespace Emby.Server.Implementations.Collections } } - public async Task RemoveFromCollection(Guid collectionId, IEnumerable itemIds) + public async Task RemoveFromCollection(Guid collectionId, string[] itemIds) { var collection = _libraryManager.GetItemById(collectionId) as BoxSet; @@ -227,9 +228,10 @@ namespace Emby.Server.Implementations.Collections foreach (var itemId in itemIds) { - var childItem = _libraryManager.GetItemById(itemId); + var guidId = new Guid(itemId); + var childItem = _libraryManager.GetItemById(guidId); - var child = collection.LinkedChildren.FirstOrDefault(i => (i.ItemId.HasValue && i.ItemId.Value == itemId) || (childItem != null && string.Equals(childItem.Path, i.Path, StringComparison.OrdinalIgnoreCase))); + var child = collection.LinkedChildren.FirstOrDefault(i => (i.ItemId.HasValue && i.ItemId.Value == guidId) || (childItem != null && string.Equals(childItem.Path, i.Path, StringComparison.OrdinalIgnoreCase))); if (child == null) { diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 6743e96fd..d7cbdf9e5 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -149,7 +149,7 @@ namespace Emby.Server.Implementations.Data "create table if not exists AncestorIds (ItemId GUID, AncestorId GUID, AncestorIdText TEXT, PRIMARY KEY (ItemId, AncestorId))", "create index if not exists idx_AncestorIds1 on AncestorIds(AncestorId)", - "create index if not exists idx_AncestorIds2 on AncestorIds(AncestorIdText)", + "create index if not exists idx_AncestorIds5 on AncestorIds(AncestorIdText,ItemId)", "create table if not exists ItemValues (ItemId GUID, Type INT, Value TEXT, CleanValue TEXT)", @@ -308,6 +308,7 @@ namespace Emby.Server.Implementations.Data "drop index if exists idx_TypeSeriesPresentationUniqueKey2", "drop index if exists idx_AncestorIds3", "drop index if exists idx_AncestorIds4", + "drop index if exists idx_AncestorIds2", "create index if not exists idx_PathTypedBaseItems on TypedBaseItems(Path)", "create index if not exists idx_ParentIdTypedBaseItems on TypedBaseItems(ParentId)", diff --git a/Emby.Server.Implementations/Devices/DeviceRepository.cs b/Emby.Server.Implementations/Devices/DeviceRepository.cs index de0dfda2e..b286a3bb0 100644 --- a/Emby.Server.Implementations/Devices/DeviceRepository.cs +++ b/Emby.Server.Implementations/Devices/DeviceRepository.cs @@ -11,6 +11,7 @@ using MediaBrowser.Model.IO; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Session; +using MediaBrowser.Model.Extensions; namespace Emby.Server.Implementations.Devices { @@ -199,7 +200,10 @@ namespace Emby.Server.Implementations.Devices } history.DeviceId = deviceId; - history.FilesUploaded.Add(file); + + var list = history.FilesUploaded.ToList(); + list.Add(file); + history.FilesUploaded = list.ToArray(list.Count); _json.SerializeToFile(history, path); } diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index e1d0a1858..9dbf299ab 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -77,7 +77,7 @@ namespace Emby.Server.Implementations.Dto /// The owner. /// Task{DtoBaseItem}. /// item - public BaseItemDto GetBaseItemDto(BaseItem item, List fields, User user = null, BaseItem owner = null) + public BaseItemDto GetBaseItemDto(BaseItem item, ItemFields[] fields, User user = null, BaseItem owner = null) { var options = new DtoOptions { @@ -87,7 +87,17 @@ namespace Emby.Server.Implementations.Dto return GetBaseItemDto(item, options, user, owner); } - public async Task> GetBaseItemDtos(IEnumerable items, DtoOptions options, User user = null, BaseItem owner = null) + public Task GetBaseItemDtos(List items, DtoOptions options, User user = null, BaseItem owner = null) + { + return GetBaseItemDtos(items, items.Count, options, user, owner); + } + + public Task GetBaseItemDtos(BaseItem[] items, DtoOptions options, User user = null, BaseItem owner = null) + { + return GetBaseItemDtos(items, items.Length, options, user, owner); + } + + public async Task GetBaseItemDtos(IEnumerable items, int itemCount, DtoOptions options, User user = null, BaseItem owner = null) { if (items == null) { @@ -101,7 +111,7 @@ namespace Emby.Server.Implementations.Dto var syncDictionary = GetSyncedItemProgress(options); - var list = new List(); + var returnItems = new BaseItemDto[itemCount]; var programTuples = new List>(); var channelTuples = new List>(); @@ -109,6 +119,7 @@ namespace Emby.Server.Implementations.Dto ? _providerManager.GetRefreshQueue() : null; + var index = 0; foreach (var item in items) { var dto = GetBaseItemDtoInternal(item, options, refreshQueue, user, owner); @@ -144,7 +155,8 @@ namespace Emby.Server.Implementations.Dto FillSyncInfo(dto, item, options, user, syncDictionary); - list.Add(dto); + returnItems[index] = dto; + index++; } if (programTuples.Count > 0) @@ -157,7 +169,7 @@ namespace Emby.Server.Implementations.Dto await _livetvManager().AddChannelInfo(channelTuples, options, user).ConfigureAwait(false); } - return list; + return returnItems; } public BaseItemDto GetBaseItemDto(BaseItem item, DtoOptions options, User user = null, BaseItem owner = null) @@ -992,7 +1004,7 @@ namespace Emby.Server.Implementations.Dto { dto.RemoteTrailers = hasTrailers != null ? hasTrailers.RemoteTrailers : - new MediaUrl[] {}; + new MediaUrl[] { }; } dto.Name = item.Name; @@ -1053,7 +1065,7 @@ namespace Emby.Server.Implementations.Dto if (dto.Taglines == null) { - dto.Taglines = new string[]{}; + dto.Taglines = new string[] { }; } } @@ -1243,17 +1255,17 @@ namespace Emby.Server.Implementations.Dto if (iHasMediaSources != null) { - List mediaStreams; + MediaStream[] mediaStreams; if (dto.MediaSources != null && dto.MediaSources.Count > 0) { mediaStreams = dto.MediaSources.Where(i => new Guid(i.Id) == item.Id) .SelectMany(i => i.MediaStreams) - .ToList(); + .ToArray(); } else { - mediaStreams = _mediaSourceManager().GetStaticMediaSources(iHasMediaSources, true).First().MediaStreams; + mediaStreams = _mediaSourceManager().GetStaticMediaSources(iHasMediaSources, true).First().MediaStreams.ToArray(); } dto.MediaStreams = mediaStreams; diff --git a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs index 69a205dda..80a188bc0 100644 --- a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs @@ -367,15 +367,15 @@ namespace Emby.Server.Implementations.EntryPoints return new LibraryUpdateInfo { - ItemsAdded = itemsAdded.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user)).Select(i => i.Id.ToString("N")).Distinct().ToList(), + ItemsAdded = itemsAdded.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user)).Select(i => i.Id.ToString("N")).Distinct().ToArray(), - ItemsUpdated = itemsUpdated.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user)).Select(i => i.Id.ToString("N")).Distinct().ToList(), + ItemsUpdated = itemsUpdated.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user)).Select(i => i.Id.ToString("N")).Distinct().ToArray(), - ItemsRemoved = itemsRemoved.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, true)).Select(i => i.Id.ToString("N")).Distinct().ToList(), + ItemsRemoved = itemsRemoved.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, true)).Select(i => i.Id.ToString("N")).Distinct().ToArray(), - FoldersAddedTo = foldersAddedTo.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user)).Select(i => i.Id.ToString("N")).Distinct().ToList(), + FoldersAddedTo = foldersAddedTo.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user)).Select(i => i.Id.ToString("N")).Distinct().ToArray(), - FoldersRemovedFrom = foldersRemovedFrom.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user)).Select(i => i.Id.ToString("N")).Distinct().ToList() + FoldersRemovedFrom = foldersRemovedFrom.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user)).Select(i => i.Id.ToString("N")).Distinct().ToArray() }; } diff --git a/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs b/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs index 71e31d4d4..accdc5e9d 100644 --- a/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs @@ -126,7 +126,7 @@ namespace Emby.Server.Implementations.EntryPoints dto.ItemId = i.Id.ToString("N"); return dto; }) - .ToList(); + .ToArray(); var info = new UserDataChangeInfo { diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs index f150e4785..f1fea2085 100644 --- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -162,7 +162,7 @@ namespace Emby.Server.Implementations.HttpServer return serviceType; } - public void AddServiceInfo(Type serviceType, Type requestType, Type responseType) + public void AddServiceInfo(Type serviceType, Type requestType) { ServiceOperationsMap[requestType] = serviceType; } diff --git a/Emby.Server.Implementations/IO/LibraryMonitor.cs b/Emby.Server.Implementations/IO/LibraryMonitor.cs index c452c01be..1467d9426 100644 --- a/Emby.Server.Implementations/IO/LibraryMonitor.cs +++ b/Emby.Server.Implementations/IO/LibraryMonitor.cs @@ -35,7 +35,7 @@ namespace Emby.Server.Implementations.IO /// /// Any file name ending in any of these will be ignored by the watchers /// - private readonly IReadOnlyList _alwaysIgnoreFiles = new List + private readonly string[] _alwaysIgnoreFiles = new string[] { "small.jpg", "albumart.jpg", @@ -45,7 +45,7 @@ namespace Emby.Server.Implementations.IO "TempSBE" }; - private readonly IReadOnlyList _alwaysIgnoreSubstrings = new List + private readonly string[] _alwaysIgnoreSubstrings = new string[] { // Synology "eaDir", @@ -54,7 +54,7 @@ namespace Emby.Server.Implementations.IO ".actors" }; - private readonly IReadOnlyList _alwaysIgnoreExtensions = new List + private readonly string[] _alwaysIgnoreExtensions = new string[] { // thumbs.db ".db", diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 40dccf9ba..bf3afd050 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -1208,7 +1208,7 @@ namespace Emby.Server.Implementations.Library .Where(i => string.Equals(ShortcutFileExtension, Path.GetExtension(i), StringComparison.OrdinalIgnoreCase)) .Select(_fileSystem.ResolveShortcut) .OrderBy(i => i) - .ToList(), + .ToArray(), CollectionType = GetCollectionType(dir) }; @@ -1554,7 +1554,7 @@ namespace Emby.Server.Implementations.Library IncludeHidden = true, IncludeExternalContent = allowExternalContent - }, CancellationToken.None).Result.ToList(); + }, CancellationToken.None).Result; query.TopParentIds = userViews.SelectMany(i => GetTopParentIdsForQuery(i, user)).Select(i => i.ToString("N")).ToArray(); } @@ -3061,7 +3061,7 @@ namespace Emby.Server.Implementations.Library var topLibraryFolders = GetUserRootFolder().Children.ToList(); var info = GetVirtualFolderInfo(virtualFolderPath, topLibraryFolders, null); - if (info.Locations.Count > 0 && info.Locations.Count != options.PathInfos.Length) + if (info.Locations.Length > 0 && info.Locations.Length != options.PathInfos.Length) { var list = options.PathInfos.ToList(); diff --git a/Emby.Server.Implementations/Library/SearchEngine.cs b/Emby.Server.Implementations/Library/SearchEngine.cs index 658558ec0..d4c4f2794 100644 --- a/Emby.Server.Implementations/Library/SearchEngine.cs +++ b/Emby.Server.Implementations/Library/SearchEngine.cs @@ -181,7 +181,7 @@ namespace Emby.Server.Implementations.Library DtoOptions = new DtoOptions { - Fields = new List + Fields = new ItemFields[] { ItemFields.AirTime, ItemFields.DateCreated, diff --git a/Emby.Server.Implementations/Library/UserDataManager.cs b/Emby.Server.Implementations/Library/UserDataManager.cs index e066ab61b..1f2bf97a3 100644 --- a/Emby.Server.Implementations/Library/UserDataManager.cs +++ b/Emby.Server.Implementations/Library/UserDataManager.cs @@ -187,11 +187,11 @@ namespace Emby.Server.Implementations.Library var userData = GetUserData(user.Id, item); var dto = GetUserItemDataDto(userData); - item.FillUserDataDtoValues(dto, userData, null, user, new List()); + item.FillUserDataDtoValues(dto, userData, null, user, new ItemFields[]{}); return dto; } - public UserItemDataDto GetUserDataDto(IHasUserData item, BaseItemDto itemDto, User user, List fields) + public UserItemDataDto GetUserDataDto(IHasUserData item, BaseItemDto itemDto, User user, ItemFields[] fields) { var userData = GetUserData(user.Id, item); var dto = GetUserItemDataDto(userData); diff --git a/Emby.Server.Implementations/Library/UserViewManager.cs b/Emby.Server.Implementations/Library/UserViewManager.cs index 0d4303b16..25c3e10e8 100644 --- a/Emby.Server.Implementations/Library/UserViewManager.cs +++ b/Emby.Server.Implementations/Library/UserViewManager.cs @@ -39,7 +39,7 @@ namespace Emby.Server.Implementations.Library _config = config; } - public async Task> GetUserViews(UserViewQuery query, CancellationToken cancellationToken) + public async Task GetUserViews(UserViewQuery query, CancellationToken cancellationToken) { var user = _userManager.GetUserById(query.UserId); @@ -154,7 +154,8 @@ namespace Emby.Server.Implementations.Library return index == -1 ? int.MaxValue : index; }) .ThenBy(sorted.IndexOf) - .ThenBy(i => i.SortName); + .ThenBy(i => i.SortName) + .ToArray(); } public Task GetUserSubView(string name, string parentId, string type, string sortName, CancellationToken cancellationToken) diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 99b5558a2..ecad5c0eb 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -208,7 +208,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV continue; } - if (virtualFolder.Locations.Count == 1) + if (virtualFolder.Locations.Length == 1) { // remove entire virtual folder try @@ -458,7 +458,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV return GetEpgChannelFromTunerChannel(info, tunerChannel, epgChannels); } - private string GetMappedChannel(string channelId, List mappings) + private string GetMappedChannel(string channelId, NameValuePair[] mappings) { foreach (NameValuePair mapping in mappings) { @@ -472,10 +472,10 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV private ChannelInfo GetEpgChannelFromTunerChannel(ListingsProviderInfo info, ChannelInfo tunerChannel, List epgChannels) { - return GetEpgChannelFromTunerChannel(info.ChannelMappings.ToList(), tunerChannel, epgChannels); + return GetEpgChannelFromTunerChannel(info.ChannelMappings, tunerChannel, epgChannels); } - public ChannelInfo GetEpgChannelFromTunerChannel(List mappings, ChannelInfo tunerChannel, List epgChannels) + public ChannelInfo GetEpgChannelFromTunerChannel(NameValuePair[] mappings, ChannelInfo tunerChannel, List epgChannels) { if (!string.IsNullOrWhiteSpace(tunerChannel.Id)) { @@ -2591,7 +2591,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { list.Add(new VirtualFolderInfo { - Locations = new List { defaultFolder }, + Locations = new string[] { defaultFolder }, Name = defaultName }); } @@ -2601,7 +2601,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { list.Add(new VirtualFolderInfo { - Locations = new List { customPath }, + Locations = new string[] { customPath }, Name = "Recorded Movies", CollectionType = CollectionType.Movies }); @@ -2612,7 +2612,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { list.Add(new VirtualFolderInfo { - Locations = new List { customPath }, + Locations = new string[] { customPath }, Name = "Recorded Shows", CollectionType = CollectionType.TvShows }); diff --git a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs index 619d2378d..eff2909fd 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs @@ -15,6 +15,8 @@ using System.Threading; using System.Threading.Tasks; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Extensions; +using MediaBrowser.Model.Querying; namespace Emby.Server.Implementations.LiveTv { @@ -110,7 +112,7 @@ namespace Emby.Server.Implementations.LiveTv PostPaddingSeconds = info.PostPaddingSeconds, IsPostPaddingRequired = info.IsPostPaddingRequired, IsPrePaddingRequired = info.IsPrePaddingRequired, - Days = info.Days, + Days = info.Days.ToArray(), Priority = info.Priority, RecordAnyChannel = info.RecordAnyChannel, RecordAnyTime = info.RecordAnyTime, @@ -135,7 +137,7 @@ namespace Emby.Server.Implementations.LiveTv dto.ProgramId = GetInternalProgramId(service.Name, info.ProgramId).ToString("N"); } - dto.DayPattern = info.Days == null ? null : GetDayPattern(info.Days); + dto.DayPattern = info.Days == null ? null : GetDayPattern(info.Days.ToArray(info.Days.Count)); FillImages(dto, info.Name, info.SeriesId); @@ -150,10 +152,7 @@ namespace Emby.Server.Implementations.LiveTv Name = seriesName, Limit = 1, ImageTypes = new ImageType[] { ImageType.Thumb }, - DtoOptions = new DtoOptions - { - Fields = new List() - } + DtoOptions = new DtoOptions(false) }).FirstOrDefault(); @@ -196,10 +195,7 @@ namespace Emby.Server.Implementations.LiveTv ExternalSeriesId = programSeriesId, Limit = 1, ImageTypes = new ImageType[] { ImageType.Primary }, - DtoOptions = new DtoOptions - { - Fields = new List() - } + DtoOptions = new DtoOptions(false) }).FirstOrDefault(); @@ -248,10 +244,7 @@ namespace Emby.Server.Implementations.LiveTv Name = seriesName, Limit = 1, ImageTypes = new ImageType[] { ImageType.Thumb }, - DtoOptions = new DtoOptions - { - Fields = new List() - } + DtoOptions = new DtoOptions(false) }).FirstOrDefault(); @@ -274,7 +267,7 @@ namespace Emby.Server.Implementations.LiveTv { try { - dto.ParentBackdropImageTags = new List + dto.ParentBackdropImageTags = new string[] { _imageProcessor.GetImageCacheTag(librarySeries, image) }; @@ -294,10 +287,7 @@ namespace Emby.Server.Implementations.LiveTv Name = seriesName, Limit = 1, ImageTypes = new ImageType[] { ImageType.Primary }, - DtoOptions = new DtoOptions - { - Fields = new List() - } + DtoOptions = new DtoOptions(false) }).FirstOrDefault() ?? _libraryManager.GetItemList(new InternalItemsQuery { @@ -305,10 +295,7 @@ namespace Emby.Server.Implementations.LiveTv ExternalSeriesId = programSeriesId, Limit = 1, ImageTypes = new ImageType[] { ImageType.Primary }, - DtoOptions = new DtoOptions - { - Fields = new List() - } + DtoOptions = new DtoOptions(false) }).FirstOrDefault(); @@ -327,14 +314,14 @@ namespace Emby.Server.Implementations.LiveTv } } - if (dto.ParentBackdropImageTags == null || dto.ParentBackdropImageTags.Count == 0) + if (dto.ParentBackdropImageTags == null || dto.ParentBackdropImageTags.Length == 0) { image = program.GetImageInfo(ImageType.Backdrop, 0); if (image != null) { try { - dto.ParentBackdropImageTags = new List + dto.ParentBackdropImageTags = new string[] { _imageProcessor.GetImageCacheTag(program, image) }; @@ -349,24 +336,24 @@ namespace Emby.Server.Implementations.LiveTv } } - public DayPattern? GetDayPattern(List days) + public DayPattern? GetDayPattern(DayOfWeek[] days) { DayPattern? pattern = null; - if (days.Count > 0) + if (days.Length > 0) { - if (days.Count == 7) + if (days.Length == 7) { pattern = DayPattern.Daily; } - else if (days.Count == 2) + else if (days.Length == 2) { if (days.Contains(DayOfWeek.Saturday) && days.Contains(DayOfWeek.Sunday)) { pattern = DayPattern.Weekends; } } - else if (days.Count == 5) + else if (days.Length == 5) { if (days.Contains(DayOfWeek.Monday) && days.Contains(DayOfWeek.Tuesday) && days.Contains(DayOfWeek.Wednesday) && days.Contains(DayOfWeek.Thursday) && days.Contains(DayOfWeek.Friday)) { @@ -384,7 +371,7 @@ namespace Emby.Server.Implementations.LiveTv { Name = info.Name, Id = info.Id, - Clients = info.Clients, + Clients = info.Clients.ToArray(), ProgramName = info.ProgramName, SourceType = info.SourceType, Status = info.Status, @@ -543,7 +530,7 @@ namespace Emby.Server.Implementations.LiveTv PostPaddingSeconds = dto.PostPaddingSeconds, IsPostPaddingRequired = dto.IsPostPaddingRequired, IsPrePaddingRequired = dto.IsPrePaddingRequired, - Days = dto.Days, + Days = dto.Days.ToList(), Priority = dto.Priority, RecordAnyChannel = dto.RecordAnyChannel, RecordAnyTime = dto.RecordAnyTime, diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index 3fbbc8390..2882af007 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -985,9 +985,8 @@ namespace Emby.Server.Implementations.LiveTv var queryResult = _libraryManager.QueryItems(internalQuery); - var returnList = (await _dtoService.GetBaseItemDtos(queryResult.Items, options, user) + var returnArray = (await _dtoService.GetBaseItemDtos(queryResult.Items, options, user) .ConfigureAwait(false)); - var returnArray = returnList.ToArray(returnList.Count); var result = new QueryResult { @@ -998,7 +997,7 @@ namespace Emby.Server.Implementations.LiveTv return result; } - public async Task> GetRecommendedProgramsInternal(RecommendedProgramQuery query, DtoOptions options, CancellationToken cancellationToken) + public async Task> GetRecommendedProgramsInternal(RecommendedProgramQuery query, DtoOptions options, CancellationToken cancellationToken) { var user = _userManager.GetUserById(query.UserId); @@ -1036,10 +1035,10 @@ namespace Emby.Server.Implementations.LiveTv } } - var programList = _libraryManager.QueryItems(internalQuery).Items.Cast().ToList(); - var totalCount = programList.Count; + var programList = _libraryManager.QueryItems(internalQuery).Items; + var totalCount = programList.Length; - IOrderedEnumerable orderedPrograms = programList.OrderBy(i => i.StartDate.Date); + IOrderedEnumerable orderedPrograms = programList.Cast().OrderBy(i => i.StartDate.Date); if (query.IsAiring ?? false) { @@ -1047,14 +1046,14 @@ namespace Emby.Server.Implementations.LiveTv .ThenByDescending(i => GetRecommendationScore(i, user.Id, true)); } - IEnumerable programs = orderedPrograms; + IEnumerable programs = orderedPrograms; if (query.Limit.HasValue) { programs = programs.Take(query.Limit.Value); } - var result = new QueryResult + var result = new QueryResult { Items = programs.ToArray(), TotalRecordCount = totalCount @@ -1071,9 +1070,8 @@ namespace Emby.Server.Implementations.LiveTv var user = _userManager.GetUserById(query.UserId); - var returnList = (await _dtoService.GetBaseItemDtos(internalResult.Items, options, user) + var returnArray = (await _dtoService.GetBaseItemDtos(internalResult.Items, options, user) .ConfigureAwait(false)); - var returnArray = returnList.ToArray(returnList.Count); var result = new QueryResult { @@ -1262,8 +1260,8 @@ namespace Emby.Server.Implementations.LiveTv progress.Report(100 * percent); } - await CleanDatabaseInternal(newChannelIdList, new[] { typeof(LiveTvChannel).Name }, progress, cancellationToken).ConfigureAwait(false); - await CleanDatabaseInternal(newProgramIdList, new[] { typeof(LiveTvProgram).Name }, progress, cancellationToken).ConfigureAwait(false); + await CleanDatabaseInternal(newChannelIdList.ToArray(), new[] { typeof(LiveTvChannel).Name }, progress, cancellationToken).ConfigureAwait(false); + await CleanDatabaseInternal(newProgramIdList.ToArray(), new[] { typeof(LiveTvProgram).Name }, progress, cancellationToken).ConfigureAwait(false); var coreService = _services.OfType().FirstOrDefault(); @@ -1275,8 +1273,11 @@ namespace Emby.Server.Implementations.LiveTv // Load these now which will prefetch metadata var dtoOptions = new DtoOptions(); - dtoOptions.Fields.Remove(ItemFields.SyncInfo); - dtoOptions.Fields.Remove(ItemFields.BasicSyncInfo); + var fields = dtoOptions.Fields.ToList(); + fields.Remove(ItemFields.SyncInfo); + fields.Remove(ItemFields.BasicSyncInfo); + dtoOptions.Fields = fields.ToArray(fields.Count); + await GetRecordings(new RecordingQuery(), dtoOptions, cancellationToken).ConfigureAwait(false); progress.Report(100); @@ -1446,14 +1447,14 @@ namespace Emby.Server.Implementations.LiveTv return new Tuple, List>(channels, programs); } - private async Task CleanDatabaseInternal(List currentIdList, string[] validTypes, IProgress progress, CancellationToken cancellationToken) + private async Task CleanDatabaseInternal(Guid[] currentIdList, string[] validTypes, IProgress progress, CancellationToken cancellationToken) { var list = _itemRepo.GetItemIdsList(new InternalItemsQuery { IncludeItemTypes = validTypes, DtoOptions = new DtoOptions(false) - }).ToList(); + }); var numComplete = 0; @@ -1543,7 +1544,7 @@ namespace Emby.Server.Implementations.LiveTv var idList = await Task.WhenAll(recordingTasks).ConfigureAwait(false); - await CleanDatabaseInternal(idList.ToList(), new[] { typeof(LiveTvVideoRecording).Name, typeof(LiveTvAudioRecording).Name }, new SimpleProgress(), cancellationToken).ConfigureAwait(false); + await CleanDatabaseInternal(idList, new[] { typeof(LiveTvVideoRecording).Name, typeof(LiveTvAudioRecording).Name }, new SimpleProgress(), cancellationToken).ConfigureAwait(false); _lastRecordingRefreshTime = DateTime.UtcNow; } @@ -1701,11 +1702,9 @@ namespace Emby.Server.Implementations.LiveTv DtoOptions = options }); - var returnList = (await _dtoService.GetBaseItemDtos(internalResult.Items, options, user) + var returnArray = (await _dtoService.GetBaseItemDtos(internalResult.Items, options, user) .ConfigureAwait(false)); - var returnArray = returnList.ToArray(returnList.Count); - return new QueryResult { Items = returnArray, @@ -1841,7 +1840,7 @@ namespace Emby.Server.Implementations.LiveTv }; } - public async Task AddInfoToProgramDto(List> tuples, List fields, User user = null) + public async Task AddInfoToProgramDto(List> tuples, ItemFields[] fields, User user = null) { var programTuples = new List>(); var hasChannelImage = fields.Contains(ItemFields.ChannelImage); @@ -1961,7 +1960,7 @@ namespace Emby.Server.Implementations.LiveTv if (dto.MediaStreams == null) { - dto.MediaStreams = dto.MediaSources.SelectMany(i => i.MediaStreams).ToList(); + dto.MediaStreams = dto.MediaSources.SelectMany(i => i.MediaStreams).ToArray(); } if (info.Status == RecordingStatus.InProgress && info.EndDate.HasValue) @@ -1995,9 +1994,8 @@ namespace Emby.Server.Implementations.LiveTv var internalResult = await GetInternalRecordings(query, options, cancellationToken).ConfigureAwait(false); - var returnList = (await _dtoService.GetBaseItemDtos(internalResult.Items, options, user) + var returnArray = (await _dtoService.GetBaseItemDtos(internalResult.Items, options, user) .ConfigureAwait(false)); - var returnArray = returnList.ToArray(returnList.Count); return new QueryResult { @@ -2479,7 +2477,7 @@ namespace Emby.Server.Implementations.LiveTv var defaults = await GetNewTimerDefaultsInternal(cancellationToken, program).ConfigureAwait(false); var info = _tvDtoService.GetSeriesTimerInfoDto(defaults.Item1, defaults.Item2, null); - info.Days = defaults.Item1.Days; + info.Days = defaults.Item1.Days.ToArray(); info.DayPattern = _tvDtoService.GetDayPattern(info.Days); @@ -2656,8 +2654,7 @@ namespace Emby.Server.Implementations.LiveTv var series = recordings .Where(i => i.IsSeries) - .ToLookup(i => i.Name, StringComparer.OrdinalIgnoreCase) - .ToList(); + .ToLookup(i => i.Name, StringComparer.OrdinalIgnoreCase); groups.AddRange(series.OrderByString(i => i.Key).Select(i => new BaseItemDto { @@ -2762,7 +2759,7 @@ namespace Emby.Server.Implementations.LiveTv } } - private async Task> GetServiceInfos(CancellationToken cancellationToken) + private async Task GetServiceInfos(CancellationToken cancellationToken) { var tasks = Services.Select(i => GetServiceInfo(i, cancellationToken)); @@ -2806,7 +2803,7 @@ namespace Emby.Server.Implementations.LiveTv return dto; - }).ToList(); + }).ToArray(); } catch (Exception ex) { @@ -2822,25 +2819,24 @@ namespace Emby.Server.Implementations.LiveTv public async Task GetLiveTvInfo(CancellationToken cancellationToken) { var services = await GetServiceInfos(CancellationToken.None).ConfigureAwait(false); - var servicesList = services.ToList(); var info = new LiveTvInfo { - Services = servicesList.ToList(), - IsEnabled = servicesList.Count > 0 + Services = services, + IsEnabled = services.Length > 0 }; info.EnabledUsers = _userManager.Users .Where(IsLiveTvEnabled) .Select(i => i.Id.ToString("N")) - .ToList(); + .ToArray(); return info; } private bool IsLiveTvEnabled(User user) { - return user.Policy.EnableLiveTvAccess && (Services.Count > 1 || GetConfiguration().TunerHosts.Count > 0); + return user.Policy.EnableLiveTvAccess && (Services.Count > 1 || GetConfiguration().TunerHosts.Length > 0); } public IEnumerable GetEnabledUsers() @@ -2880,10 +2876,13 @@ namespace Emby.Server.Implementations.LiveTv private void RemoveFields(DtoOptions options) { - options.Fields.Remove(ItemFields.CanDelete); - options.Fields.Remove(ItemFields.CanDownload); - options.Fields.Remove(ItemFields.DisplayPreferencesId); - options.Fields.Remove(ItemFields.Etag); + var fields = options.Fields.ToList(); + + fields.Remove(ItemFields.CanDelete); + fields.Remove(ItemFields.CanDownload); + fields.Remove(ItemFields.DisplayPreferencesId); + fields.Remove(ItemFields.Etag); + options.Fields = fields.ToArray(fields.Count); } public async Task GetInternalLiveTvFolder(CancellationToken cancellationToken) @@ -2911,12 +2910,14 @@ namespace Emby.Server.Implementations.LiveTv var config = GetConfiguration(); - var index = config.TunerHosts.FindIndex(i => string.Equals(i.Id, info.Id, StringComparison.OrdinalIgnoreCase)); + var list = config.TunerHosts.ToList(); + var index = list.FindIndex(i => string.Equals(i.Id, info.Id, StringComparison.OrdinalIgnoreCase)); if (index == -1 || string.IsNullOrWhiteSpace(info.Id)) { info.Id = Guid.NewGuid().ToString("N"); - config.TunerHosts.Add(info); + list.Add(info); + config.TunerHosts = list.ToArray(list.Count); } else { @@ -2948,12 +2949,14 @@ namespace Emby.Server.Implementations.LiveTv var config = GetConfiguration(); - var index = config.ListingProviders.FindIndex(i => string.Equals(i.Id, info.Id, StringComparison.OrdinalIgnoreCase)); + var list = config.ListingProviders.ToList(); + var index = list.FindIndex(i => string.Equals(i.Id, info.Id, StringComparison.OrdinalIgnoreCase)); if (index == -1 || string.IsNullOrWhiteSpace(info.Id)) { info.Id = Guid.NewGuid().ToString("N"); - config.ListingProviders.Add(info); + list.Add(info); + config.ListingProviders = list.ToArray(list.Count); info.EnableNewProgramIds = true; } else @@ -2972,7 +2975,7 @@ namespace Emby.Server.Implementations.LiveTv { var config = GetConfiguration(); - config.ListingProviders = config.ListingProviders.Where(i => !string.Equals(id, i.Id, StringComparison.OrdinalIgnoreCase)).ToList(); + config.ListingProviders = config.ListingProviders.Where(i => !string.Equals(id, i.Id, StringComparison.OrdinalIgnoreCase)).ToArray(); _config.SaveConfiguration("livetv", config); _taskManager.CancelIfRunningAndQueue(); @@ -3004,7 +3007,7 @@ namespace Emby.Server.Implementations.LiveTv var providerChannels = await GetChannelsFromListingsProviderData(providerId, CancellationToken.None) .ConfigureAwait(false); - var mappings = listingsProviderInfo.ChannelMappings.ToList(); + var mappings = listingsProviderInfo.ChannelMappings; var tunerChannelMappings = tunerChannels.Select(i => GetTunerChannelMapping(i, mappings, providerChannels)).ToList(); @@ -3014,7 +3017,7 @@ namespace Emby.Server.Implementations.LiveTv return tunerChannelMappings.First(i => string.Equals(i.Id, tunerChannelId, StringComparison.OrdinalIgnoreCase)); } - public TunerChannelMapping GetTunerChannelMapping(ChannelInfo tunerChannel, List mappings, List epgChannels) + public TunerChannelMapping GetTunerChannelMapping(ChannelInfo tunerChannel, NameValuePair[] mappings, List epgChannels) { var result = new TunerChannelMapping { @@ -3078,7 +3081,7 @@ namespace Emby.Server.Implementations.LiveTv if (string.Equals(feature, "dvr-l", StringComparison.OrdinalIgnoreCase)) { var config = GetConfiguration(); - if (config.TunerHosts.Count > 0 && + if (config.TunerHosts.Length > 0 && config.ListingProviders.Count(i => (i.EnableAllTuners || i.EnabledTuners.Length > 0) && string.Equals(i.Type, SchedulesDirect.TypeName, StringComparison.OrdinalIgnoreCase)) > 0) { return Task.FromResult(new MBRegistrationRecord diff --git a/Emby.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs b/Emby.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs index 5582d8f35..cad28c809 100644 --- a/Emby.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs +++ b/Emby.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs @@ -62,7 +62,7 @@ namespace Emby.Server.Implementations.LiveTv public bool IsHidden { - get { return _liveTvManager.Services.Count == 1 && GetConfiguration().TunerHosts.Count == 0; } + get { return _liveTvManager.Services.Count == 1 && GetConfiguration().TunerHosts.Length == 0; } } public bool IsEnabled diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/MulticastStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/MulticastStream.cs index cf50e6092..567f4ce20 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/MulticastStream.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/MulticastStream.cs @@ -24,8 +24,6 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts public async Task CopyUntilCancelled(Stream source, Action onStarted, CancellationToken cancellationToken) { - byte[] buffer = new byte[BufferSize]; - if (source == null) { throw new ArgumentNullException("source"); @@ -35,6 +33,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts { cancellationToken.ThrowIfCancellationRequested(); + byte[] buffer = new byte[BufferSize]; + var bytesRead = source.Read(buffer, 0, buffer.Length); if (bytesRead > 0) @@ -47,12 +47,12 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts //} //else { - byte[] copy = new byte[bytesRead]; - Buffer.BlockCopy(buffer, 0, copy, 0, bytesRead); + //byte[] copy = new byte[bytesRead]; + //Buffer.BlockCopy(buffer, 0, copy, 0, bytesRead); foreach (var stream in allStreams) { - stream.Value.Queue(copy, 0, copy.Length); + stream.Value.Queue(buffer, 0, bytesRead); } } diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/QueueStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/QueueStream.cs index 61bc390b4..f1ec8d5af 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/QueueStream.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/QueueStream.cs @@ -13,7 +13,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts public class QueueStream { private readonly Stream _outputStream; - private readonly ConcurrentQueue> _queue = new ConcurrentQueue>(); + private readonly BlockingCollection> _queue = new BlockingCollection>(); public TaskCompletionSource TaskCompletion { get; private set; } public Action OnFinished { get; set; } @@ -29,7 +29,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts public void Queue(byte[] bytes, int offset, int count) { - _queue.Enqueue(new Tuple(bytes, offset, count)); + _queue.Add(new Tuple(bytes, offset, count)); } public void Start(CancellationToken cancellationToken) @@ -37,17 +37,6 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts Task.Run(() => StartInternal(cancellationToken)); } - private Tuple Dequeue() - { - Tuple result; - if (_queue.TryDequeue(out result)) - { - return result; - } - - return null; - } - private void OnClosed() { GC.Collect(); @@ -79,7 +68,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } } - private async Task StartInternal(CancellationToken cancellationToken) + private void StartInternal(CancellationToken cancellationToken) { try { @@ -87,15 +76,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts { cancellationToken.ThrowIfCancellationRequested(); - var result = Dequeue(); - if (result != null) + foreach (var result in _queue.GetConsumingEnumerable()) { _outputStream.Write(result.Item1, result.Item2, result.Item3); } - else - { - await Task.Delay(50, cancellationToken).ConfigureAwait(false); - } } } catch (OperationCanceledException) diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.cs index 8d3051a89..a8cd1dc04 100644 --- a/Emby.Server.Implementations/Localization/LocalizationManager.cs +++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs @@ -132,7 +132,7 @@ namespace Emby.Server.Implementations.Localization /// Gets the cultures. /// /// IEnumerable{CultureDto}. - public List GetCultures() + public CultureDto[] GetCultures() { var type = GetType(); var path = type.Namespace + ".iso6392.txt"; @@ -169,21 +169,21 @@ namespace Emby.Server.Implementations.Localization return list.Where(i => !string.IsNullOrWhiteSpace(i.Name) && !string.IsNullOrWhiteSpace(i.DisplayName) && !string.IsNullOrWhiteSpace(i.ThreeLetterISOLanguageName) && - !string.IsNullOrWhiteSpace(i.TwoLetterISOLanguageName)).ToList(); + !string.IsNullOrWhiteSpace(i.TwoLetterISOLanguageName)).ToArray(); } /// /// Gets the countries. /// /// IEnumerable{CountryInfo}. - public List GetCountries() + public CountryInfo[] GetCountries() { var type = GetType(); var path = type.Namespace + ".countries.json"; using (var stream = _assemblyInfo.GetManifestResourceStream(type, path)) { - return _jsonSerializer.DeserializeFromStream>(stream); + return _jsonSerializer.DeserializeFromStream(stream); } } @@ -191,9 +191,9 @@ namespace Emby.Server.Implementations.Localization /// Gets the parental ratings. /// /// IEnumerable{ParentalRating}. - public IEnumerable GetParentalRatings() + public ParentalRating[] GetParentalRatings() { - return GetParentalRatingsDictionary().Values.ToList(); + return GetParentalRatingsDictionary().Values.ToArray(); } /// @@ -382,9 +382,9 @@ namespace Emby.Server.Implementations.Localization return culture + ".json"; } - public IEnumerable GetLocalizationOptions() + public LocalizatonOption[] GetLocalizationOptions() { - return new List + return new LocalizatonOption[] { new LocalizatonOption{ Name="Arabic", Value="ar"}, new LocalizatonOption{ Name="Bulgarian (Bulgaria)", Value="bg-BG"}, @@ -421,7 +421,7 @@ namespace Emby.Server.Implementations.Localization new LocalizatonOption{ Name="Ukrainian", Value="uk"}, new LocalizatonOption{ Name="Vietnamese", Value="vi"} - }.OrderBy(i => i.Name); + }; } } diff --git a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs index 7ee6e9e38..770b881d5 100644 --- a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs +++ b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs @@ -129,7 +129,7 @@ namespace Emby.Server.Implementations.MediaEncoder var protocol = MediaProtocol.File; - var inputPath = MediaEncoderHelpers.GetInputArgument(_fileSystem, video.Path, protocol, null, new List()); + var inputPath = MediaEncoderHelpers.GetInputArgument(_fileSystem, video.Path, protocol, null, new string[] { }); _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); diff --git a/Emby.Server.Implementations/Notifications/CoreNotificationTypes.cs b/Emby.Server.Implementations/Notifications/CoreNotificationTypes.cs index f9fb98f85..849e02d81 100644 --- a/Emby.Server.Implementations/Notifications/CoreNotificationTypes.cs +++ b/Emby.Server.Implementations/Notifications/CoreNotificationTypes.cs @@ -28,21 +28,21 @@ namespace Emby.Server.Implementations.Notifications Type = NotificationType.ApplicationUpdateInstalled.ToString(), DefaultDescription = "{ReleaseNotes}", DefaultTitle = "A new version of Emby Server has been installed.", - Variables = new List{"Version"} + Variables = new string[]{"Version"} }, new NotificationTypeInfo { Type = NotificationType.InstallationFailed.ToString(), DefaultTitle = "{Name} installation failed.", - Variables = new List{"Name", "Version"} + Variables = new string[]{"Name", "Version"} }, new NotificationTypeInfo { Type = NotificationType.PluginInstalled.ToString(), DefaultTitle = "{Name} was installed.", - Variables = new List{"Name", "Version"} + Variables = new string[]{"Name", "Version"} }, new NotificationTypeInfo @@ -50,14 +50,14 @@ namespace Emby.Server.Implementations.Notifications Type = NotificationType.PluginError.ToString(), DefaultTitle = "{Name} has encountered an error.", DefaultDescription = "{ErrorMessage}", - Variables = new List{"Name", "ErrorMessage"} + Variables = new string[]{"Name", "ErrorMessage"} }, new NotificationTypeInfo { Type = NotificationType.PluginUninstalled.ToString(), DefaultTitle = "{Name} was uninstalled.", - Variables = new List{"Name", "Version"} + Variables = new string[]{"Name", "Version"} }, new NotificationTypeInfo @@ -65,7 +65,7 @@ namespace Emby.Server.Implementations.Notifications Type = NotificationType.PluginUpdateInstalled.ToString(), DefaultTitle = "{Name} was updated.", DefaultDescription = "{ReleaseNotes}", - Variables = new List{"Name", "ReleaseNotes", "Version"} + Variables = new string[]{"Name", "ReleaseNotes", "Version"} }, new NotificationTypeInfo @@ -79,70 +79,70 @@ namespace Emby.Server.Implementations.Notifications Type = NotificationType.TaskFailed.ToString(), DefaultTitle = "{Name} failed.", DefaultDescription = "{ErrorMessage}", - Variables = new List{"Name", "ErrorMessage"} + Variables = new string[]{"Name", "ErrorMessage"} }, new NotificationTypeInfo { Type = NotificationType.NewLibraryContent.ToString(), DefaultTitle = "{Name} has been added to your media library.", - Variables = new List{"Name"} + Variables = new string[]{"Name"} }, new NotificationTypeInfo { Type = NotificationType.AudioPlayback.ToString(), DefaultTitle = "{UserName} is playing {ItemName} on {DeviceName}.", - Variables = new List{"UserName", "ItemName", "DeviceName", "AppName"} + Variables = new string[]{"UserName", "ItemName", "DeviceName", "AppName"} }, new NotificationTypeInfo { Type = NotificationType.GamePlayback.ToString(), DefaultTitle = "{UserName} is playing {ItemName} on {DeviceName}.", - Variables = new List{"UserName", "ItemName", "DeviceName", "AppName"} + Variables = new string[]{"UserName", "ItemName", "DeviceName", "AppName"} }, new NotificationTypeInfo { Type = NotificationType.VideoPlayback.ToString(), DefaultTitle = "{UserName} is playing {ItemName} on {DeviceName}.", - Variables = new List{"UserName", "ItemName", "DeviceName", "AppName"} + Variables = new string[]{"UserName", "ItemName", "DeviceName", "AppName"} }, new NotificationTypeInfo { Type = NotificationType.AudioPlaybackStopped.ToString(), DefaultTitle = "{UserName} has finished playing {ItemName} on {DeviceName}.", - Variables = new List{"UserName", "ItemName", "DeviceName", "AppName"} + Variables = new string[]{"UserName", "ItemName", "DeviceName", "AppName"} }, new NotificationTypeInfo { Type = NotificationType.GamePlaybackStopped.ToString(), DefaultTitle = "{UserName} has finished playing {ItemName} on {DeviceName}.", - Variables = new List{"UserName", "ItemName", "DeviceName", "AppName"} + Variables = new string[]{"UserName", "ItemName", "DeviceName", "AppName"} }, new NotificationTypeInfo { Type = NotificationType.VideoPlaybackStopped.ToString(), DefaultTitle = "{UserName} has finished playing {ItemName} on {DeviceName}.", - Variables = new List{"UserName", "ItemName", "DeviceName", "AppName"} + Variables = new string[]{"UserName", "ItemName", "DeviceName", "AppName"} }, new NotificationTypeInfo { Type = NotificationType.CameraImageUploaded.ToString(), DefaultTitle = "A new camera image has been uploaded from {DeviceName}.", - Variables = new List{"DeviceName"} + Variables = new string[]{"DeviceName"} }, new NotificationTypeInfo { Type = NotificationType.UserLockedOut.ToString(), DefaultTitle = "{UserName} has been locked out.", - Variables = new List{"UserName"} + Variables = new string[]{"UserName"} } }; diff --git a/Emby.Server.Implementations/Notifications/NotificationManager.cs b/Emby.Server.Implementations/Notifications/NotificationManager.cs index db7980497..f49d5a1d1 100644 --- a/Emby.Server.Implementations/Notifications/NotificationManager.cs +++ b/Emby.Server.Implementations/Notifications/NotificationManager.cs @@ -251,7 +251,7 @@ namespace Emby.Server.Implementations.Notifications _typeFactories = notificationTypeFactories.ToArray(); } - public IEnumerable GetNotificationTypes() + public List GetNotificationTypes() { var list = _typeFactories.Select(i => { diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs index 578a2321c..9b9596934 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs @@ -133,7 +133,7 @@ namespace Emby.Server.Implementations.Playlists await playlist.RefreshMetadata(new MetadataRefreshOptions(_fileSystem) { ForceSave = true }, CancellationToken.None) .ConfigureAwait(false); - if (options.ItemIdList.Count > 0) + if (options.ItemIdList.Length > 0) { await AddToPlaylistInternal(playlist.Id.ToString("N"), options.ItemIdList, user, new DtoOptions(false) { diff --git a/Emby.Server.Implementations/Services/ServiceController.cs b/Emby.Server.Implementations/Services/ServiceController.cs index 4ad56411a..c3970b22f 100644 --- a/Emby.Server.Implementations/Services/ServiceController.cs +++ b/Emby.Server.Implementations/Services/ServiceController.cs @@ -29,13 +29,6 @@ namespace Emby.Server.Implementations.Services } } - private Type[] GetGenericArguments(Type type) - { - return type.GetTypeInfo().IsGenericTypeDefinition - ? type.GetTypeInfo().GenericTypeParameters - : type.GetTypeInfo().GenericTypeArguments; - } - public void RegisterService(HttpListenerHost appHost, Type serviceType) { var processedReqs = new HashSet(); @@ -50,38 +43,19 @@ namespace Emby.Server.Implementations.Services ServiceExecGeneral.CreateServiceRunnersFor(requestType, actions); - var returnMarker = GetTypeWithGenericTypeDefinitionOf(requestType, typeof(IReturn<>)); - var responseType = returnMarker != null ? - GetGenericArguments(returnMarker)[0] - : mi.ReturnType != typeof(object) && mi.ReturnType != typeof(void) ? - mi.ReturnType - : Type.GetType(requestType.FullName + "Response"); + //var returnMarker = GetTypeWithGenericTypeDefinitionOf(requestType, typeof(IReturn<>)); + //var responseType = returnMarker != null ? + // GetGenericArguments(returnMarker)[0] + // : mi.ReturnType != typeof(object) && mi.ReturnType != typeof(void) ? + // mi.ReturnType + // : Type.GetType(requestType.FullName + "Response"); RegisterRestPaths(appHost, requestType); - appHost.AddServiceInfo(serviceType, requestType, responseType); + appHost.AddServiceInfo(serviceType, requestType); } } - private static Type GetTypeWithGenericTypeDefinitionOf(Type type, Type genericTypeDefinition) - { - foreach (var t in type.GetTypeInfo().ImplementedInterfaces) - { - if (t.GetTypeInfo().IsGenericType && t.GetGenericTypeDefinition() == genericTypeDefinition) - { - return t; - } - } - - var genericType = FirstGenericType(type); - if (genericType != null && genericType.GetGenericTypeDefinition() == genericTypeDefinition) - { - return genericType; - } - - return null; - } - public static Type FirstGenericType(Type type) { while (type != null) diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index dc7e83992..ee373139f 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -468,7 +468,7 @@ namespace Emby.Server.Implementations.Session if (!userId.HasValue) { - sessionInfo.AdditionalUsers.Clear(); + sessionInfo.AdditionalUsers = new SessionUserInfo[] { }; } if (sessionInfo.SessionController == null) @@ -1074,7 +1074,7 @@ namespace Emby.Server.Implementations.Session DtoOptions = new DtoOptions(false) { EnableImages = false, - Fields = new List + Fields = new ItemFields[] { ItemFields.SortName } @@ -1097,7 +1097,7 @@ namespace Emby.Server.Implementations.Session DtoOptions = new DtoOptions(false) { EnableImages = false, - Fields = new List + Fields = new ItemFields[] { ItemFields.SortName } @@ -1340,11 +1340,15 @@ namespace Emby.Server.Implementations.Session { var user = _userManager.GetUserById(userId); - session.AdditionalUsers.Add(new SessionUserInfo + var list = session.AdditionalUsers.ToList(); + + list.Add(new SessionUserInfo { UserId = userId, UserName = user.Name }); + + session.AdditionalUsers = list.ToArray(list.Count); } } @@ -1368,7 +1372,10 @@ namespace Emby.Server.Implementations.Session if (user != null) { - session.AdditionalUsers.Remove(user); + var list = session.AdditionalUsers.ToList(); + list.Remove(user); + + session.AdditionalUsers = list.ToArray(list.Count); } } @@ -1661,35 +1668,39 @@ namespace Emby.Server.Implementations.Session AddProgramRecordingInfo = false }; - dtoOptions.Fields.Remove(ItemFields.BasicSyncInfo); - dtoOptions.Fields.Remove(ItemFields.SyncInfo); - dtoOptions.Fields.Remove(ItemFields.CanDelete); - dtoOptions.Fields.Remove(ItemFields.CanDownload); - dtoOptions.Fields.Remove(ItemFields.ChildCount); - dtoOptions.Fields.Remove(ItemFields.CustomRating); - dtoOptions.Fields.Remove(ItemFields.DateLastMediaAdded); - dtoOptions.Fields.Remove(ItemFields.DateLastRefreshed); - dtoOptions.Fields.Remove(ItemFields.DateLastSaved); - dtoOptions.Fields.Remove(ItemFields.DisplayPreferencesId); - dtoOptions.Fields.Remove(ItemFields.Etag); - dtoOptions.Fields.Remove(ItemFields.ExternalEtag); - dtoOptions.Fields.Remove(ItemFields.InheritedParentalRatingValue); - dtoOptions.Fields.Remove(ItemFields.ItemCounts); - dtoOptions.Fields.Remove(ItemFields.MediaSourceCount); - dtoOptions.Fields.Remove(ItemFields.MediaStreams); - dtoOptions.Fields.Remove(ItemFields.MediaSources); - dtoOptions.Fields.Remove(ItemFields.People); - dtoOptions.Fields.Remove(ItemFields.PlayAccess); - dtoOptions.Fields.Remove(ItemFields.People); - dtoOptions.Fields.Remove(ItemFields.ProductionLocations); - dtoOptions.Fields.Remove(ItemFields.RecursiveItemCount); - dtoOptions.Fields.Remove(ItemFields.RemoteTrailers); - dtoOptions.Fields.Remove(ItemFields.SeasonUserData); - dtoOptions.Fields.Remove(ItemFields.Settings); - dtoOptions.Fields.Remove(ItemFields.SortName); - dtoOptions.Fields.Remove(ItemFields.Tags); - dtoOptions.Fields.Remove(ItemFields.ThemeSongIds); - dtoOptions.Fields.Remove(ItemFields.ThemeVideoIds); + var fields = dtoOptions.Fields.ToList(); + + fields.Remove(ItemFields.BasicSyncInfo); + fields.Remove(ItemFields.SyncInfo); + fields.Remove(ItemFields.CanDelete); + fields.Remove(ItemFields.CanDownload); + fields.Remove(ItemFields.ChildCount); + fields.Remove(ItemFields.CustomRating); + fields.Remove(ItemFields.DateLastMediaAdded); + fields.Remove(ItemFields.DateLastRefreshed); + fields.Remove(ItemFields.DateLastSaved); + fields.Remove(ItemFields.DisplayPreferencesId); + fields.Remove(ItemFields.Etag); + fields.Remove(ItemFields.ExternalEtag); + fields.Remove(ItemFields.InheritedParentalRatingValue); + fields.Remove(ItemFields.ItemCounts); + fields.Remove(ItemFields.MediaSourceCount); + fields.Remove(ItemFields.MediaStreams); + fields.Remove(ItemFields.MediaSources); + fields.Remove(ItemFields.People); + fields.Remove(ItemFields.PlayAccess); + fields.Remove(ItemFields.People); + fields.Remove(ItemFields.ProductionLocations); + fields.Remove(ItemFields.RecursiveItemCount); + fields.Remove(ItemFields.RemoteTrailers); + fields.Remove(ItemFields.SeasonUserData); + fields.Remove(ItemFields.Settings); + fields.Remove(ItemFields.SortName); + fields.Remove(ItemFields.Tags); + fields.Remove(ItemFields.ThemeSongIds); + fields.Remove(ItemFields.ThemeVideoIds); + + dtoOptions.Fields = fields.ToArray(fields.Count); _itemInfoDtoOptions = dtoOptions; } @@ -1698,7 +1709,7 @@ namespace Emby.Server.Implementations.Session if (mediaSource != null) { - info.MediaStreams = mediaSource.MediaStreams; + info.MediaStreams = mediaSource.MediaStreams.ToArray(); } return info; diff --git a/Emby.Server.Implementations/TV/TVSeriesManager.cs b/Emby.Server.Implementations/TV/TVSeriesManager.cs index 03283031e..018e452be 100644 --- a/Emby.Server.Implementations/TV/TVSeriesManager.cs +++ b/Emby.Server.Implementations/TV/TVSeriesManager.cs @@ -72,7 +72,7 @@ namespace Emby.Server.Implementations.TV Recursive = true, DtoOptions = new MediaBrowser.Controller.Dto.DtoOptions { - Fields = new List + Fields = new ItemFields[] { ItemFields.SeriesPresentationUniqueKey } @@ -128,7 +128,7 @@ namespace Emby.Server.Implementations.TV Limit = limit, DtoOptions = new MediaBrowser.Controller.Dto.DtoOptions { - Fields = new List + Fields = new ItemFields[] { ItemFields.SeriesPresentationUniqueKey }, @@ -207,7 +207,7 @@ namespace Emby.Server.Implementations.TV ParentIndexNumberNotEquals = 0, DtoOptions = new MediaBrowser.Controller.Dto.DtoOptions { - Fields = new List + Fields = new ItemFields[] { ItemFields.SortName }, diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index 6e37c1dc1..6f9c85671 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -157,7 +157,7 @@ namespace Emby.Server.Implementations.Updates /// Gets all available packages. /// /// Task{List{PackageInfo}}. - public async Task> GetAvailablePackages(CancellationToken cancellationToken, + public async Task GetAvailablePackages(CancellationToken cancellationToken, bool withRegistration = true, string packageType = null, Version applicationVersion = null) @@ -175,7 +175,7 @@ namespace Emby.Server.Implementations.Updates { cancellationToken.ThrowIfCancellationRequested(); - var packages = _jsonSerializer.DeserializeFromStream>(json).ToList(); + var packages = _jsonSerializer.DeserializeFromStream(json); return FilterPackages(packages, packageType, applicationVersion); } @@ -184,7 +184,7 @@ namespace Emby.Server.Implementations.Updates { var packages = await GetAvailablePackagesWithoutRegistrationInfo(cancellationToken).ConfigureAwait(false); - return FilterPackages(packages.ToList(), packageType, applicationVersion); + return FilterPackages(packages, packageType, applicationVersion); } } @@ -195,14 +195,14 @@ namespace Emby.Server.Implementations.Updates /// /// The cancellation token. /// Task{List{PackageInfo}}. - public async Task> GetAvailablePackagesWithoutRegistrationInfo(CancellationToken cancellationToken) + public async Task GetAvailablePackagesWithoutRegistrationInfo(CancellationToken cancellationToken) { _logger.Info("Opening {0}", PackageCachePath); try { using (var stream = _fileSystem.OpenRead(PackageCachePath)) { - var packages = _jsonSerializer.DeserializeFromStream>(stream).ToList(); + var packages = _jsonSerializer.DeserializeFromStream(stream); if (DateTime.UtcNow - _lastPackageUpdateTime > GetCacheLength()) { @@ -221,7 +221,7 @@ namespace Emby.Server.Implementations.Updates await UpdateCachedPackages(cancellationToken, true).ConfigureAwait(false); using (var stream = _fileSystem.OpenRead(PackageCachePath)) { - return _jsonSerializer.DeserializeFromStream>(stream).ToList(); + return _jsonSerializer.DeserializeFromStream(stream); } } @@ -288,31 +288,29 @@ namespace Emby.Server.Implementations.Updates } } - protected IEnumerable FilterPackages(List packages) + protected PackageInfo[] FilterPackages(List packages) { foreach (var package in packages) { package.versions = package.versions.Where(v => !string.IsNullOrWhiteSpace(v.sourceUrl)) - .OrderByDescending(GetPackageVersion).ToList(); + .OrderByDescending(GetPackageVersion).ToArray(); } // Remove packages with no versions - packages = packages.Where(p => p.versions.Any()).ToList(); - - return packages; + return packages.Where(p => p.versions.Any()).ToArray(); } - protected IEnumerable FilterPackages(List packages, string packageType, Version applicationVersion) + protected PackageInfo[] FilterPackages(PackageInfo[] packages, string packageType, Version applicationVersion) { foreach (var package in packages) { package.versions = package.versions.Where(v => !string.IsNullOrWhiteSpace(v.sourceUrl)) - .OrderByDescending(GetPackageVersion).ToList(); + .OrderByDescending(GetPackageVersion).ToArray(); } if (!string.IsNullOrWhiteSpace(packageType)) { - packages = packages.Where(p => string.Equals(p.type, packageType, StringComparison.OrdinalIgnoreCase)).ToList(); + packages = packages.Where(p => string.Equals(p.type, packageType, StringComparison.OrdinalIgnoreCase)).ToArray(); } // If an app version was supplied, filter the versions for each package to only include supported versions @@ -320,14 +318,12 @@ namespace Emby.Server.Implementations.Updates { foreach (var package in packages) { - package.versions = package.versions.Where(v => IsPackageVersionUpToDate(v, applicationVersion)).ToList(); + package.versions = package.versions.Where(v => IsPackageVersionUpToDate(v, applicationVersion)).ToArray(); } } // Remove packages with no versions - packages = packages.Where(p => p.versions.Any()).ToList(); - - return packages; + return packages.Where(p => p.versions.Any()).ToArray(); } /// @@ -418,30 +414,24 @@ namespace Emby.Server.Implementations.Updates /// Task{IEnumerable{PackageVersionInfo}}. public async Task> GetAvailablePluginUpdates(Version applicationVersion, bool withAutoUpdateEnabled, CancellationToken cancellationToken) { - var catalog = await GetAvailablePackagesWithoutRegistrationInfo(cancellationToken).ConfigureAwait(false); - - var plugins = _applicationHost.Plugins.ToList(); - - if (withAutoUpdateEnabled) + if (!_config.CommonConfiguration.EnableAutoUpdate) { - plugins = plugins - .Where(p => _config.CommonConfiguration.EnableAutoUpdate) - .ToList(); + return new PackageVersionInfo[] { }; } + var catalog = await GetAvailablePackagesWithoutRegistrationInfo(cancellationToken).ConfigureAwait(false); + var systemUpdateLevel = GetSystemUpdateLevel(); // Figure out what needs to be installed - var packages = plugins.Select(p => + return _applicationHost.Plugins.Select(p => { var latestPluginInfo = GetLatestCompatibleVersion(catalog, p.Name, p.Id.ToString(), applicationVersion, systemUpdateLevel); return latestPluginInfo != null && GetPackageVersion(latestPluginInfo) > p.Version ? latestPluginInfo : null; - }).Where(i => i != null).ToList(); - - return packages - .Where(p => !string.IsNullOrWhiteSpace(p.sourceUrl) && !CompletedInstallations.Any(i => string.Equals(i.AssemblyGuid, p.guid, StringComparison.OrdinalIgnoreCase))); + }).Where(i => i != null) + .Where(p => !string.IsNullOrWhiteSpace(p.sourceUrl) && !CompletedInstallations.Any(i => string.Equals(i.AssemblyGuid, p.guid, StringComparison.OrdinalIgnoreCase))); } /// diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index d3cc18d4b..1629d49b4 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using MediaBrowser.Model.Services; +using MediaBrowser.Model.Extensions; namespace MediaBrowser.Api { @@ -54,6 +55,17 @@ namespace MediaBrowser.Api return Request.Headers[name]; } + private static readonly string[] EmptyStringArray = new string[] { }; + public static string[] SplitValue(string value, char delim) + { + if (string.IsNullOrWhiteSpace(value)) + { + return EmptyStringArray; + } + + return value.Split(new[] { delim }, StringSplitOptions.RemoveEmptyEntries); + } + /// /// To the optimized result. /// @@ -128,7 +140,7 @@ namespace MediaBrowser.Api var hasFields = request as IHasItemFields; if (hasFields != null) { - options.Fields = hasFields.GetItemFields().ToList(); + options.Fields = hasFields.GetItemFields(); } var client = authInfo.Client ?? string.Empty; @@ -137,7 +149,9 @@ namespace MediaBrowser.Api client.IndexOf("media center", StringComparison.OrdinalIgnoreCase) != -1 || client.IndexOf("classic", StringComparison.OrdinalIgnoreCase) != -1) { - options.Fields.Add(Model.Querying.ItemFields.RecursiveItemCount); + var list = options.Fields.ToList(); + list.Add(Model.Querying.ItemFields.RecursiveItemCount); + options.Fields = list.ToArray(list.Count); } if (client.IndexOf("kodi", StringComparison.OrdinalIgnoreCase) != -1 || @@ -148,7 +162,9 @@ namespace MediaBrowser.Api client.IndexOf("samsung", StringComparison.OrdinalIgnoreCase) != -1 || client.IndexOf("androidtv", StringComparison.OrdinalIgnoreCase) != -1) { - options.Fields.Add(Model.Querying.ItemFields.ChildCount); + var list = options.Fields.ToList(); + list.Add(Model.Querying.ItemFields.ChildCount); + options.Fields = list.ToArray(list.Count); } var hasDtoOptions = request as IHasDtoOptions; @@ -167,7 +183,7 @@ namespace MediaBrowser.Api if (!string.IsNullOrWhiteSpace(hasDtoOptions.EnableImageTypes)) { - options.ImageTypes = (hasDtoOptions.EnableImageTypes ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true)).ToList(); + options.ImageTypes = (hasDtoOptions.EnableImageTypes ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true)).ToArray(); } } diff --git a/MediaBrowser.Api/ChannelService.cs b/MediaBrowser.Api/ChannelService.cs index bce1e6682..c7ceb41bc 100644 --- a/MediaBrowser.Api/ChannelService.cs +++ b/MediaBrowser.Api/ChannelService.cs @@ -55,7 +55,7 @@ namespace MediaBrowser.Api } [Route("/Channels/Features", "GET", Summary = "Gets features for a channel")] - public class GetAllChannelFeatures : IReturn> + public class GetAllChannelFeatures : IReturn { } @@ -187,7 +187,7 @@ namespace MediaBrowser.Api public object Get(GetAllChannelFeatures request) { - var result = _channelManager.GetAllChannelFeatures().ToList(); + var result = _channelManager.GetAllChannelFeatures(); return ToOptimizedResult(result); } @@ -247,7 +247,7 @@ namespace MediaBrowser.Api ChannelIds = (request.ChannelIds ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToArray(), UserId = request.UserId, Filters = request.GetFilters().ToArray(), - Fields = request.GetItemFields().ToList() + Fields = request.GetItemFields() }, CancellationToken.None).ConfigureAwait(false); diff --git a/MediaBrowser.Api/ConfigurationService.cs b/MediaBrowser.Api/ConfigurationService.cs index 8d5f46962..92128634e 100644 --- a/MediaBrowser.Api/ConfigurationService.cs +++ b/MediaBrowser.Api/ConfigurationService.cs @@ -62,7 +62,7 @@ namespace MediaBrowser.Api [Route("/System/Configuration/MetadataPlugins", "GET", Summary = "Gets all available metadata plugins")] [Authenticated(Roles = "Admin")] - public class GetMetadataPlugins : IReturn> + public class GetMetadataPlugins : IReturn { } @@ -170,7 +170,7 @@ namespace MediaBrowser.Api public object Get(GetMetadataPlugins request) { - return ToOptimizedSerializedResultUsingCache(_providerManager.GetAllMetadataPlugins().ToList()); + return ToOptimizedSerializedResultUsingCache(_providerManager.GetAllMetadataPlugins()); } } } diff --git a/MediaBrowser.Api/Dlna/DlnaService.cs b/MediaBrowser.Api/Dlna/DlnaService.cs index ecb54bf5c..fa3287ebd 100644 --- a/MediaBrowser.Api/Dlna/DlnaService.cs +++ b/MediaBrowser.Api/Dlna/DlnaService.cs @@ -1,14 +1,13 @@ using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Dlna; -using System.Collections.Generic; using System.Linq; using MediaBrowser.Model.Services; namespace MediaBrowser.Api.Dlna { [Route("/Dlna/ProfileInfos", "GET", Summary = "Gets a list of profiles")] - public class GetProfileInfos : IReturn> + public class GetProfileInfos : IReturn { } @@ -53,7 +52,7 @@ namespace MediaBrowser.Api.Dlna public object Get(GetProfileInfos request) { - var result = _dlnaManager.GetProfileInfos().ToList(); + var result = _dlnaManager.GetProfileInfos().ToArray(); return ToOptimizedResult(result); } diff --git a/MediaBrowser.Api/EnvironmentService.cs b/MediaBrowser.Api/EnvironmentService.cs index 9764a71db..bc6101d6c 100644 --- a/MediaBrowser.Api/EnvironmentService.cs +++ b/MediaBrowser.Api/EnvironmentService.cs @@ -226,7 +226,7 @@ namespace MediaBrowser.Api return ToOptimizedSerializedResultUsingCache(GetNetworkShares(path).OrderBy(i => i.Path).ToList()); } - return ToOptimizedSerializedResultUsingCache(GetFileSystemEntries(request).OrderBy(i => i.Path).ToList()); + return ToOptimizedSerializedResultUsingCache(GetFileSystemEntries(request).ToList()); } public object Get(GetNetworkShares request) @@ -271,9 +271,7 @@ namespace MediaBrowser.Api /// System.Object. public object Get(GetNetworkDevices request) { - var result = _networkManager.GetNetworkDevices() - .OrderBy(i => i.Path) - .ToList(); + var result = _networkManager.GetNetworkDevices().ToList(); return ToOptimizedSerializedResultUsingCache(result); } @@ -300,7 +298,6 @@ namespace MediaBrowser.Api /// IEnumerable{FileSystemEntryInfo}. private IEnumerable GetFileSystemEntries(GetDirectoryContents request) { - // using EnumerateFileSystemInfos doesn't handle reparse points (symlinks) var entries = _fileSystem.GetFileSystemEntries(request.Path).Where(i => { if (!request.IncludeHidden && i.IsHidden) @@ -329,7 +326,7 @@ namespace MediaBrowser.Api Path = f.FullName, Type = f.IsDirectory ? FileSystemEntryType.Directory : FileSystemEntryType.File - }).ToList(); + }); } public object Get(GetParentPath request) diff --git a/MediaBrowser.Api/FilterService.cs b/MediaBrowser.Api/FilterService.cs index 41b17e535..52b274653 100644 --- a/MediaBrowser.Api/FilterService.cs +++ b/MediaBrowser.Api/FilterService.cs @@ -108,7 +108,7 @@ namespace MediaBrowser.Api EnableTotalRecordCount = false, DtoOptions = new Controller.Dto.DtoOptions { - Fields = new List { ItemFields.Genres, ItemFields.Tags }, + Fields = new ItemFields[] { ItemFields.Genres, ItemFields.Tags }, EnableImages = false, EnableUserData = false } diff --git a/MediaBrowser.Api/GamesService.cs b/MediaBrowser.Api/GamesService.cs index 0ce57a16a..8a16cbfa1 100644 --- a/MediaBrowser.Api/GamesService.cs +++ b/MediaBrowser.Api/GamesService.cs @@ -28,21 +28,7 @@ namespace MediaBrowser.Api /// Class GetGameSystemSummaries /// [Route("/Games/SystemSummaries", "GET", Summary = "Finds games similar to a given game.")] - public class GetGameSystemSummaries : IReturn> - { - /// - /// Gets or sets the user id. - /// - /// The user id. - [ApiMember(Name = "UserId", Description = "Optional. Filter by user id", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] - public string UserId { get; set; } - } - - /// - /// Class GetGameSystemSummaries - /// - [Route("/Games/PlayerIndex", "GET", Summary = "Gets an index of players (1-x) and the number of games listed under each")] - public class GetPlayerIndex : IReturn> + public class GetGameSystemSummaries : IReturn { /// /// Gets or sets the user id. @@ -117,47 +103,17 @@ namespace MediaBrowser.Api EnableImages = false } }; - var gameSystems = _libraryManager.GetItemList(query) - .Cast() - .ToList(); - var result = gameSystems + var result = _libraryManager.GetItemList(query) + .Cast() .Select(i => GetSummary(i, user)) - .ToList(); + .ToArray(); return ToOptimizedSerializedResultUsingCache(result); } private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); - public object Get(GetPlayerIndex request) - { - var user = request.UserId == null ? null : _userManager.GetUserById(request.UserId); - var query = new InternalItemsQuery(user) - { - IncludeItemTypes = new[] { typeof(Game).Name }, - DtoOptions = new DtoOptions(false) - { - EnableImages = false - } - }; - var games = _libraryManager.GetItemList(query) - .Cast() - .ToList(); - - var lookup = games - .ToLookup(i => i.PlayersSupported ?? -1) - .OrderBy(i => i.Key) - .Select(i => new ItemIndex - { - ItemCount = i.Count(), - Name = i.Key == -1 ? string.Empty : i.Key.ToString(UsCulture) - }) - .ToList(); - - return ToOptimizedSerializedResultUsingCache(lookup); - } - /// /// Gets the summary. /// @@ -183,15 +139,15 @@ namespace MediaBrowser.Api } }); - var games = items.Cast().ToList(); + var games = items.Cast().ToArray(); summary.ClientInstalledGameCount = games.Count(i => i.IsPlaceHolder); - summary.GameCount = games.Count; + summary.GameCount = games.Length; summary.GameFileExtensions = games.Where(i => !i.IsPlaceHolder).Select(i => Path.GetExtension(i.Path)) .Distinct(StringComparer.OrdinalIgnoreCase) - .ToList(); + .ToArray(); return summary; } @@ -234,7 +190,7 @@ namespace MediaBrowser.Api var result = new QueryResult { - Items = returnList.ToArray(returnList.Count), + Items = returnList, TotalRecordCount = itemsResult.Count }; diff --git a/MediaBrowser.Api/IHasItemFields.cs b/MediaBrowser.Api/IHasItemFields.cs index 36303c889..0b3919985 100644 --- a/MediaBrowser.Api/IHasItemFields.cs +++ b/MediaBrowser.Api/IHasItemFields.cs @@ -27,7 +27,7 @@ namespace MediaBrowser.Api /// /// The request. /// IEnumerable{ItemFields}. - public static IEnumerable GetItemFields(this IHasItemFields request) + public static ItemFields[] GetItemFields(this IHasItemFields request) { var val = request.Fields; @@ -46,7 +46,7 @@ namespace MediaBrowser.Api } return null; - }).Where(i => i.HasValue).Select(i => i.Value); + }).Where(i => i.HasValue).Select(i => i.Value).ToArray(); } } } diff --git a/MediaBrowser.Api/Images/RemoteImageService.cs b/MediaBrowser.Api/Images/RemoteImageService.cs index e4f3fd3d7..3512a526b 100644 --- a/MediaBrowser.Api/Images/RemoteImageService.cs +++ b/MediaBrowser.Api/Images/RemoteImageService.cs @@ -150,7 +150,7 @@ namespace MediaBrowser.Api.Images }, CancellationToken.None).ConfigureAwait(false); - var imagesList = images.ToList(); + var imagesList = images.ToArray(); var allProviders = _providerManager.GetRemoteImageProviderInfo(item); @@ -161,22 +161,22 @@ namespace MediaBrowser.Api.Images var result = new RemoteImageResult { - TotalRecordCount = imagesList.Count, + TotalRecordCount = imagesList.Length, Providers = allProviders.Select(i => i.Name) .Distinct(StringComparer.OrdinalIgnoreCase) - .ToList() + .ToArray() }; if (request.StartIndex.HasValue) { imagesList = imagesList.Skip(request.StartIndex.Value) - .ToList(); + .ToArray(); } if (request.Limit.HasValue) { imagesList = imagesList.Take(request.Limit.Value) - .ToList(); + .ToArray(); } result.Images = imagesList; diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index 313f7aab5..56caf884b 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -64,8 +64,8 @@ namespace MediaBrowser.Api var info = new MetadataEditorInfo { - ParentalRatingOptions = _localizationManager.GetParentalRatings().ToList(), - ExternalIdInfos = _providerManager.GetExternalIdInfos(item).ToList(), + ParentalRatingOptions = _localizationManager.GetParentalRatings(), + ExternalIdInfos = _providerManager.GetExternalIdInfos(item).ToArray(), Countries = _localizationManager.GetCountries(), Cultures = _localizationManager.GetCultures() }; @@ -78,14 +78,14 @@ namespace MediaBrowser.Api if (string.IsNullOrWhiteSpace(inheritedContentType) || !string.IsNullOrWhiteSpace(configuredContentType)) { - info.ContentTypeOptions = GetContentTypeOptions(true); + info.ContentTypeOptions = GetContentTypeOptions(true).ToArray(); info.ContentType = configuredContentType; if (string.IsNullOrWhiteSpace(inheritedContentType) || string.Equals(inheritedContentType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase)) { info.ContentTypeOptions = info.ContentTypeOptions .Where(i => string.IsNullOrWhiteSpace(i.Value) || string.Equals(i.Value, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase)) - .ToList(); + .ToArray(); } } } diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index 7dd1afaf4..6c9f5d32b 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -227,7 +227,7 @@ namespace MediaBrowser.Api.Library [Route("/Library/MediaFolders", "GET", Summary = "Gets all user media folders.")] [Authenticated] - public class GetMediaFolders : IReturn + public class GetMediaFolders : IReturn> { [ApiMember(Name = "IsHidden", Description = "Optional. Filter by folders that are marked hidden, or not.", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] public bool? IsHidden { get; set; } @@ -400,7 +400,7 @@ namespace MediaBrowser.Api.Library }); } - return new ItemsResult(); + return new QueryResult(); } public object Get(GetMediaFolders request) @@ -416,7 +416,7 @@ namespace MediaBrowser.Api.Library var dtoOptions = GetDtoOptions(_authContext, request); - var result = new ItemsResult + var result = new QueryResult { TotalRecordCount = items.Count, @@ -615,7 +615,7 @@ namespace MediaBrowser.Api.Library parent = parent.GetParent(); } - return baseItemDtos.ToList(); + return baseItemDtos; } private BaseItem TranslateParentItem(BaseItem item, User user) diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index e2961f630..e866be9c6 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -648,7 +648,7 @@ namespace MediaBrowser.Api.LiveTv { public List TunerChannels { get; set; } public List ProviderChannels { get; set; } - public List Mappings { get; set; } + public NameValuePair[] Mappings { get; set; } public string ProviderName { get; set; } } @@ -789,7 +789,7 @@ namespace MediaBrowser.Api.LiveTv var providerChannels = await _liveTvManager.GetChannelsFromListingsProviderData(request.ProviderId, CancellationToken.None) .ConfigureAwait(false); - var mappings = listingsProviderInfo.ChannelMappings.ToList(); + var mappings = listingsProviderInfo.ChannelMappings; var result = new ChannelMappingOptions { @@ -862,7 +862,7 @@ namespace MediaBrowser.Api.LiveTv { var config = GetConfiguration(); - config.TunerHosts = config.TunerHosts.Where(i => !string.Equals(request.Id, i.Id, StringComparison.OrdinalIgnoreCase)).ToList(); + config.TunerHosts = config.TunerHosts.Where(i => !string.Equals(request.Id, i.Id, StringComparison.OrdinalIgnoreCase)).ToArray(); _config.SaveConfiguration("livetv", config); } @@ -922,9 +922,8 @@ namespace MediaBrowser.Api.LiveTv options.AddCurrentProgram = request.AddCurrentProgram; - var returnList = (await _dtoService.GetBaseItemDtos(channelResult.Items, options, user) + var returnArray = (await _dtoService.GetBaseItemDtos(channelResult.Items, options, user) .ConfigureAwait(false)); - var returnArray = returnList.ToArray(returnList.Count); var result = new QueryResult { @@ -937,10 +936,13 @@ namespace MediaBrowser.Api.LiveTv private void RemoveFields(DtoOptions options) { - options.Fields.Remove(ItemFields.CanDelete); - options.Fields.Remove(ItemFields.CanDownload); - options.Fields.Remove(ItemFields.DisplayPreferencesId); - options.Fields.Remove(ItemFields.Etag); + var fields = options.Fields.ToList(); + + fields.Remove(ItemFields.CanDelete); + fields.Remove(ItemFields.CanDownload); + fields.Remove(ItemFields.DisplayPreferencesId); + fields.Remove(ItemFields.Etag); + options.Fields = fields.ToArray(fields.Count); } public object Get(GetChannel request) diff --git a/MediaBrowser.Api/LocalizationService.cs b/MediaBrowser.Api/LocalizationService.cs index eee340a87..2c92505b1 100644 --- a/MediaBrowser.Api/LocalizationService.cs +++ b/MediaBrowser.Api/LocalizationService.cs @@ -11,7 +11,7 @@ namespace MediaBrowser.Api /// Class GetCultures /// [Route("/Localization/Cultures", "GET", Summary = "Gets known cultures")] - public class GetCultures : IReturn> + public class GetCultures : IReturn { } @@ -19,7 +19,7 @@ namespace MediaBrowser.Api /// Class GetCountries /// [Route("/Localization/Countries", "GET", Summary = "Gets known countries")] - public class GetCountries : IReturn> + public class GetCountries : IReturn { } @@ -27,7 +27,7 @@ namespace MediaBrowser.Api /// Class ParentalRatings /// [Route("/Localization/ParentalRatings", "GET", Summary = "Gets known parental ratings")] - public class GetParentalRatings : IReturn> + public class GetParentalRatings : IReturn { } @@ -35,7 +35,7 @@ namespace MediaBrowser.Api /// Class ParentalRatings /// [Route("/Localization/Options", "GET", Summary = "Gets localization options")] - public class GetLocalizationOptions : IReturn> + public class GetLocalizationOptions : IReturn { } @@ -66,14 +66,14 @@ namespace MediaBrowser.Api /// System.Object. public object Get(GetParentalRatings request) { - var result = _localization.GetParentalRatings().ToList(); + var result = _localization.GetParentalRatings(); return ToOptimizedResult(result); } public object Get(GetLocalizationOptions request) { - var result = _localization.GetLocalizationOptions().ToList(); + var result = _localization.GetLocalizationOptions(); return ToOptimizedResult(result); } diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj index 810b0f6b2..602a697bf 100644 --- a/MediaBrowser.Api/MediaBrowser.Api.csproj +++ b/MediaBrowser.Api/MediaBrowser.Api.csproj @@ -97,7 +97,6 @@ - diff --git a/MediaBrowser.Api/Movies/CollectionService.cs b/MediaBrowser.Api/Movies/CollectionService.cs index 917a3bc0b..6511d3127 100644 --- a/MediaBrowser.Api/Movies/CollectionService.cs +++ b/MediaBrowser.Api/Movies/CollectionService.cs @@ -71,8 +71,8 @@ namespace MediaBrowser.Api.Movies IsLocked = request.IsLocked, Name = request.Name, ParentId = parentId, - ItemIdList = (request.Ids ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => new Guid(i)).ToList(), - UserIds = new List { new Guid(userId) } + ItemIdList = SplitValue(request.Ids, ','), + UserIds = new string[] { userId } }).ConfigureAwait(false); @@ -88,14 +88,14 @@ namespace MediaBrowser.Api.Movies public void Post(AddToCollection request) { - var task = _collectionManager.AddToCollection(new Guid(request.Id), request.Ids.Split(',').Select(i => new Guid(i))); + var task = _collectionManager.AddToCollection(new Guid(request.Id), SplitValue(request.Ids, ',')); Task.WaitAll(task); } public void Delete(RemoveFromCollection request) { - var task = _collectionManager.RemoveFromCollection(new Guid(request.Id), request.Ids.Split(',').Select(i => new Guid(i))); + var task = _collectionManager.RemoveFromCollection(new Guid(request.Id), SplitValue(request.Ids, ',')); Task.WaitAll(task); } diff --git a/MediaBrowser.Api/Movies/MoviesService.cs b/MediaBrowser.Api/Movies/MoviesService.cs index c668d2c75..7873c1cd3 100644 --- a/MediaBrowser.Api/Movies/MoviesService.cs +++ b/MediaBrowser.Api/Movies/MoviesService.cs @@ -170,7 +170,7 @@ namespace MediaBrowser.Api.Movies var result = new QueryResult { - Items = returnList.ToArray(returnList.Count), + Items = returnList, TotalRecordCount = itemsResult.Count }; @@ -320,7 +320,7 @@ namespace MediaBrowser.Api.Movies BaselineItemName = name, CategoryId = name.GetMD5().ToString("N"), RecommendationType = type, - Items = returnItems.ToArray(returnItems.Count) + Items = returnItems }; } } @@ -360,7 +360,7 @@ namespace MediaBrowser.Api.Movies BaselineItemName = name, CategoryId = name.GetMD5().ToString("N"), RecommendationType = type, - Items = returnItems.ToArray(returnItems.Count) + Items = returnItems }; } } @@ -397,7 +397,7 @@ namespace MediaBrowser.Api.Movies BaselineItemName = item.Name, CategoryId = item.Id.ToString("N"), RecommendationType = type, - Items = returnItems.ToArray(returnItems.Count) + Items = returnItems }; } } diff --git a/MediaBrowser.Api/Movies/TrailersService.cs b/MediaBrowser.Api/Movies/TrailersService.cs index eb5365ab8..45b07712f 100644 --- a/MediaBrowser.Api/Movies/TrailersService.cs +++ b/MediaBrowser.Api/Movies/TrailersService.cs @@ -4,6 +4,7 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Querying; using MediaBrowser.Controller.Collections; +using MediaBrowser.Model.Dto; using MediaBrowser.Model.Globalization; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Services; @@ -11,7 +12,7 @@ using MediaBrowser.Model.Services; namespace MediaBrowser.Api.Movies { [Route("/Trailers", "GET", Summary = "Finds movies and trailers similar to a given trailer.")] - public class Getrailers : BaseItemsRequest, IReturn + public class Getrailers : BaseItemsRequest, IReturn> { } diff --git a/MediaBrowser.Api/Music/InstantMixService.cs b/MediaBrowser.Api/Music/InstantMixService.cs index b0f086ec5..bf6b75a3e 100644 --- a/MediaBrowser.Api/Music/InstantMixService.cs +++ b/MediaBrowser.Api/Music/InstantMixService.cs @@ -8,6 +8,7 @@ using MediaBrowser.Model.Querying; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using MediaBrowser.Model.Dto; using MediaBrowser.Model.Services; using MediaBrowser.Model.Extensions; @@ -185,15 +186,20 @@ namespace MediaBrowser.Api.Music { var list = items; - var result = new ItemsResult + var result = new QueryResult { TotalRecordCount = list.Count }; - var returnList = (await _dtoService.GetBaseItemDtos(list.Take(request.Limit ?? list.Count), dtoOptions, user) + if (request.Limit.HasValue) + { + list = list.Take(request.Limit.Value).ToList(); + } + + var returnList = (await _dtoService.GetBaseItemDtos(list, dtoOptions, user) .ConfigureAwait(false)); - result.Items = returnList.ToArray(returnList.Count); + result.Items = returnList; return ToOptimizedResult(result); } diff --git a/MediaBrowser.Api/NotificationsService.cs b/MediaBrowser.Api/NotificationsService.cs index 58e413cef..4876351fc 100644 --- a/MediaBrowser.Api/NotificationsService.cs +++ b/MediaBrowser.Api/NotificationsService.cs @@ -99,7 +99,7 @@ namespace MediaBrowser.Api public object Get(GetNotificationTypes request) { - var result = _notificationManager.GetNotificationTypes().ToList(); + var result = _notificationManager.GetNotificationTypes(); return ToOptimizedResult(result); } diff --git a/MediaBrowser.Api/PackageReviewService.cs b/MediaBrowser.Api/PackageReviewService.cs deleted file mode 100644 index baf1adc19..000000000 --- a/MediaBrowser.Api/PackageReviewService.cs +++ /dev/null @@ -1,162 +0,0 @@ -using MediaBrowser.Common.Net; -using MediaBrowser.Controller; -using MediaBrowser.Controller.Net; -using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Serialization; -using System.Collections.Generic; -using System.Globalization; -using System.Net; -using System.Threading; -using System.Threading.Tasks; -using MediaBrowser.Model.Services; - -namespace MediaBrowser.Api -{ - /// - /// Class InstallPackage - /// - [Route("/Packages/Reviews/{Id}", "POST", Summary = "Creates or updates a package review")] - public class CreateReviewRequest : IReturnVoid - { - /// - /// Gets or sets the Id. - /// - /// The Id. - [ApiMember(Name = "Id", Description = "Package Id", IsRequired = true, DataType = "int", ParameterType = "path", Verb = "POST")] - public int Id { get; set; } - - /// - /// Gets or sets the rating. - /// - /// The review. - [ApiMember(Name = "Rating", Description = "The rating value (1-5)", IsRequired = true, DataType = "int", ParameterType = "query", Verb = "POST")] - public int Rating { get; set; } - - /// - /// Gets or sets the recommend value. - /// - /// Whether or not this review recommends this item. - [ApiMember(Name = "Recommend", Description = "Whether or not this review recommends this item", IsRequired = true, DataType = "bool", ParameterType = "query", Verb = "POST")] - public bool Recommend { get; set; } - - /// - /// Gets or sets the title. - /// - /// The title. - [ApiMember(Name = "Title", Description = "Optional short description of review.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")] - public string Title { get; set; } - - /// - /// Gets or sets the full review. - /// - /// The full review. - [ApiMember(Name = "Review", Description = "Optional full review.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")] - public string Review { get; set; } - } - - /// - /// Class InstallPackage - /// - [Route("/Packages/{Id}/Reviews", "GET", Summary = "Gets reviews for a package")] - public class ReviewRequest : IReturn> - { - /// - /// Gets or sets the Id. - /// - /// The Id. - [ApiMember(Name = "Id", Description = "Package Id", IsRequired = true, DataType = "int", ParameterType = "path", Verb = "GET")] - public int Id { get; set; } - - /// - /// Gets or sets the max rating. - /// - /// The max rating. - [ApiMember(Name = "MaxRating", Description = "Retrieve only reviews less than or equal to this", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] - public int MaxRating { get; set; } - - /// - /// Gets or sets the min rating. - /// - /// The max rating. - [ApiMember(Name = "MinRating", Description = "Retrieve only reviews greator than or equal to this", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] - public int MinRating { get; set; } - - /// - /// Only retrieve reviews with at least a short review. - /// - /// True if should only get reviews with a title. - [ApiMember(Name = "ForceTitle", Description = "Whether or not to restrict results to those with a title", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] - public bool ForceTitle { get; set; } - - /// - /// Gets or sets the limit for the query. - /// - /// The max rating. - [ApiMember(Name = "Limit", Description = "Limit the result to this many reviews (ordered by latest)", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] - public int Limit { get; set; } - - } - - [Authenticated] - public class PackageReviewService : BaseApiService - { - private readonly IHttpClient _httpClient; - private readonly IJsonSerializer _serializer; - private const string MbAdminUrl = "https://www.mb3admin.com/admin/"; - private readonly IServerApplicationHost _appHost; - - public PackageReviewService(IHttpClient httpClient, IJsonSerializer serializer, IServerApplicationHost appHost) - { - _httpClient = httpClient; - _serializer = serializer; - _appHost = appHost; - } - - public async Task Get(ReviewRequest request) - { - var parms = "?id=" + request.Id; - - if (request.MaxRating > 0) - { - parms += "&max=" + request.MaxRating; - } - if (request.MinRating > 0) - { - parms += "&min=" + request.MinRating; - } - if (request.MinRating > 0) - { - parms += "&limit=" + request.Limit; - } - if (request.ForceTitle) - { - parms += "&title=true"; - } - - using (var result = await _httpClient.Get(MbAdminUrl + "/service/packageReview/retrieve" + parms, CancellationToken.None) - .ConfigureAwait(false)) - { - var reviews = _serializer.DeserializeFromStream>(result); - - return ToOptimizedResult(reviews); - } - } - - public void Post(CreateReviewRequest request) - { - var reviewText = WebUtility.HtmlEncode(request.Review ?? string.Empty); - var title = WebUtility.HtmlEncode(request.Title ?? string.Empty); - - var review = new Dictionary - { { "id", request.Id.ToString(CultureInfo.InvariantCulture) }, - { "mac", _appHost.SystemId }, - { "rating", request.Rating.ToString(CultureInfo.InvariantCulture) }, - { "recommend", request.Recommend.ToString() }, - { "title", title }, - { "review", reviewText }, - }; - - Task.WaitAll(_httpClient.Post(MbAdminUrl + "/service/packageReview/update", review, CancellationToken.None)); - } - } -} diff --git a/MediaBrowser.Api/PackageService.cs b/MediaBrowser.Api/PackageService.cs index 64424795f..79dda8702 100644 --- a/MediaBrowser.Api/PackageService.cs +++ b/MediaBrowser.Api/PackageService.cs @@ -40,7 +40,7 @@ namespace MediaBrowser.Api /// [Route("/Packages", "GET", Summary = "Gets available packages")] [Authenticated] - public class GetPackages : IReturn> + public class GetPackages : IReturn { /// /// Gets or sets the name. @@ -66,7 +66,7 @@ namespace MediaBrowser.Api /// [Route("/Packages/Updates", "GET", Summary = "Gets available package updates for currently installed packages")] [Authenticated(Roles = "Admin")] - public class GetPackageVersionUpdates : IReturn> + public class GetPackageVersionUpdates : IReturn { /// /// Gets or sets the name. @@ -148,24 +148,26 @@ namespace MediaBrowser.Api /// System.Object. public object Get(GetPackageVersionUpdates request) { - var result = new List(); + PackageVersionInfo[] result = null; if (string.Equals(request.PackageType, "UserInstalled", StringComparison.OrdinalIgnoreCase) || string.Equals(request.PackageType, "All", StringComparison.OrdinalIgnoreCase)) { - result.AddRange(_installationManager.GetAvailablePluginUpdates(_appHost.ApplicationVersion, false, CancellationToken.None).Result.ToList()); + result = _installationManager.GetAvailablePluginUpdates(_appHost.ApplicationVersion, false, CancellationToken.None).Result.ToArray(); } - else if (string.Equals(request.PackageType, "System", StringComparison.OrdinalIgnoreCase) || string.Equals(request.PackageType, "All", StringComparison.OrdinalIgnoreCase)) + else if (string.Equals(request.PackageType, "System", StringComparison.OrdinalIgnoreCase) || + string.Equals(request.PackageType, "All", StringComparison.OrdinalIgnoreCase)) { - var updateCheckResult = _appHost.CheckForApplicationUpdate(CancellationToken.None, new SimpleProgress()).Result; + var updateCheckResult = _appHost + .CheckForApplicationUpdate(CancellationToken.None, new SimpleProgress()).Result; if (updateCheckResult.IsUpdateAvailable) { - result.Add(updateCheckResult.Package); + result = new PackageVersionInfo[] {updateCheckResult.Package}; } } - return ToOptimizedResult(result); + return ToOptimizedResult(result ?? new PackageVersionInfo[] { }); } /// @@ -176,10 +178,9 @@ namespace MediaBrowser.Api public object Get(GetPackage request) { var packages = _installationManager.GetAvailablePackages(CancellationToken.None, applicationVersion: _appHost.ApplicationVersion).Result; - var list = packages.ToList(); - var result = list.FirstOrDefault(p => string.Equals(p.guid, request.AssemblyGuid ?? "none", StringComparison.OrdinalIgnoreCase)) - ?? list.FirstOrDefault(p => p.name.Equals(request.Name, StringComparison.OrdinalIgnoreCase)); + var result = packages.FirstOrDefault(p => string.Equals(p.guid, request.AssemblyGuid ?? "none", StringComparison.OrdinalIgnoreCase)) + ?? packages.FirstOrDefault(p => p.name.Equals(request.Name, StringComparison.OrdinalIgnoreCase)); return ToOptimizedResult(result); } @@ -191,7 +192,7 @@ namespace MediaBrowser.Api /// System.Object. public async Task Get(GetPackages request) { - var packages = await _installationManager.GetAvailablePackages(CancellationToken.None, false, request.PackageType, _appHost.ApplicationVersion).ConfigureAwait(false); + IEnumerable packages = await _installationManager.GetAvailablePackages(CancellationToken.None, false, request.PackageType, _appHost.ApplicationVersion).ConfigureAwait(false); if (!string.IsNullOrEmpty(request.TargetSystems)) { @@ -215,7 +216,7 @@ namespace MediaBrowser.Api packages = packages.Where(p => p.enableInAppStore == request.IsAppStoreEnabled.Value); } - return ToOptimizedResult(packages.ToList()); + return ToOptimizedResult(packages.ToArray()); } /// diff --git a/MediaBrowser.Api/PlaylistService.cs b/MediaBrowser.Api/PlaylistService.cs index aef16e442..07a976f39 100644 --- a/MediaBrowser.Api/PlaylistService.cs +++ b/MediaBrowser.Api/PlaylistService.cs @@ -149,7 +149,7 @@ namespace MediaBrowser.Api var result = await _playlistManager.CreatePlaylist(new PlaylistCreationRequest { Name = request.Name, - ItemIdList = (request.Ids ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToList(), + ItemIdList = SplitValue(request.Ids, ','), UserId = request.UserId, MediaType = request.MediaType @@ -193,10 +193,8 @@ namespace MediaBrowser.Api var dtoOptions = GetDtoOptions(_authContext, request); - var returnList = (await _dtoService.GetBaseItemDtos(items.Select(i => i.Item2), dtoOptions, user) + var dtos = (await _dtoService.GetBaseItemDtos(items.Select(i => i.Item2).ToList(), dtoOptions, user) .ConfigureAwait(false)); - var dtos = returnList - .ToArray(returnList.Count); var index = 0; foreach (var item in dtos) @@ -205,7 +203,7 @@ namespace MediaBrowser.Api index++; } - var result = new ItemsResult + var result = new QueryResult { Items = dtos, TotalRecordCount = count diff --git a/MediaBrowser.Api/PluginService.cs b/MediaBrowser.Api/PluginService.cs index eb95224b7..f6efe15e6 100644 --- a/MediaBrowser.Api/PluginService.cs +++ b/MediaBrowser.Api/PluginService.cs @@ -23,7 +23,7 @@ namespace MediaBrowser.Api /// [Route("/Plugins", "GET", Summary = "Gets a list of currently installed plugins")] [Authenticated] - public class GetPlugins : IReturn> + public class GetPlugins : IReturn { public bool? IsAppStoreEnabled { get; set; } } @@ -195,14 +195,13 @@ namespace MediaBrowser.Api /// System.Object. public async Task Get(GetPlugins request) { - var result = _appHost.Plugins.OrderBy(p => p.Name).Select(p => p.GetPluginInfo()).ToList(); + var result = _appHost.Plugins.OrderBy(p => p.Name).Select(p => p.GetPluginInfo()).ToArray(); var requireAppStoreEnabled = request.IsAppStoreEnabled.HasValue && request.IsAppStoreEnabled.Value; // Don't fail just on account of image url's try { - var packages = (await _installationManager.GetAvailablePackagesWithoutRegistrationInfo(CancellationToken.None)) - .ToList(); + var packages = (await _installationManager.GetAvailablePackagesWithoutRegistrationInfo(CancellationToken.None)); foreach (var plugin in result) { @@ -223,7 +222,7 @@ namespace MediaBrowser.Api return pkg != null && pkg.enableInAppStore; }) - .ToList(); + .ToArray(); } } catch @@ -232,7 +231,7 @@ namespace MediaBrowser.Api // Play it safe here if (requireAppStoreEnabled) { - result = new List(); + result = new PluginInfo[] { }; } } diff --git a/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs b/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs index e8ad9ea95..abe3e5407 100644 --- a/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs +++ b/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs @@ -27,7 +27,7 @@ namespace MediaBrowser.Api.ScheduledTasks /// Class GetScheduledTasks /// [Route("/ScheduledTasks", "GET", Summary = "Gets scheduled tasks")] - public class GetScheduledTasks : IReturn> + public class GetScheduledTasks : IReturn { [ApiMember(Name = "IsHidden", Description = "Optional filter tasks that are hidden, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] public bool? IsHidden { get; set; } @@ -158,7 +158,7 @@ namespace MediaBrowser.Api.ScheduledTasks var infos = result .Select(ScheduledTaskHelpers.GetTaskInfo) - .ToList(); + .ToArray(); return ToOptimizedResult(infos); } diff --git a/MediaBrowser.Api/Session/SessionsService.cs b/MediaBrowser.Api/Session/SessionsService.cs index fe40ceeeb..18d261195 100644 --- a/MediaBrowser.Api/Session/SessionsService.cs +++ b/MediaBrowser.Api/Session/SessionsService.cs @@ -18,7 +18,7 @@ namespace MediaBrowser.Api.Session /// [Route("/Sessions", "GET", Summary = "Gets a list of sessions")] [Authenticated] - public class GetSessions : IReturn> + public class GetSessions : IReturn { [ApiMember(Name = "ControllableByUserId", Description = "Optional. Filter by sessions that a given user is allowed to remote control.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public string ControllableByUserId { get; set; } @@ -396,7 +396,7 @@ namespace MediaBrowser.Api.Session }); } - return ToOptimizedResult(result.Select(_sessionManager.GetSessionInfoDto).ToList()); + return ToOptimizedResult(result.Select(_sessionManager.GetSessionInfoDto).ToArray()); } public void Post(SendPlaystateCommand request) @@ -532,9 +532,9 @@ namespace MediaBrowser.Api.Session } _sessionManager.ReportCapabilities(request.Id, new ClientCapabilities { - PlayableMediaTypes = (request.PlayableMediaTypes ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(), + PlayableMediaTypes = SplitValue(request.PlayableMediaTypes, ','), - SupportedCommands = (request.SupportedCommands ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(), + SupportedCommands = SplitValue(request.SupportedCommands, ','), SupportsMediaControl = request.SupportsMediaControl, diff --git a/MediaBrowser.Api/SimilarItemsHelper.cs b/MediaBrowser.Api/SimilarItemsHelper.cs index a4b14d2d4..48765e698 100644 --- a/MediaBrowser.Api/SimilarItemsHelper.cs +++ b/MediaBrowser.Api/SimilarItemsHelper.cs @@ -30,7 +30,7 @@ namespace MediaBrowser.Api public string ExcludeArtistIds { get; set; } } - public class BaseGetSimilarItems : IReturn, IHasDtoOptions + public class BaseGetSimilarItems : IReturn>, IHasDtoOptions { [ApiMember(Name = "EnableImages", Description = "Optional, include image information in output", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] public bool? EnableImages { get; set; } @@ -97,18 +97,18 @@ namespace MediaBrowser.Api var items = GetSimilaritems(item, libraryManager, inputItems, getSimilarityScore) .ToList(); - IEnumerable returnItems = items; + List returnItems = items; if (request.Limit.HasValue) { - returnItems = returnItems.Take(request.Limit.Value); + returnItems = returnItems.Take(request.Limit.Value).ToList(); } var dtos = await dtoService.GetBaseItemDtos(returnItems, dtoOptions, user).ConfigureAwait(false); return new QueryResult { - Items = dtos.ToArray(dtos.Count), + Items = dtos, TotalRecordCount = items.Count }; diff --git a/MediaBrowser.Api/Subtitles/SubtitleService.cs b/MediaBrowser.Api/Subtitles/SubtitleService.cs index 645aacdec..4d4b4cb27 100644 --- a/MediaBrowser.Api/Subtitles/SubtitleService.cs +++ b/MediaBrowser.Api/Subtitles/SubtitleService.cs @@ -14,8 +14,6 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; - -using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; using MediaBrowser.Model.Services; using MimeTypes = MediaBrowser.Model.Net.MimeTypes; @@ -39,7 +37,7 @@ namespace MediaBrowser.Api.Subtitles [Route("/Items/{Id}/RemoteSearch/Subtitles/{Language}", "GET")] [Authenticated] - public class SearchRemoteSubtitles : IReturn> + public class SearchRemoteSubtitles : IReturn { [ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] public string Id { get; set; } @@ -52,7 +50,7 @@ namespace MediaBrowser.Api.Subtitles [Route("/Items/{Id}/RemoteSearch/Subtitles/Providers", "GET")] [Authenticated] - public class GetSubtitleProviders : IReturn> + public class GetSubtitleProviders : IReturn { [ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] public string Id { get; set; } diff --git a/MediaBrowser.Api/SuggestionsService.cs b/MediaBrowser.Api/SuggestionsService.cs index 2456dd6c0..22432bf51 100644 --- a/MediaBrowser.Api/SuggestionsService.cs +++ b/MediaBrowser.Api/SuggestionsService.cs @@ -72,7 +72,7 @@ namespace MediaBrowser.Api return new QueryResult { TotalRecordCount = result.TotalRecordCount, - Items = dtoList.ToArray(dtoList.Count) + Items = dtoList }; } diff --git a/MediaBrowser.Api/System/SystemService.cs b/MediaBrowser.Api/System/SystemService.cs index cbff7cc2e..edb9f063d 100644 --- a/MediaBrowser.Api/System/SystemService.cs +++ b/MediaBrowser.Api/System/SystemService.cs @@ -60,7 +60,7 @@ namespace MediaBrowser.Api.System [Route("/System/Logs", "GET", Summary = "Gets a list of available server log files")] [Authenticated(Roles = "Admin")] - public class GetServerLogs : IReturn> + public class GetServerLogs : IReturn { } @@ -126,7 +126,7 @@ namespace MediaBrowser.Api.System } catch (IOException) { - files = new List(); + files = new FileSystemMetadata[]{}; } var result = files.Select(i => new LogFile @@ -139,7 +139,7 @@ namespace MediaBrowser.Api.System }).OrderByDescending(i => i.DateModified) .ThenByDescending(i => i.DateCreated) .ThenBy(i => i.Name) - .ToList(); + .ToArray(); return ToOptimizedResult(result); } diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.cs index 148e65b49..cd0c5d9e5 100644 --- a/MediaBrowser.Api/TvShowsService.cs +++ b/MediaBrowser.Api/TvShowsService.cs @@ -22,7 +22,7 @@ namespace MediaBrowser.Api /// Class GetNextUpEpisodes /// [Route("/Shows/NextUp", "GET", Summary = "Gets a list of next up episodes")] - public class GetNextUpEpisodes : IReturn, IHasDtoOptions + public class GetNextUpEpisodes : IReturn>, IHasDtoOptions { /// /// Gets or sets the user id. @@ -82,7 +82,7 @@ namespace MediaBrowser.Api } [Route("/Shows/Upcoming", "GET", Summary = "Gets a list of upcoming episodes")] - public class GetUpcomingEpisodes : IReturn, IHasDtoOptions + public class GetUpcomingEpisodes : IReturn>, IHasDtoOptions { /// /// Gets or sets the user id. @@ -138,7 +138,7 @@ namespace MediaBrowser.Api } [Route("/Shows/{Id}/Episodes", "GET", Summary = "Gets episodes for a tv season")] - public class GetEpisodes : IReturn, IHasItemFields, IHasDtoOptions + public class GetEpisodes : IReturn>, IHasItemFields, IHasDtoOptions { /// /// Gets or sets the user id. @@ -206,7 +206,7 @@ namespace MediaBrowser.Api } [Route("/Shows/{Id}/Seasons", "GET", Summary = "Gets seasons for a tv series")] - public class GetSeasons : IReturn, IHasItemFields, IHasDtoOptions + public class GetSeasons : IReturn>, IHasItemFields, IHasDtoOptions { /// /// Gets or sets the user id. @@ -327,7 +327,7 @@ namespace MediaBrowser.Api var result = new QueryResult { - Items = returnList.ToArray(returnList.Count), + Items = returnList, TotalRecordCount = itemsResult.Count }; @@ -359,10 +359,9 @@ namespace MediaBrowser.Api }); - var returnList = (await _dtoService.GetBaseItemDtos(itemsResult, options, user).ConfigureAwait(false)); - var returnItems = returnList.ToArray(returnList.Count); + var returnItems = (await _dtoService.GetBaseItemDtos(itemsResult, options, user).ConfigureAwait(false)); - var result = new ItemsResult + var result = new QueryResult { TotalRecordCount = itemsResult.Count, Items = returnItems @@ -392,10 +391,9 @@ namespace MediaBrowser.Api var user = _userManager.GetUserById(request.UserId); - var returnList = (await _dtoService.GetBaseItemDtos(result.Items, options, user).ConfigureAwait(false)); - var returnItems = returnList.ToArray(returnList.Count); + var returnItems = (await _dtoService.GetBaseItemDtos(result.Items, options, user).ConfigureAwait(false)); - return ToOptimizedSerializedResultUsingCache(new ItemsResult + return ToOptimizedSerializedResultUsingCache(new QueryResult { TotalRecordCount = result.TotalRecordCount, Items = returnItems @@ -443,14 +441,13 @@ namespace MediaBrowser.Api IsSpecialSeason = request.IsSpecialSeason, AdjacentTo = request.AdjacentTo - })).OfType(); + })); var dtoOptions = GetDtoOptions(_authContext, request); - var returnList = (await _dtoService.GetBaseItemDtos(seasons, dtoOptions, user).ConfigureAwait(false)); - var returnItems = returnList.ToArray(returnList.Count); + var returnItems = (await _dtoService.GetBaseItemDtos(seasons, dtoOptions, user).ConfigureAwait(false)); - return new ItemsResult + return new QueryResult { TotalRecordCount = returnItems.Length, Items = returnItems @@ -471,7 +468,7 @@ namespace MediaBrowser.Api { var user = _userManager.GetUserById(request.UserId); - IEnumerable episodes; + List episodes; var dtoOptions = GetDtoOptions(_authContext, request); @@ -499,11 +496,11 @@ namespace MediaBrowser.Api if (season == null) { - episodes = new List(); + episodes = new List(); } else { - episodes = season.GetEpisodes(user, dtoOptions); + episodes = ((Season)season).GetEpisodes(user, dtoOptions); } } else @@ -515,44 +512,44 @@ namespace MediaBrowser.Api throw new ResourceNotFoundException("Series not found"); } - episodes = series.GetEpisodes(user, dtoOptions); + episodes = series.GetEpisodes(user, dtoOptions).ToList(); } // Filter after the fact in case the ui doesn't want them if (request.IsMissing.HasValue) { var val = request.IsMissing.Value; - episodes = episodes.Where(i => i.IsMissingEpisode == val); + episodes = episodes.Where(i => ((Episode)i).IsMissingEpisode == val).ToList(); } if (!string.IsNullOrWhiteSpace(request.StartItemId)) { - episodes = episodes.SkipWhile(i => !string.Equals(i.Id.ToString("N"), request.StartItemId, StringComparison.OrdinalIgnoreCase)); + episodes = episodes.SkipWhile(i => !string.Equals(i.Id.ToString("N"), request.StartItemId, StringComparison.OrdinalIgnoreCase)).ToList(); } - IEnumerable returnItems = episodes; - // This must be the last filter if (!string.IsNullOrEmpty(request.AdjacentTo)) { - returnItems = UserViewBuilder.FilterForAdjacency(returnItems, request.AdjacentTo); + episodes = UserViewBuilder.FilterForAdjacency(episodes, request.AdjacentTo).ToList(); } if (string.Equals(request.SortBy, ItemSortBy.Random, StringComparison.OrdinalIgnoreCase)) { - returnItems = returnItems.OrderBy(i => Guid.NewGuid()); + episodes = episodes.OrderBy(i => Guid.NewGuid()).ToList(); } - var returnList = returnItems.ToList(); + var returnItems = episodes; - var pagedItems = ApplyPaging(returnList, request.StartIndex, request.Limit); - - var returnDtos = (await _dtoService.GetBaseItemDtos(pagedItems, dtoOptions, user).ConfigureAwait(false)); - var dtos = returnDtos.ToArray(returnDtos.Count); - - return new ItemsResult + if (request.StartIndex.HasValue || request.Limit.HasValue) { - TotalRecordCount = returnList.Count, + returnItems = ApplyPaging(episodes, request.StartIndex, request.Limit).ToList(); + } + + var dtos = (await _dtoService.GetBaseItemDtos(returnItems, dtoOptions, user).ConfigureAwait(false)); + + return new QueryResult + { + TotalRecordCount = episodes.Count, Items = dtos }; } diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs index 30e64d89d..1d0065c7c 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs @@ -88,7 +88,7 @@ namespace MediaBrowser.Api.UserLibrary return null; } - protected ItemsResult GetResultSlim(GetItemsByName request) + protected QueryResult GetResultSlim(GetItemsByName request) { var dtoOptions = GetDtoOptions(AuthorizationContext, request); @@ -209,7 +209,7 @@ namespace MediaBrowser.Api.UserLibrary return dto; }); - return new ItemsResult + return new QueryResult { Items = dtos.ToArray(result.Items.Length), TotalRecordCount = result.TotalRecordCount @@ -240,7 +240,7 @@ namespace MediaBrowser.Api.UserLibrary /// /// The request. /// Task{ItemsResult}. - protected ItemsResult GetResult(GetItemsByName request) + protected QueryResult GetResult(GetItemsByName request) { var dtoOptions = GetDtoOptions(AuthorizationContext, request); @@ -305,7 +305,7 @@ namespace MediaBrowser.Api.UserLibrary IEnumerable ibnItems = ibnItemsArray; - var result = new ItemsResult + var result = new QueryResult { TotalRecordCount = ibnItemsArray.Count }; @@ -357,13 +357,13 @@ namespace MediaBrowser.Api.UserLibrary items = items.Where(i => string.Compare(request.NameLessThan, i.SortName, StringComparison.CurrentCultureIgnoreCase) == 1); } - var imageTypes = request.GetImageTypes().ToList(); - if (imageTypes.Count > 0) + var imageTypes = request.GetImageTypes(); + if (imageTypes.Length > 0) { items = items.Where(item => imageTypes.Any(item.HasImage)); } - var filters = request.GetFilters().ToList(); + var filters = request.GetFilters(); if (filters.Contains(ItemFilter.Dislikes)) { @@ -506,7 +506,7 @@ namespace MediaBrowser.Api.UserLibrary /// /// Class GetItemsByName /// - public class GetItemsByName : BaseItemsRequest, IReturn + public class GetItemsByName : BaseItemsRequest, IReturn> { public GetItemsByName() { diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs index a9c5ae700..66aa35de9 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs @@ -435,7 +435,7 @@ namespace MediaBrowser.Api.UserLibrary /// Gets the filters. /// /// IEnumerable{ItemFilter}. - public IEnumerable GetFilters() + public ItemFilter[] GetFilters() { var val = Filters; @@ -444,7 +444,7 @@ namespace MediaBrowser.Api.UserLibrary return new ItemFilter[] { }; } - return val.Split(',').Select(v => (ItemFilter)Enum.Parse(typeof(ItemFilter), v, true)); + return val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(v => (ItemFilter)Enum.Parse(typeof(ItemFilter), v, true)).ToArray(); } /// diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index f3d7772fc..9dd5aa565 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -10,6 +10,7 @@ using System.Globalization; using System.Linq; using System.Threading.Tasks; using MediaBrowser.Controller.Entities.Audio; +using MediaBrowser.Model.Dto; using MediaBrowser.Model.Globalization; using MediaBrowser.Model.Services; using MediaBrowser.Model.Extensions; @@ -21,7 +22,7 @@ namespace MediaBrowser.Api.UserLibrary /// [Route("/Items", "GET", Summary = "Gets items based on a query.")] [Route("/Users/{UserId}/Items", "GET", Summary = "Gets items based on a query.")] - public class GetItems : BaseItemsRequest, IReturn + public class GetItems : BaseItemsRequest, IReturn> { } @@ -100,7 +101,7 @@ namespace MediaBrowser.Api.UserLibrary /// /// The request. /// Task{ItemsResult}. - private async Task GetItems(GetItems request) + private async Task> GetItems(GetItems request) { var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null; @@ -125,10 +126,10 @@ namespace MediaBrowser.Api.UserLibrary throw new InvalidOperationException("GetBaseItemDtos returned null"); } - return new ItemsResult + return new QueryResult { TotalRecordCount = result.TotalRecordCount, - Items = dtoList.ToArray(dtoList.Count) + Items = dtoList }; } @@ -180,9 +181,7 @@ namespace MediaBrowser.Api.UserLibrary return folder.GetItems(GetItemsQuery(request, dtoOptions, user)); } - IEnumerable items = folder.GetChildren(user, true); - - var itemsArray = items.ToArray(); + var itemsArray = folder.GetChildren(user, true).ToArray(); return new QueryResult { @@ -332,13 +331,11 @@ namespace MediaBrowser.Api.UserLibrary if (!string.IsNullOrEmpty(request.LocationTypes)) { var requestedLocationTypes = - request.LocationTypes.Split(',') - .Select(d => (LocationType)Enum.Parse(typeof(LocationType), d, true)) - .ToList(); + request.LocationTypes.Split(','); - if (requestedLocationTypes.Count > 0 && requestedLocationTypes.Count < 4) + if (requestedLocationTypes.Length > 0 && requestedLocationTypes.Length < 4) { - query.IsVirtualItem = requestedLocationTypes.Contains(LocationType.Virtual); + query.IsVirtualItem = requestedLocationTypes.Contains(LocationType.Virtual.ToString()); } } diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs index ee1162687..87a06e4d5 100644 --- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs +++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs @@ -59,7 +59,7 @@ namespace MediaBrowser.Api.UserLibrary /// Class GetIntros /// [Route("/Users/{UserId}/Items/{Id}/Intros", "GET", Summary = "Gets intros to play before the main media item plays")] - public class GetIntros : IReturn + public class GetIntros : IReturn> { /// /// Gets or sets the user id. @@ -171,7 +171,7 @@ namespace MediaBrowser.Api.UserLibrary /// Class GetLocalTrailers /// [Route("/Users/{UserId}/Items/{Id}/LocalTrailers", "GET", Summary = "Gets local trailers for an item")] - public class GetLocalTrailers : IReturn> + public class GetLocalTrailers : IReturn { /// /// Gets or sets the user id. @@ -192,7 +192,7 @@ namespace MediaBrowser.Api.UserLibrary /// Class GetSpecialFeatures /// [Route("/Users/{UserId}/Items/{Id}/SpecialFeatures", "GET", Summary = "Gets special features for an item")] - public class GetSpecialFeatures : IReturn> + public class GetSpecialFeatures : IReturn { /// /// Gets or sets the user id. @@ -210,7 +210,7 @@ namespace MediaBrowser.Api.UserLibrary } [Route("/Users/{UserId}/Items/Latest", "GET", Summary = "Gets latest media")] - public class GetLatestMedia : IReturn>, IHasDtoOptions + public class GetLatestMedia : IReturn, IHasDtoOptions { /// /// Gets or sets the user id. @@ -338,10 +338,10 @@ namespace MediaBrowser.Api.UserLibrary return dto; }); - return ToOptimizedResult(dtos.ToList()); + return ToOptimizedResult(dtos.ToArray()); } - private List GetAsync(GetSpecialFeatures request) + private BaseItemDto[] GetAsync(GetSpecialFeatures request) { var user = _userManager.GetUserById(request.UserId); @@ -364,7 +364,7 @@ namespace MediaBrowser.Api.UserLibrary .Where(i => i.ParentIndexNumber.HasValue && i.ParentIndexNumber.Value == 0) .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, currentUser)); - return dtos.ToList(); + return dtos.ToArray(); } var movie = item as IHasSpecialFeatures; @@ -379,10 +379,10 @@ namespace MediaBrowser.Api.UserLibrary .OrderBy(i => i.SortName) .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item)); - return dtos.ToList(); + return dtos.ToArray(); } - return new List(); + return new BaseItemDto[] { }; } /// @@ -396,19 +396,24 @@ namespace MediaBrowser.Api.UserLibrary var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : _libraryManager.GetItemById(request.Id); - var trailerIds = new List(); + List trailerIds = null; var hasTrailers = item as IHasTrailers; if (hasTrailers != null) { trailerIds = hasTrailers.GetTrailerIds(); } + else + { + trailerIds = new List(); + } var dtoOptions = GetDtoOptions(_authContext, request); var dtos = trailerIds .Select(_libraryManager.GetItemById) - .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item)); + .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item)) + .ToArray(); return ToOptimizedSerializedResultUsingCache(dtos); } @@ -489,7 +494,7 @@ namespace MediaBrowser.Api.UserLibrary var dtos = items.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user)).ToArray(); - var result = new ItemsResult + var result = new QueryResult { Items = dtos, TotalRecordCount = dtos.Length diff --git a/MediaBrowser.Api/UserLibrary/UserViewsService.cs b/MediaBrowser.Api/UserLibrary/UserViewsService.cs index 3ed5166a4..096157e47 100644 --- a/MediaBrowser.Api/UserLibrary/UserViewsService.cs +++ b/MediaBrowser.Api/UserLibrary/UserViewsService.cs @@ -12,6 +12,7 @@ using System.Threading; using System.Threading.Tasks; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Services; +using MediaBrowser.Model.Extensions; namespace MediaBrowser.Api.UserLibrary { @@ -32,7 +33,7 @@ namespace MediaBrowser.Api.UserLibrary } [Route("/Users/{UserId}/GroupingOptions", "GET")] - public class GetGroupingOptions : IReturn> + public class GetGroupingOptions : IReturn { /// /// Gets or sets the user id. @@ -84,10 +85,13 @@ namespace MediaBrowser.Api.UserLibrary var folders = await _userViewManager.GetUserViews(query, CancellationToken.None).ConfigureAwait(false); var dtoOptions = GetDtoOptions(_authContext, request); - dtoOptions.Fields.Add(ItemFields.PrimaryImageAspectRatio); - dtoOptions.Fields.Add(ItemFields.DisplayPreferencesId); - dtoOptions.Fields.Remove(ItemFields.SyncInfo); - dtoOptions.Fields.Remove(ItemFields.BasicSyncInfo); + var fields = dtoOptions.Fields.ToList(); + + fields.Add(ItemFields.PrimaryImageAspectRatio); + fields.Add(ItemFields.DisplayPreferencesId); + fields.Remove(ItemFields.SyncInfo); + fields.Remove(ItemFields.BasicSyncInfo); + dtoOptions.Fields = fields.ToArray(fields.Count); var user = _userManager.GetUserById(request.UserId); @@ -107,13 +111,10 @@ namespace MediaBrowser.Api.UserLibrary { var user = _userManager.GetUserById(request.UserId); - var views = user.RootFolder + var list = user.RootFolder .GetChildren(user, true) .OfType() .Where(UserView.IsEligibleForGrouping) - .ToList(); - - var list = views .Select(i => new SpecialViewOption { Name = i.Name, @@ -121,7 +122,7 @@ namespace MediaBrowser.Api.UserLibrary }) .OrderBy(i => i.Name) - .ToList(); + .ToArray(); return ToOptimizedResult(list); } diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs index 49b7f6c15..acdbf96f4 100644 --- a/MediaBrowser.Api/UserService.cs +++ b/MediaBrowser.Api/UserService.cs @@ -22,7 +22,7 @@ namespace MediaBrowser.Api /// [Route("/Users", "GET", Summary = "Gets a list of users")] [Authenticated] - public class GetUsers : IReturn> + public class GetUsers : IReturn { [ApiMember(Name = "IsHidden", Description = "Optional filter by IsHidden=true or false", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] public bool? IsHidden { get; set; } @@ -35,7 +35,7 @@ namespace MediaBrowser.Api } [Route("/Users/Public", "GET", Summary = "Gets a list of publicly visible users for display on a login screen.")] - public class GetPublicUsers : IReturn> + public class GetPublicUsers : IReturn { } @@ -329,7 +329,7 @@ namespace MediaBrowser.Api var result = users .OrderBy(u => u.Name) .Select(i => _userManager.GetUserDto(i, Request.RemoteIp)) - .ToList(); + .ToArray(); return ToOptimizedResult(result); } diff --git a/MediaBrowser.Api/VideosService.cs b/MediaBrowser.Api/VideosService.cs index 57d3d7e39..dc7d09863 100644 --- a/MediaBrowser.Api/VideosService.cs +++ b/MediaBrowser.Api/VideosService.cs @@ -19,7 +19,7 @@ namespace MediaBrowser.Api { [Route("/Videos/{Id}/AdditionalParts", "GET", Summary = "Gets additional parts for a video.")] [Authenticated] - public class GetAdditionalParts : IReturn + public class GetAdditionalParts : IReturn> { [ApiMember(Name = "UserId", Description = "Optional. Filter by user id, and attach user data", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public string UserId { get; set; } @@ -99,7 +99,7 @@ namespace MediaBrowser.Api items = new BaseItemDto[] { }; } - var result = new ItemsResult + var result = new QueryResult { Items = items, TotalRecordCount = items.Length diff --git a/MediaBrowser.Common/Updates/IInstallationManager.cs b/MediaBrowser.Common/Updates/IInstallationManager.cs index 636526567..ecc272605 100644 --- a/MediaBrowser.Common/Updates/IInstallationManager.cs +++ b/MediaBrowser.Common/Updates/IInstallationManager.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.Common.Updates /// Type of the package. /// The application version. /// Task{List{PackageInfo}}. - Task> GetAvailablePackages(CancellationToken cancellationToken, + Task GetAvailablePackages(CancellationToken cancellationToken, bool withRegistration = true, string packageType = null, Version applicationVersion = null); @@ -58,7 +58,7 @@ namespace MediaBrowser.Common.Updates /// /// The cancellation token. /// Task{List{PackageInfo}}. - Task> GetAvailablePackagesWithoutRegistrationInfo(CancellationToken cancellationToken); + Task GetAvailablePackagesWithoutRegistrationInfo(CancellationToken cancellationToken); /// /// Gets the package. diff --git a/MediaBrowser.Controller/Channels/IChannelManager.cs b/MediaBrowser.Controller/Channels/IChannelManager.cs index 824bdf8ff..46e55a21c 100644 --- a/MediaBrowser.Controller/Channels/IChannelManager.cs +++ b/MediaBrowser.Controller/Channels/IChannelManager.cs @@ -30,7 +30,7 @@ namespace MediaBrowser.Controller.Channels /// Gets all channel features. /// /// IEnumerable{ChannelFeatures}. - IEnumerable GetAllChannelFeatures(); + ChannelFeatures[] GetAllChannelFeatures(); /// /// Gets the channel. diff --git a/MediaBrowser.Controller/Channels/InternalChannelFeatures.cs b/MediaBrowser.Controller/Channels/InternalChannelFeatures.cs index 7d80d7e12..976808aad 100644 --- a/MediaBrowser.Controller/Channels/InternalChannelFeatures.cs +++ b/MediaBrowser.Controller/Channels/InternalChannelFeatures.cs @@ -58,13 +58,4 @@ namespace MediaBrowser.Controller.Channels DefaultSortFields = new List(); } } - - public class ChannelDownloadException : Exception - { - public ChannelDownloadException(string message) - : base(message) - { - - } - } } diff --git a/MediaBrowser.Controller/Collections/CollectionCreationOptions.cs b/MediaBrowser.Controller/Collections/CollectionCreationOptions.cs index 4a2d39066..7a387e319 100644 --- a/MediaBrowser.Controller/Collections/CollectionCreationOptions.cs +++ b/MediaBrowser.Controller/Collections/CollectionCreationOptions.cs @@ -14,14 +14,14 @@ namespace MediaBrowser.Controller.Collections public Dictionary ProviderIds { get; set; } - public List ItemIdList { get; set; } - public List UserIds { get; set; } + public string[] ItemIdList { get; set; } + public string[] UserIds { get; set; } public CollectionCreationOptions() { ProviderIds = new Dictionary(StringComparer.OrdinalIgnoreCase); - ItemIdList = new List(); - UserIds = new List(); + ItemIdList = new string[] { }; + UserIds = new string[] { }; } } } diff --git a/MediaBrowser.Controller/Collections/ICollectionManager.cs b/MediaBrowser.Controller/Collections/ICollectionManager.cs index 89e505579..0ca7b2e3e 100644 --- a/MediaBrowser.Controller/Collections/ICollectionManager.cs +++ b/MediaBrowser.Controller/Collections/ICollectionManager.cs @@ -36,7 +36,7 @@ namespace MediaBrowser.Controller.Collections /// The collection identifier. /// The item ids. /// Task. - Task AddToCollection(Guid collectionId, IEnumerable itemIds); + Task AddToCollection(Guid collectionId, string[] itemIds); /// /// Removes from collection. @@ -44,7 +44,7 @@ namespace MediaBrowser.Controller.Collections /// The collection identifier. /// The item ids. /// Task. - Task RemoveFromCollection(Guid collectionId, IEnumerable itemIds); + Task RemoveFromCollection(Guid collectionId, string[] itemIds); /// /// Collapses the items within box sets. diff --git a/MediaBrowser.Controller/Dto/DtoOptions.cs b/MediaBrowser.Controller/Dto/DtoOptions.cs index 098ba558f..f05ae4e71 100644 --- a/MediaBrowser.Controller/Dto/DtoOptions.cs +++ b/MediaBrowser.Controller/Dto/DtoOptions.cs @@ -14,8 +14,8 @@ namespace MediaBrowser.Controller.Dto ItemFields.RefreshState }; - public List Fields { get; set; } - public List ImageTypes { get; set; } + public ItemFields[] Fields { get; set; } + public ImageType[] ImageTypes { get; set; } public int ImageTypeLimit { get; set; } public bool EnableImages { get; set; } public bool AddProgramRecordingInfo { get; set; } @@ -28,6 +28,15 @@ namespace MediaBrowser.Controller.Dto { } + private static readonly ImageType[] AllImageTypes = Enum.GetNames(typeof(ImageType)) + .Select(i => (ImageType)Enum.Parse(typeof(ImageType), i, true)) + .ToArray(); + + private static readonly ItemFields[] AllItemFields = Enum.GetNames(typeof(ItemFields)) + .Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)) + .Except(DefaultExcludedFields) + .ToArray(); + public DtoOptions(bool allFields) { ImageTypeLimit = int.MaxValue; @@ -37,19 +46,14 @@ namespace MediaBrowser.Controller.Dto if (allFields) { - Fields = Enum.GetNames(typeof(ItemFields)) - .Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)) - .Except(DefaultExcludedFields) - .ToList(); + Fields = AllItemFields; } else { - Fields = new List(); + Fields = new ItemFields[] { }; } - ImageTypes = Enum.GetNames(typeof(ImageType)) - .Select(i => (ImageType)Enum.Parse(typeof(ImageType), i, true)) - .ToList(); + ImageTypes = AllImageTypes; } public int GetImageLimit(ImageType type) diff --git a/MediaBrowser.Controller/Dto/IDtoService.cs b/MediaBrowser.Controller/Dto/IDtoService.cs index 963092f52..76ecd8180 100644 --- a/MediaBrowser.Controller/Dto/IDtoService.cs +++ b/MediaBrowser.Controller/Dto/IDtoService.cs @@ -41,7 +41,7 @@ namespace MediaBrowser.Controller.Dto /// The user. /// The owner. /// Task{BaseItemDto}. - BaseItemDto GetBaseItemDto(BaseItem item, List fields, User user = null, BaseItem owner = null); + BaseItemDto GetBaseItemDto(BaseItem item, ItemFields[] fields, User user = null, BaseItem owner = null); /// /// Gets the base item dto. @@ -61,9 +61,10 @@ namespace MediaBrowser.Controller.Dto /// The user. /// The owner. /// IEnumerable<BaseItemDto>. - Task> GetBaseItemDtos(IEnumerable items, DtoOptions options, User user = null, - BaseItem owner = null); - + Task GetBaseItemDtos(BaseItem[] items, DtoOptions options, User user = null, BaseItem owner = null); + + Task GetBaseItemDtos(List items, DtoOptions options, User user = null, BaseItem owner = null); + /// /// Gets the chapter information dto. /// diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index a6418418e..c158378a6 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -2265,7 +2265,7 @@ namespace MediaBrowser.Controller.Entities return path; } - public virtual void FillUserDataDtoValues(UserItemDataDto dto, UserItemData userData, BaseItemDto itemDto, User user, List fields) + public virtual void FillUserDataDtoValues(UserItemDataDto dto, UserItemData userData, BaseItemDto itemDto, User user, ItemFields[] fields) { if (RunTimeTicks.HasValue) { diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 46ae9230b..b08834784 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -711,7 +711,7 @@ namespace MediaBrowser.Controller.Entities { if (!(this is ICollectionFolder)) { - return GetChildren(user, true).Count(); + return GetChildren(user, true).Count; } } @@ -792,16 +792,16 @@ namespace MediaBrowser.Controller.Entities query.StartIndex = null; query.Limit = null; - IEnumerable itemsList = LibraryManager.GetItemList(query); + var itemsList = LibraryManager.GetItemList(query); var user = query.User; if (user != null) { // needed for boxsets - itemsList = itemsList.Where(i => i.IsVisibleStandalone(query.User)); + itemsList = itemsList.Where(i => i.IsVisibleStandalone(query.User)).ToList(); } - IEnumerable returnItems; + BaseItem[] returnItems; int totalCount = 0; if (query.EnableTotalRecordCount) @@ -812,16 +812,16 @@ namespace MediaBrowser.Controller.Entities } else { - returnItems = itemsList; + returnItems = itemsList.ToArray(); } if (limit.HasValue) { - returnItems = returnItems.Skip(startIndex ?? 0).Take(limit.Value); + returnItems = returnItems.Skip(startIndex ?? 0).Take(limit.Value).ToArray(); } else if (startIndex.HasValue) { - returnItems = returnItems.Skip(startIndex.Value); + returnItems = returnItems.Skip(startIndex.Value).ToArray(); } return new QueryResult @@ -1044,7 +1044,7 @@ namespace MediaBrowser.Controller.Entities return UserViewBuilder.PostFilterAndSort(items, this, null, query, LibraryManager, ConfigurationManager, collapseBoxSetItems, enableSorting); } - public virtual IEnumerable GetChildren(User user, bool includeLinkedChildren) + public virtual List GetChildren(User user, bool includeLinkedChildren) { if (user == null) { @@ -1058,7 +1058,7 @@ namespace MediaBrowser.Controller.Entities AddChildren(user, includeLinkedChildren, result, false, null); - return result.Values; + return result.Values.ToList(); } protected virtual IEnumerable GetEligibleChildrenForRecursiveChildren(User user) @@ -1477,7 +1477,7 @@ namespace MediaBrowser.Controller.Entities } } - public override void FillUserDataDtoValues(UserItemDataDto dto, UserItemData userData, BaseItemDto itemDto, User user, List fields) + public override void FillUserDataDtoValues(UserItemDataDto dto, UserItemData userData, BaseItemDto itemDto, User user, ItemFields[] fields) { if (!SupportsUserDataFromChildren) { diff --git a/MediaBrowser.Controller/Entities/IHasUserData.cs b/MediaBrowser.Controller/Entities/IHasUserData.cs index ce4a482ba..ab4f624e2 100644 --- a/MediaBrowser.Controller/Entities/IHasUserData.cs +++ b/MediaBrowser.Controller/Entities/IHasUserData.cs @@ -16,7 +16,7 @@ namespace MediaBrowser.Controller.Entities /// /// Fills the user data dto values. /// - void FillUserDataDtoValues(UserItemDataDto dto, UserItemData userData, BaseItemDto itemDto, User user, List fields); + void FillUserDataDtoValues(UserItemDataDto dto, UserItemData userData, BaseItemDto itemDto, User user, ItemFields[] fields); bool EnableRememberingTrackSelections { get; } diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index 6ba9577d1..376f65d60 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -170,24 +170,24 @@ namespace MediaBrowser.Controller.Entities.Movies StringComparison.OrdinalIgnoreCase); } - public override IEnumerable GetChildren(User user, bool includeLinkedChildren) + public override List GetChildren(User user, bool includeLinkedChildren) { var children = base.GetChildren(user, includeLinkedChildren); if (string.Equals(DisplayOrder, ItemSortBy.SortName, StringComparison.OrdinalIgnoreCase)) { // Sort by name - return LibraryManager.Sort(children, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending); + return LibraryManager.Sort(children, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending).ToList(); } if (string.Equals(DisplayOrder, ItemSortBy.PremiereDate, StringComparison.OrdinalIgnoreCase)) { // Sort by release date - return LibraryManager.Sort(children, user, new[] { ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName }, SortOrder.Ascending); + return LibraryManager.Sort(children, user, new[] { ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName }, SortOrder.Ascending).ToList(); } // Default sorting - return LibraryManager.Sort(children, user, new[] { ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName }, SortOrder.Ascending); + return LibraryManager.Sort(children, user, new[] { ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName }, SortOrder.Ascending).ToList(); } public BoxSetInfo GetLookupInfo() diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index b681fdcb1..8b934bc47 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -160,27 +160,27 @@ namespace MediaBrowser.Controller.Entities.TV /// /// Gets the episodes. /// - public IEnumerable GetEpisodes(User user, DtoOptions options) + public List GetEpisodes(User user, DtoOptions options) { return GetEpisodes(Series, user, options); } - public IEnumerable GetEpisodes(Series series, User user, DtoOptions options) + public List GetEpisodes(Series series, User user, DtoOptions options) { return GetEpisodes(series, user, null, options); } - public IEnumerable GetEpisodes(Series series, User user, IEnumerable allSeriesEpisodes, DtoOptions options) + public List GetEpisodes(Series series, User user, IEnumerable allSeriesEpisodes, DtoOptions options) { return series.GetSeasonEpisodes(this, user, allSeriesEpisodes, options); } - public IEnumerable GetEpisodes() + public List GetEpisodes() { return Series.GetSeasonEpisodes(this, null, null, new DtoOptions(true)); } - public override IEnumerable GetChildren(User user, bool includeLinkedChildren) + public override List GetChildren(User user, bool includeLinkedChildren) { return GetEpisodes(user, new DtoOptions(true)); } diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index 3350a6579..545e8518a 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -152,12 +152,8 @@ namespace MediaBrowser.Controller.Entities.TV IncludeItemTypes = new[] { typeof(Season).Name }, IsVirtualItem = false, Limit = 0, - DtoOptions = new Dto.DtoOptions + DtoOptions = new Dto.DtoOptions(false) { - Fields = new List - { - - }, EnableImages = false } }); @@ -173,12 +169,8 @@ namespace MediaBrowser.Controller.Entities.TV { AncestorWithPresentationUniqueKey = null, SeriesPresentationUniqueKey = seriesKey, - DtoOptions = new Dto.DtoOptions + DtoOptions = new Dto.DtoOptions(false) { - Fields = new List - { - - }, EnableImages = false } }; @@ -226,12 +218,12 @@ namespace MediaBrowser.Controller.Entities.TV } } - public override IEnumerable GetChildren(User user, bool includeLinkedChildren) + public override List GetChildren(User user, bool includeLinkedChildren) { return GetSeasons(user, new DtoOptions(true)); } - public IEnumerable GetSeasons(User user, DtoOptions options) + public List GetSeasons(User user, DtoOptions options) { var query = new InternalItemsQuery(user) { @@ -240,7 +232,7 @@ namespace MediaBrowser.Controller.Entities.TV SetSeasonQueryOptions(query, user); - return LibraryManager.GetItemList(query).Cast(); + return LibraryManager.GetItemList(query); } private void SetSeasonQueryOptions(InternalItemsQuery query, User user) @@ -292,7 +284,7 @@ namespace MediaBrowser.Controller.Entities.TV return LibraryManager.GetItemsResult(query); } - public IEnumerable GetEpisodes(User user, DtoOptions options) + public IEnumerable GetEpisodes(User user, DtoOptions options) { var seriesKey = GetUniqueSeriesKey(this); @@ -312,7 +304,7 @@ namespace MediaBrowser.Controller.Entities.TV var allItems = LibraryManager.GetItemList(query); - var allSeriesEpisodes = allItems.OfType(); + var allSeriesEpisodes = allItems.OfType().ToList(); var allEpisodes = allItems.OfType() .SelectMany(i => i.GetEpisodes(this, user, allSeriesEpisodes, options)) @@ -396,7 +388,7 @@ namespace MediaBrowser.Controller.Entities.TV await ProviderManager.RefreshSingleItem(this, refreshOptions, cancellationToken).ConfigureAwait(false); } - public IEnumerable GetSeasonEpisodes(Season parentSeason, User user, DtoOptions options) + public List GetSeasonEpisodes(Season parentSeason, User user, DtoOptions options) { var queryFromSeries = ConfigurationManager.Configuration.DisplaySpecialsWithinSeasons; @@ -422,12 +414,12 @@ namespace MediaBrowser.Controller.Entities.TV } } - var allItems = LibraryManager.GetItemList(query).OfType(); + var allItems = LibraryManager.GetItemList(query); return GetSeasonEpisodes(parentSeason, user, allItems, options); } - public IEnumerable GetSeasonEpisodes(Season parentSeason, User user, IEnumerable allSeriesEpisodes, DtoOptions options) + public List GetSeasonEpisodes(Season parentSeason, User user, IEnumerable allSeriesEpisodes, DtoOptions options) { if (allSeriesEpisodes == null) { @@ -438,14 +430,13 @@ namespace MediaBrowser.Controller.Entities.TV var sortBy = (parentSeason.IndexNumber ?? -1) == 0 ? ItemSortBy.SortName : ItemSortBy.AiredEpisodeOrder; - return LibraryManager.Sort(episodes, user, new[] { sortBy }, SortOrder.Ascending) - .Cast(); + return LibraryManager.Sort(episodes, user, new[] { sortBy }, SortOrder.Ascending).ToList(); } /// /// Filters the episodes by season. /// - public static IEnumerable FilterEpisodesBySeason(IEnumerable episodes, Season parentSeason, bool includeSpecials) + public static IEnumerable FilterEpisodesBySeason(IEnumerable episodes, Season parentSeason, bool includeSpecials) { var seasonNumber = parentSeason.IndexNumber; var seasonPresentationKey = GetUniqueSeriesKey(parentSeason); @@ -454,7 +445,9 @@ namespace MediaBrowser.Controller.Entities.TV return episodes.Where(episode => { - var currentSeasonNumber = supportSpecialsInSeason ? episode.AiredSeasonNumber : episode.ParentIndexNumber; + var episodeItem = (Episode) episode; + + var currentSeasonNumber = supportSpecialsInSeason ? episodeItem.AiredSeasonNumber : episode.ParentIndexNumber; if (currentSeasonNumber.HasValue && seasonNumber.HasValue && currentSeasonNumber.Value == seasonNumber.Value) { return true; @@ -465,7 +458,7 @@ namespace MediaBrowser.Controller.Entities.TV return true; } - var season = episode.Season; + var season = episodeItem.Season; return season != null && string.Equals(GetUniqueSeriesKey(season), seasonPresentationKey, StringComparison.OrdinalIgnoreCase); }); } diff --git a/MediaBrowser.Controller/Entities/UserRootFolder.cs b/MediaBrowser.Controller/Entities/UserRootFolder.cs index d35156345..dd70277a7 100644 --- a/MediaBrowser.Controller/Entities/UserRootFolder.cs +++ b/MediaBrowser.Controller/Entities/UserRootFolder.cs @@ -81,7 +81,7 @@ namespace MediaBrowser.Controller.Entities public override int GetChildCount(User user) { - return GetChildren(user, true).Count(); + return GetChildren(user, true).Count; } [IgnoreDataMember] diff --git a/MediaBrowser.Controller/Entities/UserView.cs b/MediaBrowser.Controller/Entities/UserView.cs index 4c44a613b..7ab4e98fc 100644 --- a/MediaBrowser.Controller/Entities/UserView.cs +++ b/MediaBrowser.Controller/Entities/UserView.cs @@ -80,7 +80,7 @@ namespace MediaBrowser.Controller.Entities .GetUserItems(parent, this, ViewType, query).Result; } - public override IEnumerable GetChildren(User user, bool includeLinkedChildren) + public override List GetChildren(User user, bool includeLinkedChildren) { var result = GetItemList(new InternalItemsQuery { @@ -90,7 +90,7 @@ namespace MediaBrowser.Controller.Entities }); - return result; + return result.ToList(); } public override bool CanDelete() diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index 9323404e3..acfa239d3 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -533,7 +533,7 @@ namespace MediaBrowser.Controller.Entities return ConvertToResult(_libraryManager.GetItemList(query)); } - private QueryResult ConvertToResult(IEnumerable items) + private QueryResult ConvertToResult(List items) { var arr = items.ToArray(); return new QueryResult @@ -789,7 +789,7 @@ namespace MediaBrowser.Controller.Entities // This must be the last filter if (!string.IsNullOrEmpty(query.AdjacentTo)) { - items = FilterForAdjacency(items, query.AdjacentTo); + items = FilterForAdjacency(items.ToList(), query.AdjacentTo); } return SortAndPage(items, totalRecordLimit, query, libraryManager, enableSorting); @@ -1763,10 +1763,8 @@ namespace MediaBrowser.Controller.Entities return _userViewManager.GetUserSubView(parent.Id.ToString("N"), type, sortName, CancellationToken.None); } - public static IEnumerable FilterForAdjacency(IEnumerable items, string adjacentToId) + public static IEnumerable FilterForAdjacency(List list, string adjacentToId) { - var list = items.ToList(); - var adjacentToIdGuid = new Guid(adjacentToId); var adjacentToItem = list.FirstOrDefault(i => i.Id == adjacentToIdGuid); diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 3b166db92..fa11787f5 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -153,14 +153,14 @@ namespace MediaBrowser.Controller.Entities /// Gets the playable stream files. /// /// List{System.String}. - public List GetPlayableStreamFiles() + public string[] GetPlayableStreamFiles() { return GetPlayableStreamFiles(Path); } - public List GetPlayableStreamFileNames() + public string[] GetPlayableStreamFileNames() { - return GetPlayableStreamFiles().Select(System.IO.Path.GetFileName).ToList(); ; + return GetPlayableStreamFiles().Select(System.IO.Path.GetFileName).ToArray(); } /// @@ -389,11 +389,11 @@ namespace MediaBrowser.Controller.Entities /// /// The root path. /// List{System.String}. - public List GetPlayableStreamFiles(string rootPath) + public string[] GetPlayableStreamFiles(string rootPath) { if (VideoType == VideoType.VideoFile) { - return new List(); + return new string[] { }; } var allFiles = FileSystem.GetFilePaths(rootPath, true).ToList(); @@ -411,10 +411,10 @@ namespace MediaBrowser.Controller.Entities return QueryPlayableStreamFiles(rootPath, videoType).Select(name => allFiles.FirstOrDefault(f => string.Equals(System.IO.Path.GetFileName(f), name, StringComparison.OrdinalIgnoreCase))) .Where(f => !string.IsNullOrEmpty(f)) - .ToList(); + .ToArray(); } - public static List QueryPlayableStreamFiles(string rootPath, VideoType videoType) + public static string[] QueryPlayableStreamFiles(string rootPath, VideoType videoType) { if (videoType == VideoType.Dvd) { @@ -423,7 +423,7 @@ namespace MediaBrowser.Controller.Entities .ThenBy(i => i.FullName) .Take(1) .Select(i => i.FullName) - .ToList(); + .ToArray(); } if (videoType == VideoType.BluRay) { @@ -432,9 +432,9 @@ namespace MediaBrowser.Controller.Entities .ThenBy(i => i.FullName) .Take(1) .Select(i => i.FullName) - .ToList(); + .ToArray(); } - return new List(); + return new string[] { }; } /// diff --git a/MediaBrowser.Controller/Library/IUserDataManager.cs b/MediaBrowser.Controller/Library/IUserDataManager.cs index e9954545e..b364ab990 100644 --- a/MediaBrowser.Controller/Library/IUserDataManager.cs +++ b/MediaBrowser.Controller/Library/IUserDataManager.cs @@ -40,7 +40,7 @@ namespace MediaBrowser.Controller.Library /// UserItemDataDto GetUserDataDto(IHasUserData item, User user); - UserItemDataDto GetUserDataDto(IHasUserData item, BaseItemDto itemDto, User user, List fields); + UserItemDataDto GetUserDataDto(IHasUserData item, BaseItemDto itemDto, User user, ItemFields[] fields); /// /// Get all user data for the given user diff --git a/MediaBrowser.Controller/Library/IUserViewManager.cs b/MediaBrowser.Controller/Library/IUserViewManager.cs index b46ece49d..76182c641 100644 --- a/MediaBrowser.Controller/Library/IUserViewManager.cs +++ b/MediaBrowser.Controller/Library/IUserViewManager.cs @@ -11,7 +11,7 @@ namespace MediaBrowser.Controller.Library { public interface IUserViewManager { - Task> GetUserViews(UserViewQuery query, CancellationToken cancellationToken); + Task GetUserViews(UserViewQuery query, CancellationToken cancellationToken); Task GetUserSubView(string name, string parentId, string type, string sortName, CancellationToken cancellationToken); diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index d6855b792..862894f61 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -243,7 +243,7 @@ namespace MediaBrowser.Controller.LiveTv /// Gets the recommended programs internal. /// /// Task<QueryResult<LiveTvProgram>>. - Task> GetRecommendedProgramsInternal(RecommendedProgramQuery query, DtoOptions options, CancellationToken cancellationToken); + Task> GetRecommendedProgramsInternal(RecommendedProgramQuery query, DtoOptions options, CancellationToken cancellationToken); /// /// Gets the live tv information. @@ -316,7 +316,7 @@ namespace MediaBrowser.Controller.LiveTv /// The fields. /// The user. /// Task. - Task AddInfoToProgramDto(List> programs, List fields, User user = null); + Task AddInfoToProgramDto(List> programs, ItemFields[] fields, User user = null); /// /// Saves the tuner host. @@ -335,7 +335,7 @@ namespace MediaBrowser.Controller.LiveTv Task SetChannelMapping(string providerId, string tunerChannelNumber, string providerChannelNumber); - TunerChannelMapping GetTunerChannelMapping(ChannelInfo channel, List mappings, List providerChannels); + TunerChannelMapping GetTunerChannelMapping(ChannelInfo channel, NameValuePair[] mappings, List providerChannels); /// /// Gets the lineups. diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 823c893ea..8b4179adc 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -1521,7 +1521,7 @@ namespace MediaBrowser.Controller.MediaEncoding { var inputModifier = string.Empty; - var numInputFiles = state.PlayableStreamFileNames.Count > 0 ? state.PlayableStreamFileNames.Count : 1; + var numInputFiles = state.PlayableStreamFileNames.Length > 0 ? state.PlayableStreamFileNames.Length : 1; var probeSizeArgument = GetProbeSizeArgument(numInputFiles); string analyzeDurationArgument; @@ -1676,12 +1676,12 @@ namespace MediaBrowser.Controller.MediaEncoding } else { - state.PlayableStreamFileNames = new List(); + state.PlayableStreamFileNames = new string[]{}; } } else { - state.PlayableStreamFileNames = new List(); + state.PlayableStreamFileNames = new string[] { }; } if (mediaSource.Timestamp.HasValue) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs index b552579a8..c2ce96979 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs @@ -27,7 +27,7 @@ namespace MediaBrowser.Controller.MediaEncoding public string MediaPath { get; set; } public bool IsInputVideo { get; set; } public IIsoMount IsoMount { get; set; } - public List PlayableStreamFileNames { get; set; } + public string[] PlayableStreamFileNames { get; set; } public string OutputAudioCodec { get; set; } public int? OutputVideoBitrate { get; set; } public MediaStream SubtitleStream { get; set; } @@ -42,8 +42,8 @@ namespace MediaBrowser.Controller.MediaEncoding public bool ReadInputAtNativeFramerate { get; set; } - private List _transcodeReasons = null; - public List TranscodeReasons + private TranscodeReason[] _transcodeReasons = null; + public TranscodeReason[] TranscodeReasons { get { @@ -53,7 +53,7 @@ namespace MediaBrowser.Controller.MediaEncoding .Split(',') .Where(i => !string.IsNullOrWhiteSpace(i)) .Select(v => (TranscodeReason)Enum.Parse(typeof(TranscodeReason), v, true)) - .ToList(); + .ToArray(); } return _transcodeReasons; @@ -164,7 +164,7 @@ namespace MediaBrowser.Controller.MediaEncoding _logger = logger; TranscodingType = jobType; RemoteHttpHeaders = new Dictionary(StringComparer.OrdinalIgnoreCase); - PlayableStreamFileNames = new List(); + PlayableStreamFileNames = new string[]{}; SupportedAudioCodecs = new List(); SupportedVideoCodecs = new List(); SupportedSubtitleCodecs = new List(); diff --git a/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs b/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs index d5c85197f..70e4db84f 100644 --- a/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs +++ b/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs @@ -1,12 +1,9 @@ using MediaBrowser.Model.IO; using MediaBrowser.Model.MediaInfo; using System; -using System.Collections.Generic; using System.IO; using System.Linq; -using MediaBrowser.Controller.IO; - namespace MediaBrowser.Controller.MediaEncoding { /// @@ -23,34 +20,34 @@ namespace MediaBrowser.Controller.MediaEncoding /// The iso mount. /// The playable stream file names. /// System.String[][]. - public static string[] GetInputArgument(IFileSystem fileSystem, string videoPath, MediaProtocol protocol, IIsoMount isoMount, List playableStreamFileNames) + public static string[] GetInputArgument(IFileSystem fileSystem, string videoPath, MediaProtocol protocol, IIsoMount isoMount, string[] playableStreamFileNames) { - if (playableStreamFileNames.Count > 0) + if (playableStreamFileNames.Length > 0) { if (isoMount == null) { - return GetPlayableStreamFiles(fileSystem, videoPath, playableStreamFileNames).ToArray(); + return GetPlayableStreamFiles(fileSystem, videoPath, playableStreamFileNames); } - return GetPlayableStreamFiles(fileSystem, isoMount.MountedPath, playableStreamFileNames).ToArray(); + return GetPlayableStreamFiles(fileSystem, isoMount.MountedPath, playableStreamFileNames); } return new[] {videoPath}; } - private static List GetPlayableStreamFiles(IFileSystem fileSystem, string rootPath, List filenames) + private static string[] GetPlayableStreamFiles(IFileSystem fileSystem, string rootPath, string[] filenames) { - if (filenames.Count == 0) + if (filenames.Length == 0) { - return new List(); + return new string[]{}; } var allFiles = fileSystem .GetFilePaths(rootPath, true) - .ToList(); + .ToArray(); return filenames.Select(name => allFiles.FirstOrDefault(f => string.Equals(Path.GetFileName(f), name, StringComparison.OrdinalIgnoreCase))) .Where(f => !string.IsNullOrEmpty(f)) - .ToList(); + .ToArray(); } } } diff --git a/MediaBrowser.Controller/MediaEncoding/MediaInfoRequest.cs b/MediaBrowser.Controller/MediaEncoding/MediaInfoRequest.cs index 0785ee29f..929f4e649 100644 --- a/MediaBrowser.Controller/MediaEncoding/MediaInfoRequest.cs +++ b/MediaBrowser.Controller/MediaEncoding/MediaInfoRequest.cs @@ -14,12 +14,12 @@ namespace MediaBrowser.Controller.MediaEncoding public DlnaProfileType MediaType { get; set; } public IIsoMount MountedIso { get; set; } public VideoType VideoType { get; set; } - public List PlayableStreamFileNames { get; set; } + public string[] PlayableStreamFileNames { get; set; } public int AnalyzeDurationMs { get; set; } public MediaInfoRequest() { - PlayableStreamFileNames = new List(); + PlayableStreamFileNames = new string[] { }; } } } diff --git a/MediaBrowser.Controller/Notifications/INotificationManager.cs b/MediaBrowser.Controller/Notifications/INotificationManager.cs index cb1e3da90..f9d264314 100644 --- a/MediaBrowser.Controller/Notifications/INotificationManager.cs +++ b/MediaBrowser.Controller/Notifications/INotificationManager.cs @@ -26,7 +26,7 @@ namespace MediaBrowser.Controller.Notifications /// Gets the notification types. /// /// IEnumerable{NotificationTypeInfo}. - IEnumerable GetNotificationTypes(); + List GetNotificationTypes(); /// /// Gets the notification services. diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index aec0668d4..e36e6ad5d 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -89,7 +89,7 @@ namespace MediaBrowser.Controller.Playlists return new List(); } - public override IEnumerable GetChildren(User user, bool includeLinkedChildren) + public override List GetChildren(User user, bool includeLinkedChildren) { return GetPlayableItems(user, new DtoOptions(true)); } diff --git a/MediaBrowser.Controller/Providers/IProviderManager.cs b/MediaBrowser.Controller/Providers/IProviderManager.cs index 703666d66..77e6a7e40 100644 --- a/MediaBrowser.Controller/Providers/IProviderManager.cs +++ b/MediaBrowser.Controller/Providers/IProviderManager.cs @@ -97,7 +97,7 @@ namespace MediaBrowser.Controller.Providers /// Gets all metadata plugins. /// /// IEnumerable{MetadataPlugin}. - IEnumerable GetAllMetadataPlugins(); + MetadataPluginSummary[] GetAllMetadataPlugins(); /// /// Gets the external urls. diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index 11a9ceac4..265f4f544 100644 --- a/MediaBrowser.Controller/Session/SessionInfo.cs +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -22,13 +22,13 @@ namespace MediaBrowser.Controller.Session _sessionManager = sessionManager; _logger = logger; - AdditionalUsers = new List(); + AdditionalUsers = new SessionUserInfo[] { }; PlayState = new PlayerStateInfo(); } public PlayerStateInfo PlayState { get; set; } - public List AdditionalUsers { get; set; } + public SessionUserInfo[] AdditionalUsers { get; set; } public ClientCapabilities Capabilities { get; set; } @@ -42,13 +42,13 @@ namespace MediaBrowser.Controller.Session /// Gets or sets the playable media types. /// /// The playable media types. - public List PlayableMediaTypes + public string[] PlayableMediaTypes { get { if (Capabilities == null) { - return new List(); + return new string[] { }; } return Capabilities.PlayableMediaTypes; } @@ -138,13 +138,13 @@ namespace MediaBrowser.Controller.Session /// Gets or sets the supported commands. /// /// The supported commands. - public List SupportedCommands + public string[] SupportedCommands { get { if (Capabilities == null) { - return new List(); + return new string[] { }; } return Capabilities.SupportedCommands; } diff --git a/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs b/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs index d1d5f27be..2199c21e6 100644 --- a/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs +++ b/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs @@ -28,7 +28,7 @@ namespace MediaBrowser.Controller.Subtitles /// /// Searches the subtitles. /// - Task> SearchSubtitles(Video video, + Task SearchSubtitles(Video video, string language, bool? isPerfectMatch, CancellationToken cancellationToken); @@ -39,7 +39,7 @@ namespace MediaBrowser.Controller.Subtitles /// The request. /// The cancellation token. /// Task{IEnumerable{RemoteSubtitleInfo}}. - Task> SearchSubtitles(SubtitleSearchRequest request, + Task SearchSubtitles(SubtitleSearchRequest request, CancellationToken cancellationToken); /// @@ -74,6 +74,6 @@ namespace MediaBrowser.Controller.Subtitles /// /// The item identifier. /// IEnumerable{SubtitleProviderInfo}. - IEnumerable GetProviders(string itemId); + SubtitleProviderInfo[] GetProviders(string itemId); } } diff --git a/MediaBrowser.Controller/Sync/ISyncManager.cs b/MediaBrowser.Controller/Sync/ISyncManager.cs index 66f64464f..910d697ec 100644 --- a/MediaBrowser.Controller/Sync/ISyncManager.cs +++ b/MediaBrowser.Controller/Sync/ISyncManager.cs @@ -79,7 +79,7 @@ namespace MediaBrowser.Controller.Sync /// The target identifier. /// The item ids. /// Task. - Task CancelItems(string targetId, IEnumerable itemIds); + Task CancelItems(string targetId, string[] itemIds); /// /// Adds the parts. @@ -89,9 +89,9 @@ namespace MediaBrowser.Controller.Sync /// /// Gets the synchronize targets. /// - IEnumerable GetSyncTargets(string userId); + List GetSyncTargets(string userId); - IEnumerable GetSyncTargets(string userId, bool? supportsRemoteSync); + List GetSyncTargets(string userId, bool? supportsRemoteSync); /// /// Supportses the synchronize. @@ -160,28 +160,24 @@ namespace MediaBrowser.Controller.Sync /// Gets the quality options. /// /// The target identifier. - /// IEnumerable<SyncQualityOption>. - IEnumerable GetQualityOptions(string targetId); + List GetQualityOptions(string targetId); /// /// Gets the quality options. /// /// The target identifier. /// The user. - /// IEnumerable<SyncQualityOption>. - IEnumerable GetQualityOptions(string targetId, User user); + List GetQualityOptions(string targetId, User user); /// /// Gets the profile options. /// /// The target identifier. - /// IEnumerable<SyncQualityOption>. - IEnumerable GetProfileOptions(string targetId); + List GetProfileOptions(string targetId); /// /// Gets the profile options. /// /// The target identifier. /// The user. - /// IEnumerable<SyncProfileOption>. - IEnumerable GetProfileOptions(string targetId, User user); + List GetProfileOptions(string targetId, User user); } } diff --git a/MediaBrowser.Controller/Sync/ISyncProvider.cs b/MediaBrowser.Controller/Sync/ISyncProvider.cs index aa4b36427..2f60e124e 100644 --- a/MediaBrowser.Controller/Sync/ISyncProvider.cs +++ b/MediaBrowser.Controller/Sync/ISyncProvider.cs @@ -18,13 +18,13 @@ namespace MediaBrowser.Controller.Sync /// /// The user identifier. /// IEnumerable<SyncTarget>. - IEnumerable GetSyncTargets(string userId); + List GetSyncTargets(string userId); /// /// Gets all synchronize targets. /// /// IEnumerable<SyncTarget>. - IEnumerable GetAllSyncTargets(); + List GetAllSyncTargets(); } public interface IHasUniqueTargetIds diff --git a/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs b/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs index 1b61f079e..ddfb70321 100644 --- a/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs +++ b/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs @@ -163,36 +163,71 @@ namespace MediaBrowser.LocalMetadata.Images PopulateScreenshots(images, files, imagePrefix, isInMixedFolder); } + private static readonly string[] CommonImageFileNames = new[] + { + "poster", + "folder", + "cover", + "default" + }; + + private static readonly string[] MusicImageFileNames = new[] + { + "folder", + "poster", + "cover", + "default" + }; + + private static readonly string[] PersonImageFileNames = new[] + { + "folder", + "poster" + }; + + private static readonly string[] SeriesImageFileNames = new[] + { + "poster", + "folder", + "cover", + "default", + "show" + }; + + private static readonly string[] VideoImageFileNames = new[] + { + "poster", + "folder", + "cover", + "default", + "movie" + }; + private void PopulatePrimaryImages(IHasMetadata item, List images, List files, string imagePrefix, bool isInMixedFolder) { - var names = new List - { - "cover", - "default" - }; + string[] imageFileNames; - if (item is MusicAlbum || item is MusicArtist || item is PhotoAlbum || item is Person) + if (item is MusicAlbum || item is MusicArtist || item is PhotoAlbum) { // these prefer folder - names.Insert(0, "poster"); - names.Insert(0, "folder"); + imageFileNames = MusicImageFileNames; + } + else if (item is Person) + { + // these prefer folder + imageFileNames = PersonImageFileNames; + } + else if (item is Series) + { + imageFileNames = SeriesImageFileNames; + } + else if (item is Video && !(item is Episode)) + { + imageFileNames = VideoImageFileNames; } else { - names.Insert(0, "folder"); - names.Insert(0, "poster"); - } - - // Support plex/kodi convention - if (item is Series) - { - names.Add("show"); - } - - // Support plex/kodi convention - if (item is Video && !(item is Episode)) - { - names.Add("movie"); + imageFileNames = CommonImageFileNames; } var fileNameWithoutExtension = item.FileNameWithoutExtension; @@ -201,14 +236,14 @@ namespace MediaBrowser.LocalMetadata.Images AddImage(files, images, fileNameWithoutExtension, ImageType.Primary); } - foreach (var name in names) + foreach (var name in imageFileNames) { AddImage(files, images, imagePrefix + name, ImageType.Primary); } if (!isInMixedFolder) { - foreach (var name in names) + foreach (var name in imageFileNames) { AddImage(files, images, name, ImageType.Primary); } diff --git a/MediaBrowser.Model/Channels/AllChannelMediaQuery.cs b/MediaBrowser.Model/Channels/AllChannelMediaQuery.cs index c5631899e..920f3e4b2 100644 --- a/MediaBrowser.Model/Channels/AllChannelMediaQuery.cs +++ b/MediaBrowser.Model/Channels/AllChannelMediaQuery.cs @@ -52,10 +52,10 @@ namespace MediaBrowser.Model.Channels TrailerTypes = new TrailerType[] { }; Filters = new ItemFilter[] { }; - Fields = new List(); + Fields = new ItemFields[]{}; } public ItemFilter[] Filters { get; set; } - public List Fields { get; set; } + public ItemFields[] Fields { get; set; } } } \ No newline at end of file diff --git a/MediaBrowser.Model/Channels/ChannelFeatures.cs b/MediaBrowser.Model/Channels/ChannelFeatures.cs index 8dfdbcd7a..39b40cabc 100644 --- a/MediaBrowser.Model/Channels/ChannelFeatures.cs +++ b/MediaBrowser.Model/Channels/ChannelFeatures.cs @@ -26,13 +26,13 @@ namespace MediaBrowser.Model.Channels /// Gets or sets the media types. /// /// The media types. - public List MediaTypes { get; set; } + public ChannelMediaType[] MediaTypes { get; set; } /// /// Gets or sets the content types. /// /// The content types. - public List ContentTypes { get; set; } + public ChannelMediaContentType[] ContentTypes { get; set; } /// /// Represents the maximum number of records the channel allows retrieving at a time @@ -49,7 +49,7 @@ namespace MediaBrowser.Model.Channels /// Gets or sets the default sort orders. /// /// The default sort orders. - public List DefaultSortFields { get; set; } + public ChannelItemSortField[] DefaultSortFields { get; set; } /// /// Indicates if a sort ascending/descending toggle is supported or not. @@ -76,10 +76,10 @@ namespace MediaBrowser.Model.Channels public ChannelFeatures() { - MediaTypes = new List(); - ContentTypes = new List(); + MediaTypes = new ChannelMediaType[] { }; + ContentTypes = new ChannelMediaContentType[] { }; - DefaultSortFields = new List(); + DefaultSortFields = new ChannelItemSortField[] { }; } } } diff --git a/MediaBrowser.Model/Configuration/MetadataOptions.cs b/MediaBrowser.Model/Configuration/MetadataOptions.cs index ddde688b2..8a41decbf 100644 --- a/MediaBrowser.Model/Configuration/MetadataOptions.cs +++ b/MediaBrowser.Model/Configuration/MetadataOptions.cs @@ -29,7 +29,7 @@ namespace MediaBrowser.Model.Configuration public MetadataOptions(int backdropLimit, int minBackdropWidth) { - List imageOptions = new List + ImageOptions = new[] { new ImageOption { @@ -39,7 +39,6 @@ namespace MediaBrowser.Model.Configuration } }; - ImageOptions = imageOptions.ToArray(); DisabledMetadataSavers = new string[] { }; LocalMetadataReaderOrder = new string[] { }; diff --git a/MediaBrowser.Model/Configuration/MetadataPluginSummary.cs b/MediaBrowser.Model/Configuration/MetadataPluginSummary.cs index 90b3933eb..80142cf43 100644 --- a/MediaBrowser.Model/Configuration/MetadataPluginSummary.cs +++ b/MediaBrowser.Model/Configuration/MetadataPluginSummary.cs @@ -15,18 +15,18 @@ namespace MediaBrowser.Model.Configuration /// Gets or sets the plugins. /// /// The plugins. - public List Plugins { get; set; } + public MetadataPlugin[] Plugins { get; set; } /// /// Gets or sets the supported image types. /// /// The supported image types. - public List SupportedImageTypes { get; set; } + public ImageType[] SupportedImageTypes { get; set; } public MetadataPluginSummary() { - SupportedImageTypes = new List(); - Plugins = new List(); + SupportedImageTypes = new ImageType[] { }; + Plugins = new MetadataPlugin[] { }; } } } \ No newline at end of file diff --git a/MediaBrowser.Model/Devices/ContentUploadHistory.cs b/MediaBrowser.Model/Devices/ContentUploadHistory.cs index cd4858d90..2b344df24 100644 --- a/MediaBrowser.Model/Devices/ContentUploadHistory.cs +++ b/MediaBrowser.Model/Devices/ContentUploadHistory.cs @@ -5,11 +5,11 @@ namespace MediaBrowser.Model.Devices public class ContentUploadHistory { public string DeviceId { get; set; } - public List FilesUploaded { get; set; } + public LocalFileInfo[] FilesUploaded { get; set; } public ContentUploadHistory() { - FilesUploaded = new List(); + FilesUploaded = new LocalFileInfo[] { }; } } } diff --git a/MediaBrowser.Model/Dlna/AudioOptions.cs b/MediaBrowser.Model/Dlna/AudioOptions.cs index 24c7aef98..6584bb3cc 100644 --- a/MediaBrowser.Model/Dlna/AudioOptions.cs +++ b/MediaBrowser.Model/Dlna/AudioOptions.cs @@ -22,7 +22,7 @@ namespace MediaBrowser.Model.Dlna public bool ForceDirectStream { get; set; } public string ItemId { get; set; } - public List MediaSources { get; set; } + public MediaSourceInfo[] MediaSources { get; set; } public DeviceProfile Profile { get; set; } /// diff --git a/MediaBrowser.Model/Dlna/CodecProfile.cs b/MediaBrowser.Model/Dlna/CodecProfile.cs index 14b1875c1..d75547adb 100644 --- a/MediaBrowser.Model/Dlna/CodecProfile.cs +++ b/MediaBrowser.Model/Dlna/CodecProfile.cs @@ -26,19 +26,9 @@ namespace MediaBrowser.Model.Dlna ApplyConditions = new ProfileCondition[] { }; } - private static List SplitValue(string value) + public string[] GetCodecs() { - List list = new List(); - foreach (string i in (value ?? string.Empty).Split(',')) - { - if (!string.IsNullOrEmpty(i)) list.Add(i); - } - return list; - } - - public List GetCodecs() - { - return SplitValue(Codec); + return ContainerProfile.SplitValue(Codec); } private bool ContainsContainer(string container) @@ -53,10 +43,9 @@ namespace MediaBrowser.Model.Dlna return false; } - List codecs = GetCodecs(); + var codecs = GetCodecs(); - return codecs.Count == 0 || ListHelper.ContainsIgnoreCase(codecs, SplitValue(codec)[0]); - //return codecs.Count == 0 || SplitValue(codec).Any(i => ListHelper.ContainsIgnoreCase(codecs, i)); + return codecs.Length == 0 || ListHelper.ContainsIgnoreCase(codecs, ContainerProfile.SplitValue(codec)[0]); } } } diff --git a/MediaBrowser.Model/Dlna/ContainerProfile.cs b/MediaBrowser.Model/Dlna/ContainerProfile.cs index 2004cfc1f..23bbf0193 100644 --- a/MediaBrowser.Model/Dlna/ContainerProfile.cs +++ b/MediaBrowser.Model/Dlna/ContainerProfile.cs @@ -20,24 +20,26 @@ namespace MediaBrowser.Model.Dlna Conditions = new ProfileCondition[] { }; } - public List GetContainers() + public string[] GetContainers() { return SplitValue(Container); } - public static List SplitValue(string value) + private static readonly string[] EmptyStringArray = new string[] { }; + + public static string[] SplitValue(string value) { - List list = new List(); - foreach (string i in (value ?? string.Empty).Split(',')) + if (string.IsNullOrWhiteSpace(value)) { - if (!string.IsNullOrWhiteSpace(i)) list.Add(i); + return EmptyStringArray; } - return list; + + return value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } public bool ContainsContainer(string container) { - List containers = GetContainers(); + var containers = GetContainers(); return ContainsContainer(containers, container); } @@ -47,9 +49,9 @@ namespace MediaBrowser.Model.Dlna return ContainsContainer(SplitValue(profileContainers), inputContainer); } - public static bool ContainsContainer(List profileContainers, string inputContainer) + public static bool ContainsContainer(string[] profileContainers, string inputContainer) { - if (profileContainers.Count == 0) + if (profileContainers.Length == 0) { return true; } diff --git a/MediaBrowser.Model/Dlna/DeviceProfile.cs b/MediaBrowser.Model/Dlna/DeviceProfile.cs index 5f9bd772c..d6f0eafc7 100644 --- a/MediaBrowser.Model/Dlna/DeviceProfile.cs +++ b/MediaBrowser.Model/Dlna/DeviceProfile.cs @@ -117,15 +117,9 @@ namespace MediaBrowser.Model.Dlna MusicStreamingTranscodingBitrate = 128000; } - public List GetSupportedMediaTypes() + public string[] GetSupportedMediaTypes() { - List list = new List(); - foreach (string i in (SupportedMediaTypes ?? string.Empty).Split(',')) - { - if (!string.IsNullOrEmpty(i)) - list.Add(i); - } - return list; + return ContainerProfile.SplitValue(SupportedMediaTypes); } public TranscodingProfile GetAudioTranscodingProfile(string container, string audioCodec) @@ -199,8 +193,8 @@ namespace MediaBrowser.Model.Dlna continue; } - List audioCodecs = i.GetAudioCodecs(); - if (audioCodecs.Count > 0 && !ListHelper.ContainsIgnoreCase(audioCodecs, audioCodec ?? string.Empty)) + var audioCodecs = i.GetAudioCodecs(); + if (audioCodecs.Length > 0 && !ListHelper.ContainsIgnoreCase(audioCodecs, audioCodec ?? string.Empty)) { continue; } @@ -306,14 +300,14 @@ namespace MediaBrowser.Model.Dlna continue; } - List audioCodecs = i.GetAudioCodecs(); - if (audioCodecs.Count > 0 && !ListHelper.ContainsIgnoreCase(audioCodecs, audioCodec ?? string.Empty)) + var audioCodecs = i.GetAudioCodecs(); + if (audioCodecs.Length > 0 && !ListHelper.ContainsIgnoreCase(audioCodecs, audioCodec ?? string.Empty)) { continue; } - List videoCodecs = i.GetVideoCodecs(); - if (videoCodecs.Count > 0 && !ListHelper.ContainsIgnoreCase(videoCodecs, videoCodec ?? string.Empty)) + var videoCodecs = i.GetVideoCodecs(); + if (videoCodecs.Length > 0 && !ListHelper.ContainsIgnoreCase(videoCodecs, videoCodec ?? string.Empty)) { continue; } diff --git a/MediaBrowser.Model/Dlna/DirectPlayProfile.cs b/MediaBrowser.Model/Dlna/DirectPlayProfile.cs index e80f59be4..7430c449f 100644 --- a/MediaBrowser.Model/Dlna/DirectPlayProfile.cs +++ b/MediaBrowser.Model/Dlna/DirectPlayProfile.cs @@ -23,24 +23,14 @@ namespace MediaBrowser.Model.Dlna return ContainerProfile.ContainsContainer(Container, container); } - public List GetAudioCodecs() + public string[] GetAudioCodecs() { - List list = new List(); - foreach (string i in (AudioCodec ?? string.Empty).Split(',')) - { - if (!string.IsNullOrEmpty(i)) list.Add(i); - } - return list; + return ContainerProfile.SplitValue(AudioCodec); } - public List GetVideoCodecs() + public string[] GetVideoCodecs() { - List list = new List(); - foreach (string i in (VideoCodec ?? string.Empty).Split(',')) - { - if (!string.IsNullOrEmpty(i)) list.Add(i); - } - return list; + return ContainerProfile.SplitValue(VideoCodec); } } } diff --git a/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs b/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs index a464b045b..034e0fe6a 100644 --- a/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs +++ b/MediaBrowser.Model/Dlna/MediaFormatProfileResolver.cs @@ -7,33 +7,33 @@ namespace MediaBrowser.Model.Dlna { public class MediaFormatProfileResolver { - public List ResolveVideoFormat(string container, string videoCodec, string audioCodec, int? width, int? height, TransportStreamTimestamp timestampType) + public MediaFormatProfile[] ResolveVideoFormat(string container, string videoCodec, string audioCodec, int? width, int? height, TransportStreamTimestamp timestampType) { if (StringHelper.EqualsIgnoreCase(container, "asf")) { MediaFormatProfile? val = ResolveVideoASFFormat(videoCodec, audioCodec, width, height); - return val.HasValue ? new List { val.Value } : new List(); + return val.HasValue ? new MediaFormatProfile[] { val.Value } : new MediaFormatProfile[]{}; } if (StringHelper.EqualsIgnoreCase(container, "mp4")) { MediaFormatProfile? val = ResolveVideoMP4Format(videoCodec, audioCodec, width, height); - return val.HasValue ? new List { val.Value } : new List(); + return val.HasValue ? new MediaFormatProfile[] { val.Value } : new MediaFormatProfile[] { }; } if (StringHelper.EqualsIgnoreCase(container, "avi")) - return new List { MediaFormatProfile.AVI }; + return new MediaFormatProfile[] { MediaFormatProfile.AVI }; if (StringHelper.EqualsIgnoreCase(container, "mkv")) - return new List { MediaFormatProfile.MATROSKA }; + return new MediaFormatProfile[] { MediaFormatProfile.MATROSKA }; if (StringHelper.EqualsIgnoreCase(container, "mpeg2ps") || StringHelper.EqualsIgnoreCase(container, "ts")) - return new List { MediaFormatProfile.MPEG_PS_NTSC, MediaFormatProfile.MPEG_PS_PAL }; + return new MediaFormatProfile[] { MediaFormatProfile.MPEG_PS_NTSC, MediaFormatProfile.MPEG_PS_PAL }; if (StringHelper.EqualsIgnoreCase(container, "mpeg1video")) - return new List { MediaFormatProfile.MPEG1 }; + return new MediaFormatProfile[] { MediaFormatProfile.MPEG1 }; if (StringHelper.EqualsIgnoreCase(container, "mpeg2ts") || StringHelper.EqualsIgnoreCase(container, "mpegts") || @@ -44,24 +44,24 @@ namespace MediaBrowser.Model.Dlna } if (StringHelper.EqualsIgnoreCase(container, "flv")) - return new List { MediaFormatProfile.FLV }; + return new MediaFormatProfile[] { MediaFormatProfile.FLV }; if (StringHelper.EqualsIgnoreCase(container, "wtv")) - return new List { MediaFormatProfile.WTV }; + return new MediaFormatProfile[] { MediaFormatProfile.WTV }; if (StringHelper.EqualsIgnoreCase(container, "3gp")) { MediaFormatProfile? val = ResolveVideo3GPFormat(videoCodec, audioCodec); - return val.HasValue ? new List { val.Value } : new List(); + return val.HasValue ? new MediaFormatProfile[] { val.Value } : new MediaFormatProfile[] { }; } if (StringHelper.EqualsIgnoreCase(container, "ogv") || StringHelper.EqualsIgnoreCase(container, "ogg")) - return new List { MediaFormatProfile.OGV }; + return new MediaFormatProfile[] { MediaFormatProfile.OGV }; - return new List(); + return new MediaFormatProfile[] { }; } - private List ResolveVideoMPEG2TSFormat(string videoCodec, string audioCodec, int? width, int? height, TransportStreamTimestamp timestampType) + private MediaFormatProfile[] ResolveVideoMPEG2TSFormat(string videoCodec, string audioCodec, int? width, int? height, TransportStreamTimestamp timestampType) { string suffix = ""; @@ -93,41 +93,41 @@ namespace MediaBrowser.Model.Dlna { list.Add(MediaFormatProfile.MPEG_TS_JP_T); } - return list; + return list.ToArray(list.Count); } if (StringHelper.EqualsIgnoreCase(videoCodec, "h264")) { if (StringHelper.EqualsIgnoreCase(audioCodec, "lpcm")) - return new List { MediaFormatProfile.AVC_TS_HD_50_LPCM_T }; + return new MediaFormatProfile[] { MediaFormatProfile.AVC_TS_HD_50_LPCM_T }; if (StringHelper.EqualsIgnoreCase(audioCodec, "dts")) { if (timestampType == TransportStreamTimestamp.None) { - return new List { MediaFormatProfile.AVC_TS_HD_DTS_ISO }; + return new MediaFormatProfile[] { MediaFormatProfile.AVC_TS_HD_DTS_ISO }; } - return new List { MediaFormatProfile.AVC_TS_HD_DTS_T }; + return new MediaFormatProfile[] { MediaFormatProfile.AVC_TS_HD_DTS_T }; } if (StringHelper.EqualsIgnoreCase(audioCodec, "mp2")) { if (timestampType == TransportStreamTimestamp.None) { - return new List { ValueOf(string.Format("AVC_TS_HP_{0}D_MPEG1_L2_ISO", resolution)) }; + return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_HP_{0}D_MPEG1_L2_ISO", resolution)) }; } - return new List { ValueOf(string.Format("AVC_TS_HP_{0}D_MPEG1_L2_T", resolution)) }; + return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_HP_{0}D_MPEG1_L2_T", resolution)) }; } if (StringHelper.EqualsIgnoreCase(audioCodec, "aac")) - return new List { ValueOf(string.Format("AVC_TS_MP_{0}D_AAC_MULT5{1}", resolution, suffix)) }; + return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_MP_{0}D_AAC_MULT5{1}", resolution, suffix)) }; if (StringHelper.EqualsIgnoreCase(audioCodec, "mp3")) - return new List { ValueOf(string.Format("AVC_TS_MP_{0}D_MPEG1_L3{1}", resolution, suffix)) }; + return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_MP_{0}D_MPEG1_L3{1}", resolution, suffix)) }; if (string.IsNullOrEmpty(audioCodec) || StringHelper.EqualsIgnoreCase(audioCodec, "ac3")) - return new List { ValueOf(string.Format("AVC_TS_MP_{0}D_AC3{1}", resolution, suffix)) }; + return new MediaFormatProfile[] { ValueOf(string.Format("AVC_TS_MP_{0}D_AC3{1}", resolution, suffix)) }; } else if (StringHelper.EqualsIgnoreCase(videoCodec, "vc1")) { @@ -135,31 +135,31 @@ namespace MediaBrowser.Model.Dlna { if ((width.HasValue && width.Value > 720) || (height.HasValue && height.Value > 576)) { - return new List { MediaFormatProfile.VC1_TS_AP_L2_AC3_ISO }; + return new MediaFormatProfile[] { MediaFormatProfile.VC1_TS_AP_L2_AC3_ISO }; } - return new List { MediaFormatProfile.VC1_TS_AP_L1_AC3_ISO }; + return new MediaFormatProfile[] { MediaFormatProfile.VC1_TS_AP_L1_AC3_ISO }; } if (StringHelper.EqualsIgnoreCase(audioCodec, "dts")) { suffix = StringHelper.EqualsIgnoreCase(suffix, "_ISO") ? suffix : "_T"; - return new List { ValueOf(string.Format("VC1_TS_HD_DTS{0}", suffix)) }; + return new MediaFormatProfile[] { ValueOf(string.Format("VC1_TS_HD_DTS{0}", suffix)) }; } } else if (StringHelper.EqualsIgnoreCase(videoCodec, "mpeg4") || StringHelper.EqualsIgnoreCase(videoCodec, "msmpeg4")) { if (StringHelper.EqualsIgnoreCase(audioCodec, "aac")) - return new List { ValueOf(string.Format("MPEG4_P2_TS_ASP_AAC{0}", suffix)) }; + return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_AAC{0}", suffix)) }; if (StringHelper.EqualsIgnoreCase(audioCodec, "mp3")) - return new List { ValueOf(string.Format("MPEG4_P2_TS_ASP_MPEG1_L3{0}", suffix)) }; + return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_MPEG1_L3{0}", suffix)) }; if (StringHelper.EqualsIgnoreCase(audioCodec, "mp2")) - return new List { ValueOf(string.Format("MPEG4_P2_TS_ASP_MPEG2_L2{0}", suffix)) }; + return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_MPEG2_L2{0}", suffix)) }; if (StringHelper.EqualsIgnoreCase(audioCodec, "ac3")) - return new List { ValueOf(string.Format("MPEG4_P2_TS_ASP_AC3{0}", suffix)) }; + return new MediaFormatProfile[] { ValueOf(string.Format("MPEG4_P2_TS_ASP_AC3{0}", suffix)) }; } - return new List(); + return new MediaFormatProfile[]{}; } private MediaFormatProfile ValueOf(string value) diff --git a/MediaBrowser.Model/Dlna/ResolutionNormalizer.cs b/MediaBrowser.Model/Dlna/ResolutionNormalizer.cs index 950d3680d..ae74e255b 100644 --- a/MediaBrowser.Model/Dlna/ResolutionNormalizer.cs +++ b/MediaBrowser.Model/Dlna/ResolutionNormalizer.cs @@ -6,8 +6,8 @@ namespace MediaBrowser.Model.Dlna { public class ResolutionNormalizer { - private static readonly List Configurations = - new List + private static readonly ResolutionConfiguration[] Configurations = + new [] { new ResolutionConfiguration(426, 320000), new ResolutionConfiguration(640, 400000), diff --git a/MediaBrowser.Model/Dlna/ResponseProfile.cs b/MediaBrowser.Model/Dlna/ResponseProfile.cs index f1a001bba..742253fa3 100644 --- a/MediaBrowser.Model/Dlna/ResponseProfile.cs +++ b/MediaBrowser.Model/Dlna/ResponseProfile.cs @@ -31,29 +31,19 @@ namespace MediaBrowser.Model.Dlna Conditions = new ProfileCondition[] {}; } - public List GetContainers() + public string[] GetContainers() { return ContainerProfile.SplitValue(Container); } - public List GetAudioCodecs() + public string[] GetAudioCodecs() { - List list = new List(); - foreach (string i in (AudioCodec ?? string.Empty).Split(',')) - { - if (!string.IsNullOrEmpty(i)) list.Add(i); - } - return list; + return ContainerProfile.SplitValue(AudioCodec); } - public List GetVideoCodecs() + public string[] GetVideoCodecs() { - List list = new List(); - foreach (string i in (VideoCodec ?? string.Empty).Split(',')) - { - if (!string.IsNullOrEmpty(i)) list.Add(i); - } - return list; + return ContainerProfile.SplitValue(VideoCodec); } } } diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index 189ed27e4..1cb783669 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -31,7 +31,7 @@ namespace MediaBrowser.Model.Dlna { ValidateAudioInput(options); - List mediaSources = new List(); + var mediaSources = new List(); foreach (MediaSourceInfo i in options.MediaSources) { if (string.IsNullOrEmpty(options.MediaSourceId) || @@ -41,7 +41,7 @@ namespace MediaBrowser.Model.Dlna } } - List streams = new List(); + var streams = new List(); foreach (MediaSourceInfo i in mediaSources) { StreamInfo streamInfo = BuildAudioItem(i, options); @@ -64,7 +64,7 @@ namespace MediaBrowser.Model.Dlna { ValidateInput(options); - List mediaSources = new List(); + var mediaSources = new List(); foreach (MediaSourceInfo i in options.MediaSources) { if (string.IsNullOrEmpty(options.MediaSourceId) || @@ -74,7 +74,7 @@ namespace MediaBrowser.Model.Dlna } } - List streams = new List(); + var streams = new List(); foreach (MediaSourceInfo i in mediaSources) { StreamInfo streamInfo = BuildVideoItem(i, options); @@ -95,9 +95,9 @@ namespace MediaBrowser.Model.Dlna private StreamInfo GetOptimalStream(List streams, long? maxBitrate) { - streams = StreamInfoSorter.SortMediaSources(streams, maxBitrate); + var sorted = StreamInfoSorter.SortMediaSources(streams, maxBitrate); - foreach (StreamInfo stream in streams) + foreach (StreamInfo stream in sorted) { return stream; } @@ -206,7 +206,7 @@ namespace MediaBrowser.Model.Dlna var formats = ContainerProfile.SplitValue(inputContainer); - if (formats.Count == 1) + if (formats.Length == 1) { return formats[0]; } @@ -233,7 +233,7 @@ namespace MediaBrowser.Model.Dlna private StreamInfo BuildAudioItem(MediaSourceInfo item, AudioOptions options) { - List transcodeReasons = new List(); + var transcodeReasons = new List(); StreamInfo playlistItem = new StreamInfo { @@ -263,7 +263,7 @@ namespace MediaBrowser.Model.Dlna var directPlayInfo = GetAudioDirectPlayMethods(item, audioStream, options); - List directPlayMethods = directPlayInfo.Item1; + var directPlayMethods = directPlayInfo.Item1; transcodeReasons.AddRange(directPlayInfo.Item2); ConditionProcessor conditionProcessor = new ConditionProcessor(); @@ -280,7 +280,7 @@ namespace MediaBrowser.Model.Dlna // Make sure audio codec profiles are satisfied if (!string.IsNullOrEmpty(audioCodec)) { - List conditions = new List(); + var conditions = new List(); foreach (CodecProfile i in options.Profile.CodecProfiles) { if (i.Type == CodecType.Audio && i.ContainsCodec(audioCodec, item.Container)) @@ -372,7 +372,7 @@ namespace MediaBrowser.Model.Dlna playlistItem.SubProtocol = transcodingProfile.Protocol; - List audioCodecProfiles = new List(); + var audioCodecProfiles = new List(); foreach (CodecProfile i in options.Profile.CodecProfiles) { if (i.Type == CodecType.Audio && i.ContainsCodec(transcodingProfile.AudioCodec, transcodingProfile.Container)) @@ -383,7 +383,7 @@ namespace MediaBrowser.Model.Dlna if (audioCodecProfiles.Count >= 1) break; } - List audioTranscodingConditions = new List(); + var audioTranscodingConditions = new List(); foreach (CodecProfile i in audioCodecProfiles) { bool applyConditions = true; @@ -447,7 +447,7 @@ namespace MediaBrowser.Model.Dlna private Tuple, List> GetAudioDirectPlayMethods(MediaSourceInfo item, MediaStream audioStream, AudioOptions options) { - List transcodeReasons = new List(); + var transcodeReasons = new List(); DirectPlayProfile directPlayProfile = null; foreach (DirectPlayProfile i in options.Profile.DirectPlayProfiles) @@ -459,7 +459,7 @@ namespace MediaBrowser.Model.Dlna } } - List playMethods = new List(); + var playMethods = new List(); if (directPlayProfile != null) { @@ -534,8 +534,8 @@ namespace MediaBrowser.Model.Dlna if (videoStream != null) { // Check video codec - List videoCodecs = profile.GetVideoCodecs(); - if (videoCodecs.Count > 0) + var videoCodecs = profile.GetVideoCodecs(); + if (videoCodecs.Length > 0) { string videoCodec = videoStream.Codec; if (!string.IsNullOrEmpty(videoCodec) && ListHelper.ContainsIgnoreCase(videoCodecs, videoCodec)) @@ -552,8 +552,8 @@ namespace MediaBrowser.Model.Dlna if (audioStream != null) { // Check audio codec - List audioCodecs = profile.GetAudioCodecs(); - if (audioCodecs.Count > 0) + var audioCodecs = profile.GetAudioCodecs(); + if (audioCodecs.Length > 0) { string audioCodec = audioStream.Codec; if (!string.IsNullOrEmpty(audioCodec) && ListHelper.ContainsIgnoreCase(audioCodecs, audioCodec)) @@ -602,7 +602,7 @@ namespace MediaBrowser.Model.Dlna } } - List topStreams = new List(); + var topStreams = new List(); foreach (MediaStream stream in item.MediaStreams) { if (stream.Type == MediaStreamType.Subtitle && stream.Score.HasValue && stream.Score.Value == highestScore) @@ -637,7 +637,7 @@ namespace MediaBrowser.Model.Dlna throw new ArgumentNullException("item"); } - List transcodeReasons = new List(); + var transcodeReasons = new List(); StreamInfo playlistItem = new StreamInfo { @@ -769,7 +769,7 @@ namespace MediaBrowser.Model.Dlna playlistItem.AudioStreamIndex = audioStreamIndex; ConditionProcessor conditionProcessor = new ConditionProcessor(); - List videoTranscodingConditions = new List(); + var videoTranscodingConditions = new List(); foreach (CodecProfile i in options.Profile.CodecProfiles) { if (i.Type == CodecType.Video && i.ContainsCodec(transcodingProfile.VideoCodec, transcodingProfile.Container)) @@ -804,7 +804,7 @@ namespace MediaBrowser.Model.Dlna } ApplyTranscodingConditions(playlistItem, videoTranscodingConditions); - List audioTranscodingConditions = new List(); + var audioTranscodingConditions = new List(); foreach (CodecProfile i in options.Profile.CodecProfiles) { if (i.Type == CodecType.VideoAudio && i.ContainsCodec(playlistItem.TargetAudioCodec, transcodingProfile.Container)) @@ -990,7 +990,7 @@ namespace MediaBrowser.Model.Dlna string container = mediaSource.Container; - List conditions = new List(); + var conditions = new List(); foreach (ContainerProfile i in profile.ContainerProfiles) { if (i.Type == DlnaProfileType.Video && @@ -1578,8 +1578,8 @@ namespace MediaBrowser.Model.Dlna } // Check audio codec - List audioCodecs = profile.GetAudioCodecs(); - if (audioCodecs.Count > 0) + var audioCodecs = profile.GetAudioCodecs(); + if (audioCodecs.Length > 0) { // Check audio codecs string audioCodec = audioStream == null ? null : audioStream.Codec; @@ -1601,8 +1601,8 @@ namespace MediaBrowser.Model.Dlna } // Check video codec - List videoCodecs = profile.GetVideoCodecs(); - if (videoCodecs.Count > 0) + var videoCodecs = profile.GetVideoCodecs(); + if (videoCodecs.Length > 0) { string videoCodec = videoStream == null ? null : videoStream.Codec; if (string.IsNullOrEmpty(videoCodec) || !ListHelper.ContainsIgnoreCase(videoCodecs, videoCodec)) @@ -1614,8 +1614,8 @@ namespace MediaBrowser.Model.Dlna // Check audio codec if (audioStream != null) { - List audioCodecs = profile.GetAudioCodecs(); - if (audioCodecs.Count > 0) + var audioCodecs = profile.GetAudioCodecs(); + if (audioCodecs.Length > 0) { // Check audio codecs string audioCodec = audioStream == null ? null : audioStream.Codec; diff --git a/MediaBrowser.Model/Dlna/StreamInfoSorter.cs b/MediaBrowser.Model/Dlna/StreamInfoSorter.cs index badd3c5b1..e13b32767 100644 --- a/MediaBrowser.Model/Dlna/StreamInfoSorter.cs +++ b/MediaBrowser.Model/Dlna/StreamInfoSorter.cs @@ -8,7 +8,7 @@ namespace MediaBrowser.Model.Dlna { public class StreamInfoSorter { - public static List SortMediaSources(List streams, long? maxBitrate) + public static StreamInfo[] SortMediaSources(List streams, long? maxBitrate) { return streams.OrderBy(i => { @@ -54,7 +54,7 @@ namespace MediaBrowser.Model.Dlna return 0; - }).ToList(); + }).ToArray(); } } } diff --git a/MediaBrowser.Model/Dlna/SubtitleProfile.cs b/MediaBrowser.Model/Dlna/SubtitleProfile.cs index f182541d8..3f639a520 100644 --- a/MediaBrowser.Model/Dlna/SubtitleProfile.cs +++ b/MediaBrowser.Model/Dlna/SubtitleProfile.cs @@ -19,14 +19,9 @@ namespace MediaBrowser.Model.Dlna [XmlAttribute("language")] public string Language { get; set; } - public List GetLanguages() + public string[] GetLanguages() { - List list = new List(); - foreach (string i in (Language ?? string.Empty).Split(',')) - { - if (!string.IsNullOrEmpty(i)) list.Add(i); - } - return list; + return ContainerProfile.SplitValue(Language); } public bool SupportsLanguage(string subLanguage) @@ -41,8 +36,8 @@ namespace MediaBrowser.Model.Dlna subLanguage = "und"; } - List languages = GetLanguages(); - return languages.Count == 0 || ListHelper.ContainsIgnoreCase(languages, subLanguage); + var languages = GetLanguages(); + return languages.Length == 0 || ListHelper.ContainsIgnoreCase(languages, subLanguage); } } } \ No newline at end of file diff --git a/MediaBrowser.Model/Dlna/TranscodingProfile.cs b/MediaBrowser.Model/Dlna/TranscodingProfile.cs index 9623a68b0..8453fdf6d 100644 --- a/MediaBrowser.Model/Dlna/TranscodingProfile.cs +++ b/MediaBrowser.Model/Dlna/TranscodingProfile.cs @@ -51,14 +51,9 @@ namespace MediaBrowser.Model.Dlna [XmlAttribute("breakOnNonKeyFrames")] public bool BreakOnNonKeyFrames { get; set; } - public List GetAudioCodecs() + public string[] GetAudioCodecs() { - List list = new List(); - foreach (string i in (AudioCodec ?? string.Empty).Split(',')) - { - if (!string.IsNullOrEmpty(i)) list.Add(i); - } - return list; + return ContainerProfile.SplitValue(AudioCodec); } } } diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs index e0e7e55aa..8da20c9f5 100644 --- a/MediaBrowser.Model/Dto/BaseItemDto.cs +++ b/MediaBrowser.Model/Dto/BaseItemDto.cs @@ -497,7 +497,7 @@ namespace MediaBrowser.Model.Dto /// Gets or sets the media streams. /// /// The media streams. - public List MediaStreams { get; set; } + public MediaStream[] MediaStreams { get; set; } /// /// Gets or sets the type of the video. diff --git a/MediaBrowser.Model/Dto/GameSystemSummary.cs b/MediaBrowser.Model/Dto/GameSystemSummary.cs index 1da3bb0ac..2cd9d408d 100644 --- a/MediaBrowser.Model/Dto/GameSystemSummary.cs +++ b/MediaBrowser.Model/Dto/GameSystemSummary.cs @@ -29,7 +29,7 @@ namespace MediaBrowser.Model.Dto /// Gets or sets the game extensions. /// /// The game extensions. - public List GameFileExtensions { get; set; } + public string[] GameFileExtensions { get; set; } /// /// Gets or sets the client installed game count. @@ -42,7 +42,7 @@ namespace MediaBrowser.Model.Dto /// public GameSystemSummary() { - GameFileExtensions = new List(); + GameFileExtensions = new string[] { }; } } } diff --git a/MediaBrowser.Model/Dto/ItemLayout.cs b/MediaBrowser.Model/Dto/ItemLayout.cs deleted file mode 100644 index c85818390..000000000 --- a/MediaBrowser.Model/Dto/ItemLayout.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace MediaBrowser.Model.Dto -{ - public static class ItemLayout - { - public static double? GetDisplayAspectRatio(BaseItemDto item) - { - List items = new List(); - items.Add(item); - return GetDisplayAspectRatio(items); - } - - public static double? GetDisplayAspectRatio(List items) - { - List values = new List(); - - foreach (BaseItemDto item in items) - { - if (item.PrimaryImageAspectRatio.HasValue) - { - values.Add(item.PrimaryImageAspectRatio.Value); - } - } - - if (values.Count == 0) - { - return null; - } - - values.Sort(); - - double halfDouble = values.Count; - halfDouble /= 2; - int half = Convert.ToInt32(Math.Floor(halfDouble)); - - double result; - - if (values.Count % 2 > 0) - result = values[half]; - else - result = (values[half - 1] + values[half]) / 2.0; - - // If really close to 2:3 (poster image), just return 2:3 - if (Math.Abs(0.66666666667 - result) <= .15) - { - return 0.66666666667; - } - - // If really close to 16:9 (episode image), just return 16:9 - if (Math.Abs(1.777777778 - result) <= .2) - { - return 1.777777778; - } - - // If really close to 1 (square image), just return 1 - if (Math.Abs(1 - result) <= .15) - { - return 1.0; - } - - // If really close to 4:3 (poster image), just return 2:3 - if (Math.Abs(1.33333333333 - result) <= .15) - { - return 1.33333333333; - } - - return result; - } - } -} diff --git a/MediaBrowser.Model/Dto/MediaSourceInfo.cs b/MediaBrowser.Model/Dto/MediaSourceInfo.cs index 1bf67f66c..488b1e7a8 100644 --- a/MediaBrowser.Model/Dto/MediaSourceInfo.cs +++ b/MediaBrowser.Model/Dto/MediaSourceInfo.cs @@ -54,7 +54,7 @@ namespace MediaBrowser.Model.Dto public List MediaStreams { get; set; } - public List Formats { get; set; } + public string[] Formats { get; set; } public int? Bitrate { get; set; } @@ -69,7 +69,7 @@ namespace MediaBrowser.Model.Dto public MediaSourceInfo() { - Formats = new List(); + Formats = new string[] { }; MediaStreams = new List(); RequiredHttpHeaders = new Dictionary(); SupportsTranscoding = true; diff --git a/MediaBrowser.Model/Dto/MetadataEditorInfo.cs b/MediaBrowser.Model/Dto/MetadataEditorInfo.cs index 9bd15fc8f..aa8b33c81 100644 --- a/MediaBrowser.Model/Dto/MetadataEditorInfo.cs +++ b/MediaBrowser.Model/Dto/MetadataEditorInfo.cs @@ -7,21 +7,21 @@ namespace MediaBrowser.Model.Dto { public class MetadataEditorInfo { - public List ParentalRatingOptions { get; set; } - public List Countries { get; set; } - public List Cultures { get; set; } - public List ExternalIdInfos { get; set; } + public ParentalRating[] ParentalRatingOptions { get; set; } + public CountryInfo[] Countries { get; set; } + public CultureDto[] Cultures { get; set; } + public ExternalIdInfo[] ExternalIdInfos { get; set; } public string ContentType { get; set; } - public List ContentTypeOptions { get; set; } + public NameValuePair[] ContentTypeOptions { get; set; } public MetadataEditorInfo() { - ParentalRatingOptions = new List(); - Countries = new List(); - Cultures = new List(); - ExternalIdInfos = new List(); - ContentTypeOptions = new List(); + ParentalRatingOptions = new ParentalRating[] { }; + Countries = new CountryInfo[] { }; + Cultures = new CultureDto[] { }; + ExternalIdInfos = new ExternalIdInfo[] { }; + ContentTypeOptions = new NameValuePair[] { }; } } } diff --git a/MediaBrowser.Model/Entities/LibraryUpdateInfo.cs b/MediaBrowser.Model/Entities/LibraryUpdateInfo.cs index 07a4b5f60..b3d3be70e 100644 --- a/MediaBrowser.Model/Entities/LibraryUpdateInfo.cs +++ b/MediaBrowser.Model/Entities/LibraryUpdateInfo.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; - + namespace MediaBrowser.Model.Entities { /// @@ -11,41 +10,41 @@ namespace MediaBrowser.Model.Entities /// Gets or sets the folders added to. /// /// The folders added to. - public List FoldersAddedTo { get; set; } + public string[] FoldersAddedTo { get; set; } /// /// Gets or sets the folders removed from. /// /// The folders removed from. - public List FoldersRemovedFrom { get; set; } + public string[] FoldersRemovedFrom { get; set; } /// /// Gets or sets the items added. /// /// The items added. - public List ItemsAdded { get; set; } + public string[] ItemsAdded { get; set; } /// /// Gets or sets the items removed. /// /// The items removed. - public List ItemsRemoved { get; set; } + public string[] ItemsRemoved { get; set; } /// /// Gets or sets the items updated. /// /// The items updated. - public List ItemsUpdated { get; set; } + public string[] ItemsUpdated { get; set; } /// /// Initializes a new instance of the class. /// public LibraryUpdateInfo() { - FoldersAddedTo = new List(); - FoldersRemovedFrom = new List(); - ItemsAdded = new List(); - ItemsRemoved = new List(); - ItemsUpdated = new List(); + FoldersAddedTo = new string[] { }; + FoldersRemovedFrom = new string[] { }; + ItemsAdded = new string[] { }; + ItemsRemoved = new string[] { }; + ItemsUpdated = new string[] { }; } } } diff --git a/MediaBrowser.Model/Entities/VirtualFolderInfo.cs b/MediaBrowser.Model/Entities/VirtualFolderInfo.cs index 374d8d028..901090717 100644 --- a/MediaBrowser.Model/Entities/VirtualFolderInfo.cs +++ b/MediaBrowser.Model/Entities/VirtualFolderInfo.cs @@ -18,7 +18,7 @@ namespace MediaBrowser.Model.Entities /// Gets or sets the locations. /// /// The locations. - public List Locations { get; set; } + public string[] Locations { get; set; } /// /// Gets or sets the type of the collection. @@ -33,7 +33,7 @@ namespace MediaBrowser.Model.Entities /// public VirtualFolderInfo() { - Locations = new List(); + Locations = new string[] { }; } /// diff --git a/MediaBrowser.Model/Extensions/ListHelper.cs b/MediaBrowser.Model/Extensions/ListHelper.cs index 741f07469..cfcb229c8 100644 --- a/MediaBrowser.Model/Extensions/ListHelper.cs +++ b/MediaBrowser.Model/Extensions/ListHelper.cs @@ -6,15 +6,6 @@ namespace MediaBrowser.Model.Extensions { public static class ListHelper { - public static bool ContainsIgnoreCase(List list, string value) - { - if (value == null) - { - throw new ArgumentNullException("value"); - } - - return list.Contains(value, StringComparer.OrdinalIgnoreCase); - } public static bool ContainsIgnoreCase(string[] list, string value) { if (value == null) diff --git a/MediaBrowser.Model/Globalization/ILocalizationManager.cs b/MediaBrowser.Model/Globalization/ILocalizationManager.cs index 47cec1459..2356a2fa1 100644 --- a/MediaBrowser.Model/Globalization/ILocalizationManager.cs +++ b/MediaBrowser.Model/Globalization/ILocalizationManager.cs @@ -12,17 +12,17 @@ namespace MediaBrowser.Model.Globalization /// Gets the cultures. /// /// IEnumerable{CultureDto}. - List GetCultures(); + CultureDto[] GetCultures(); /// /// Gets the countries. /// /// IEnumerable{CountryInfo}. - List GetCountries(); + CountryInfo[] GetCountries(); /// /// Gets the parental ratings. /// /// IEnumerable{ParentalRating}. - IEnumerable GetParentalRatings(); + ParentalRating[] GetParentalRatings(); /// /// Gets the rating level. /// @@ -49,7 +49,7 @@ namespace MediaBrowser.Model.Globalization /// Gets the localization options. /// /// IEnumerable{LocalizatonOption}. - IEnumerable GetLocalizationOptions(); + LocalizatonOption[] GetLocalizationOptions(); string RemoveDiacritics(string text); diff --git a/MediaBrowser.Model/Health/IHealthMonitor.cs b/MediaBrowser.Model/Health/IHealthMonitor.cs deleted file mode 100644 index a4f95c1bc..000000000 --- a/MediaBrowser.Model/Health/IHealthMonitor.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using MediaBrowser.Model.Notifications; - -namespace MediaBrowser.Model.Health -{ - public interface IHealthMonitor - { - Task> GetNotifications(CancellationToken cancellationToken); - } -} diff --git a/MediaBrowser.Model/LiveTv/BaseTimerInfoDto.cs b/MediaBrowser.Model/LiveTv/BaseTimerInfoDto.cs index 9d7fdd129..7c9fe0790 100644 --- a/MediaBrowser.Model/LiveTv/BaseTimerInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/BaseTimerInfoDto.cs @@ -113,7 +113,7 @@ namespace MediaBrowser.Model.LiveTv /// Gets or sets the parent backdrop image tags. /// /// The parent backdrop image tags. - public List ParentBackdropImageTags { get; set; } + public string[] ParentBackdropImageTags { get; set; } /// /// Gets or sets a value indicating whether this instance is post padding required. diff --git a/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs b/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs index a8ea86494..67e3d44da 100644 --- a/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs @@ -41,7 +41,7 @@ namespace MediaBrowser.Model.LiveTv /// Gets or sets the media sources. /// /// The media sources. - public List MediaSources { get; set; } + public MediaSourceInfo[] MediaSources { get; set; } /// /// Gets or sets the image tags. @@ -116,7 +116,7 @@ namespace MediaBrowser.Model.LiveTv public ChannelInfoDto() { ImageTags = new Dictionary(); - MediaSources = new List(); + MediaSources = new MediaSourceInfo[] { }; } } } diff --git a/MediaBrowser.Model/LiveTv/LiveTvInfo.cs b/MediaBrowser.Model/LiveTv/LiveTvInfo.cs index f4d3e21d9..4620fbf0c 100644 --- a/MediaBrowser.Model/LiveTv/LiveTvInfo.cs +++ b/MediaBrowser.Model/LiveTv/LiveTvInfo.cs @@ -8,7 +8,7 @@ namespace MediaBrowser.Model.LiveTv /// Gets or sets the services. /// /// The services. - public List Services { get; set; } + public LiveTvServiceInfo[] Services { get; set; } /// /// Gets or sets a value indicating whether this instance is enabled. @@ -20,12 +20,12 @@ namespace MediaBrowser.Model.LiveTv /// Gets or sets the enabled users. /// /// The enabled users. - public List EnabledUsers { get; set; } + public string[] EnabledUsers { get; set; } public LiveTvInfo() { - Services = new List(); - EnabledUsers = new List(); + Services = new LiveTvServiceInfo[] { }; + EnabledUsers = new string[] { }; } } } \ No newline at end of file diff --git a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs index a1df35b12..64b628a13 100644 --- a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs +++ b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs @@ -15,8 +15,8 @@ namespace MediaBrowser.Model.LiveTv public bool EnableOriginalAudioWithEncodedRecordings { get; set; } public string RecordedVideoCodec { get; set; } - public List TunerHosts { get; set; } - public List ListingProviders { get; set; } + public TunerHostInfo[] TunerHosts { get; set; } + public ListingsProviderInfo[] ListingProviders { get; set; } public int PrePaddingSeconds { get; set; } public int PostPaddingSeconds { get; set; } @@ -28,8 +28,8 @@ namespace MediaBrowser.Model.LiveTv public LiveTvOptions() { - TunerHosts = new List(); - ListingProviders = new List(); + TunerHosts = new TunerHostInfo[] { }; + ListingProviders = new ListingsProviderInfo[] { }; MediaLocationsCreated = new string[] { }; RecordingEncodingFormat = "mkv"; RecordingPostProcessorArguments = "\"{path}\""; diff --git a/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs b/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs index 25d3b289f..09ec4b931 100644 --- a/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs +++ b/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs @@ -48,11 +48,11 @@ namespace MediaBrowser.Model.LiveTv /// true if this instance is visible; otherwise, false. public bool IsVisible { get; set; } - public List Tuners { get; set; } + public LiveTvTunerInfoDto[] Tuners { get; set; } public LiveTvServiceInfo() { - Tuners = new List(); + Tuners = new LiveTvTunerInfoDto[] { }; } } } diff --git a/MediaBrowser.Model/LiveTv/LiveTvTunerInfoDto.cs b/MediaBrowser.Model/LiveTv/LiveTvTunerInfoDto.cs index 9af96df43..937cef057 100644 --- a/MediaBrowser.Model/LiveTv/LiveTvTunerInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/LiveTvTunerInfoDto.cs @@ -62,7 +62,7 @@ namespace MediaBrowser.Model.LiveTv /// Gets or sets the clients. /// /// The clients. - public List Clients { get; set; } + public string[] Clients { get; set; } /// /// Gets or sets a value indicating whether this instance can reset. @@ -72,7 +72,7 @@ namespace MediaBrowser.Model.LiveTv public LiveTvTunerInfoDto() { - Clients = new List(); + Clients = new string[] { }; } } } \ No newline at end of file diff --git a/MediaBrowser.Model/LiveTv/SeriesTimerInfoDto.cs b/MediaBrowser.Model/LiveTv/SeriesTimerInfoDto.cs index 388001287..743caa97e 100644 --- a/MediaBrowser.Model/LiveTv/SeriesTimerInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/SeriesTimerInfoDto.cs @@ -15,7 +15,7 @@ namespace MediaBrowser.Model.LiveTv public SeriesTimerInfoDto() { ImageTags = new Dictionary(); - Days = new List(); + Days = new DayOfWeek[] { }; Type = "SeriesTimer"; } @@ -45,7 +45,7 @@ namespace MediaBrowser.Model.LiveTv /// Gets or sets the days. /// /// The days. - public List Days { get; set; } + public DayOfWeek[] Days { get; set; } /// /// Gets or sets the day pattern. @@ -59,16 +59,6 @@ namespace MediaBrowser.Model.LiveTv /// The image tags. public Dictionary ImageTags { get; set; } - /// - /// Gets a value indicating whether this instance has primary image. - /// - /// true if this instance has primary image; otherwise, false. - [IgnoreDataMember] - public bool HasPrimaryImage - { - get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Primary); } - } - /// /// Gets or sets the parent thumb item id. /// diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 0e4cc0623..b36a773eb 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -111,7 +111,6 @@ - @@ -127,7 +126,6 @@ - @@ -413,7 +411,6 @@ - diff --git a/MediaBrowser.Model/MediaInfo/BlurayDiscInfo.cs b/MediaBrowser.Model/MediaInfo/BlurayDiscInfo.cs index 963e8dd95..1b573fba7 100644 --- a/MediaBrowser.Model/MediaInfo/BlurayDiscInfo.cs +++ b/MediaBrowser.Model/MediaInfo/BlurayDiscInfo.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Model.MediaInfo /// Gets or sets the media streams. /// /// The media streams. - public List MediaStreams { get; set; } + public MediaStream[] MediaStreams { get; set; } /// /// Gets or sets the run time ticks. @@ -24,7 +24,7 @@ namespace MediaBrowser.Model.MediaInfo /// Gets or sets the files. /// /// The files. - public List Files { get; set; } + public string[] Files { get; set; } public string PlaylistName { get; set; } @@ -32,6 +32,6 @@ namespace MediaBrowser.Model.MediaInfo /// Gets or sets the chapters. /// /// The chapters. - public List Chapters { get; set; } + public double[] Chapters { get; set; } } } diff --git a/MediaBrowser.Model/MediaInfo/MediaInfo.cs b/MediaBrowser.Model/MediaInfo/MediaInfo.cs index 691dcc6c8..63b1c9cfd 100644 --- a/MediaBrowser.Model/MediaInfo/MediaInfo.cs +++ b/MediaBrowser.Model/MediaInfo/MediaInfo.cs @@ -9,7 +9,7 @@ namespace MediaBrowser.Model.MediaInfo { private static readonly string[] EmptyStringArray = new string[] { }; - public List Chapters { get; set; } + public ChapterInfo[] Chapters { get; set; } /// /// Gets or sets the album. @@ -20,7 +20,7 @@ namespace MediaBrowser.Model.MediaInfo /// Gets or sets the artists. /// /// The artists. - public List Artists { get; set; } + public string[] Artists { get; set; } /// /// Gets or sets the album artists. /// @@ -30,13 +30,13 @@ namespace MediaBrowser.Model.MediaInfo /// Gets or sets the studios. /// /// The studios. - public List Studios { get; set; } - public List Genres { get; set; } + public string[] Studios { get; set; } + public string[] Genres { get; set; } public int? IndexNumber { get; set; } public int? ParentIndexNumber { get; set; } public int? ProductionYear { get; set; } public DateTime? PremiereDate { get; set; } - public List People { get; set; } + public BaseItemPerson[] People { get; set; } public Dictionary ProviderIds { get; set; } /// /// Gets or sets the official rating. @@ -56,12 +56,12 @@ namespace MediaBrowser.Model.MediaInfo public MediaInfo() { - Chapters = new List(); - Artists = new List(); + Chapters = new ChapterInfo[] { }; + Artists = new string[] { }; AlbumArtists = EmptyStringArray; - Studios = new List(); - Genres = new List(); - People = new List(); + Studios = new string[] { }; + Genres = new string[] { }; + People = new BaseItemPerson[] { }; ProviderIds = new Dictionary(StringComparer.OrdinalIgnoreCase); } } diff --git a/MediaBrowser.Model/MediaInfo/PlaybackInfoResponse.cs b/MediaBrowser.Model/MediaInfo/PlaybackInfoResponse.cs index 1f8936d01..b38fec7d4 100644 --- a/MediaBrowser.Model/MediaInfo/PlaybackInfoResponse.cs +++ b/MediaBrowser.Model/MediaInfo/PlaybackInfoResponse.cs @@ -10,7 +10,7 @@ namespace MediaBrowser.Model.MediaInfo /// Gets or sets the media sources. /// /// The media sources. - public List MediaSources { get; set; } + public MediaSourceInfo[] MediaSources { get; set; } /// /// Gets or sets the play session identifier. @@ -26,7 +26,7 @@ namespace MediaBrowser.Model.MediaInfo public PlaybackInfoResponse() { - MediaSources = new List(); + MediaSources = new MediaSourceInfo[] { }; } } } diff --git a/MediaBrowser.Model/MediaInfo/SubtitleTrackInfo.cs b/MediaBrowser.Model/MediaInfo/SubtitleTrackInfo.cs index 765cfe32f..d3a3bb1d0 100644 --- a/MediaBrowser.Model/MediaInfo/SubtitleTrackInfo.cs +++ b/MediaBrowser.Model/MediaInfo/SubtitleTrackInfo.cs @@ -4,11 +4,11 @@ namespace MediaBrowser.Model.MediaInfo { public class SubtitleTrackInfo { - public List TrackEvents { get; set; } + public SubtitleTrackEvent[] TrackEvents { get; set; } public SubtitleTrackInfo() { - TrackEvents = new List(); + TrackEvents = new SubtitleTrackEvent[] { }; } } } diff --git a/MediaBrowser.Model/Net/MimeTypes.cs b/MediaBrowser.Model/Net/MimeTypes.cs index 7a2e1f215..c4dfd25ca 100644 --- a/MediaBrowser.Model/Net/MimeTypes.cs +++ b/MediaBrowser.Model/Net/MimeTypes.cs @@ -14,7 +14,7 @@ namespace MediaBrowser.Model.Net /// /// Any extension in this list is considered a video file - can be added to at runtime for extensibility /// - private static readonly List VideoFileExtensions = new List + private static readonly string[] VideoFileExtensions = new string[] { ".mkv", ".m2t", diff --git a/MediaBrowser.Model/Notifications/NotificationTypeInfo.cs b/MediaBrowser.Model/Notifications/NotificationTypeInfo.cs index 59b39fbc7..ee5101011 100644 --- a/MediaBrowser.Model/Notifications/NotificationTypeInfo.cs +++ b/MediaBrowser.Model/Notifications/NotificationTypeInfo.cs @@ -18,11 +18,11 @@ namespace MediaBrowser.Model.Notifications public string DefaultDescription { get; set; } - public List Variables { get; set; } + public string[] Variables { get; set; } public NotificationTypeInfo() { - Variables = new List(); + Variables = new string[] { }; } } } \ No newline at end of file diff --git a/MediaBrowser.Model/Playlists/PlaylistCreationRequest.cs b/MediaBrowser.Model/Playlists/PlaylistCreationRequest.cs index 63deb19dc..5314e791a 100644 --- a/MediaBrowser.Model/Playlists/PlaylistCreationRequest.cs +++ b/MediaBrowser.Model/Playlists/PlaylistCreationRequest.cs @@ -6,7 +6,7 @@ namespace MediaBrowser.Model.Playlists { public string Name { get; set; } - public List ItemIdList { get; set; } + public string[] ItemIdList { get; set; } public string MediaType { get; set; } @@ -14,7 +14,7 @@ namespace MediaBrowser.Model.Playlists public PlaylistCreationRequest() { - ItemIdList = new List(); + ItemIdList = new string[] { }; } } } diff --git a/MediaBrowser.Model/Providers/ImageProviderInfo.cs b/MediaBrowser.Model/Providers/ImageProviderInfo.cs index c519d66cb..199552640 100644 --- a/MediaBrowser.Model/Providers/ImageProviderInfo.cs +++ b/MediaBrowser.Model/Providers/ImageProviderInfo.cs @@ -14,11 +14,11 @@ namespace MediaBrowser.Model.Providers /// The name. public string Name { get; set; } - public List SupportedImages { get; set; } + public ImageType[] SupportedImages { get; set; } public ImageProviderInfo() { - SupportedImages = new List(); + SupportedImages = new ImageType[] { }; } } } diff --git a/MediaBrowser.Model/Providers/RemoteImageResult.cs b/MediaBrowser.Model/Providers/RemoteImageResult.cs index 1c60db6ae..7e38badfc 100644 --- a/MediaBrowser.Model/Providers/RemoteImageResult.cs +++ b/MediaBrowser.Model/Providers/RemoteImageResult.cs @@ -11,7 +11,7 @@ namespace MediaBrowser.Model.Providers /// Gets or sets the images. /// /// The images. - public List Images { get; set; } + public RemoteImageInfo[] Images { get; set; } /// /// Gets or sets the total record count. @@ -23,6 +23,6 @@ namespace MediaBrowser.Model.Providers /// Gets or sets the providers. /// /// The providers. - public List Providers { get; set; } + public string[] Providers { get; set; } } } diff --git a/MediaBrowser.Model/Querying/ItemsResult.cs b/MediaBrowser.Model/Querying/ItemsResult.cs deleted file mode 100644 index 3b9c59733..000000000 --- a/MediaBrowser.Model/Querying/ItemsResult.cs +++ /dev/null @@ -1,11 +0,0 @@ -using MediaBrowser.Model.Dto; - -namespace MediaBrowser.Model.Querying -{ - /// - /// Represents the result of a query for items - /// - public class ItemsResult : QueryResult - { - } -} diff --git a/MediaBrowser.Model/Querying/QueryResult.cs b/MediaBrowser.Model/Querying/QueryResult.cs index 1ecc1de6c..6f9923d08 100644 --- a/MediaBrowser.Model/Querying/QueryResult.cs +++ b/MediaBrowser.Model/Querying/QueryResult.cs @@ -15,9 +15,6 @@ namespace MediaBrowser.Model.Querying /// The total record count. public int TotalRecordCount { get; set; } - /// - /// Initializes a new instance of the class. - /// public QueryResult() { Items = new T[] { }; diff --git a/MediaBrowser.Model/Querying/ThemeMediaResult.cs b/MediaBrowser.Model/Querying/ThemeMediaResult.cs index 80478a910..0d7eb502f 100644 --- a/MediaBrowser.Model/Querying/ThemeMediaResult.cs +++ b/MediaBrowser.Model/Querying/ThemeMediaResult.cs @@ -1,10 +1,11 @@ - +using MediaBrowser.Model.Dto; + namespace MediaBrowser.Model.Querying { /// /// Class ThemeMediaResult /// - public class ThemeMediaResult : ItemsResult + public class ThemeMediaResult : QueryResult { /// /// Gets or sets the owner id. diff --git a/MediaBrowser.Model/Session/ClientCapabilities.cs b/MediaBrowser.Model/Session/ClientCapabilities.cs index 222c1bd64..9ae1fae9f 100644 --- a/MediaBrowser.Model/Session/ClientCapabilities.cs +++ b/MediaBrowser.Model/Session/ClientCapabilities.cs @@ -5,9 +5,9 @@ namespace MediaBrowser.Model.Session { public class ClientCapabilities { - public List PlayableMediaTypes { get; set; } + public string[] PlayableMediaTypes { get; set; } - public List SupportedCommands { get; set; } + public string[] SupportedCommands { get; set; } public bool SupportsMediaControl { get; set; } public bool SupportsContentUploading { get; set; } @@ -17,17 +17,17 @@ namespace MediaBrowser.Model.Session public bool SupportsSync { get; set; } public DeviceProfile DeviceProfile { get; set; } - public List SupportedLiveMediaTypes { get; set; } + public string[] SupportedLiveMediaTypes { get; set; } public string AppStoreUrl { get; set; } public string IconUrl { get; set; } public ClientCapabilities() { - PlayableMediaTypes = new List(); - SupportedCommands = new List(); + PlayableMediaTypes = new string[] { }; + SupportedCommands = new string[] { }; SupportsPersistentIdentifier = true; - SupportedLiveMediaTypes = new List(); + SupportedLiveMediaTypes = new string[] { }; } } } \ No newline at end of file diff --git a/MediaBrowser.Model/Session/SessionInfoDto.cs b/MediaBrowser.Model/Session/SessionInfoDto.cs index 3081d7ee3..78ee72f61 100644 --- a/MediaBrowser.Model/Session/SessionInfoDto.cs +++ b/MediaBrowser.Model/Session/SessionInfoDto.cs @@ -12,13 +12,13 @@ namespace MediaBrowser.Model.Session /// Gets or sets the supported commands. /// /// The supported commands. - public List SupportedCommands { get; set; } + public string[] SupportedCommands { get; set; } /// /// Gets or sets the playable media types. /// /// The playable media types. - public List PlayableMediaTypes { get; set; } + public string[] PlayableMediaTypes { get; set; } /// /// Gets or sets the id. @@ -50,7 +50,7 @@ namespace MediaBrowser.Model.Session /// Gets or sets the additional users present. /// /// The additional users present. - public List AdditionalUsers { get; set; } + public SessionUserInfo[] AdditionalUsers { get; set; } /// /// Gets or sets the application version. @@ -112,10 +112,10 @@ namespace MediaBrowser.Model.Session public SessionInfoDto() { - AdditionalUsers = new List(); + AdditionalUsers = new SessionUserInfo[] { }; - PlayableMediaTypes = new List(); - SupportedCommands = new List(); + PlayableMediaTypes = new string[] { }; + SupportedCommands = new string[] { }; } } } diff --git a/MediaBrowser.Model/Session/TranscodingInfo.cs b/MediaBrowser.Model/Session/TranscodingInfo.cs index f58e605b2..70c299bc2 100644 --- a/MediaBrowser.Model/Session/TranscodingInfo.cs +++ b/MediaBrowser.Model/Session/TranscodingInfo.cs @@ -18,11 +18,11 @@ namespace MediaBrowser.Model.Session public int? Height { get; set; } public int? AudioChannels { get; set; } - public List TranscodeReasons { get; set; } + public TranscodeReason[] TranscodeReasons { get; set; } public TranscodingInfo() { - TranscodeReasons = new List(); + TranscodeReasons = new TranscodeReason[] { }; } } diff --git a/MediaBrowser.Model/Session/UserDataChangeInfo.cs b/MediaBrowser.Model/Session/UserDataChangeInfo.cs index f92f44586..c6b03200d 100644 --- a/MediaBrowser.Model/Session/UserDataChangeInfo.cs +++ b/MediaBrowser.Model/Session/UserDataChangeInfo.cs @@ -18,6 +18,6 @@ namespace MediaBrowser.Model.Session /// Gets or sets the user data list. /// /// The user data list. - public List UserDataList { get; set; } + public UserItemDataDto[] UserDataList { get; set; } } } diff --git a/MediaBrowser.Model/Sync/CompleteSyncJobInfo.cs b/MediaBrowser.Model/Sync/CompleteSyncJobInfo.cs index 52d3fab3c..adfb84b05 100644 --- a/MediaBrowser.Model/Sync/CompleteSyncJobInfo.cs +++ b/MediaBrowser.Model/Sync/CompleteSyncJobInfo.cs @@ -5,11 +5,11 @@ namespace MediaBrowser.Model.Sync public class CompleteSyncJobInfo { public SyncJob Job { get; set; } - public List JobItems { get; set; } + public SyncJobItem[] JobItems { get; set; } public CompleteSyncJobInfo() { - JobItems = new List(); + JobItems = new SyncJobItem[] { }; } } } diff --git a/MediaBrowser.Model/Sync/LocalItem.cs b/MediaBrowser.Model/Sync/LocalItem.cs index c5728ac97..3d625aa99 100644 --- a/MediaBrowser.Model/Sync/LocalItem.cs +++ b/MediaBrowser.Model/Sync/LocalItem.cs @@ -44,17 +44,17 @@ namespace MediaBrowser.Model.Sync /// Gets or sets the user ids with access. /// /// The user ids with access. - public List UserIdsWithAccess { get; set; } + public string[] UserIdsWithAccess { get; set; } /// /// Gets or sets the additional files. /// /// The additional files. - public List AdditionalFiles { get; set; } + public string[] AdditionalFiles { get; set; } public LocalItem() { - AdditionalFiles = new List(); - UserIdsWithAccess = new List(); + AdditionalFiles = new string[] { }; + UserIdsWithAccess = new string[] { }; } } } diff --git a/MediaBrowser.Model/Sync/SyncDataRequest.cs b/MediaBrowser.Model/Sync/SyncDataRequest.cs index 0df4de86d..c0941caee 100644 --- a/MediaBrowser.Model/Sync/SyncDataRequest.cs +++ b/MediaBrowser.Model/Sync/SyncDataRequest.cs @@ -4,16 +4,16 @@ namespace MediaBrowser.Model.Sync { public class SyncDataRequest { - public List LocalItemIds { get; set; } - public List OfflineUserIds { get; set; } - public List SyncJobItemIds { get; set; } + public string[] LocalItemIds { get; set; } + public string[] OfflineUserIds { get; set; } + public string[] SyncJobItemIds { get; set; } public string TargetId { get; set; } public SyncDataRequest() { - LocalItemIds = new List(); - OfflineUserIds = new List(); + LocalItemIds = new string[] { }; + OfflineUserIds = new string[] { }; } } } diff --git a/MediaBrowser.Model/Sync/SyncDataResponse.cs b/MediaBrowser.Model/Sync/SyncDataResponse.cs index 3799e9455..0b017af6e 100644 --- a/MediaBrowser.Model/Sync/SyncDataResponse.cs +++ b/MediaBrowser.Model/Sync/SyncDataResponse.cs @@ -1,16 +1,13 @@ -using System.Collections.Generic; - + namespace MediaBrowser.Model.Sync { public class SyncDataResponse { - public List ItemIdsToRemove { get; set; } - public Dictionary> ItemUserAccess { get; set; } + public string[] ItemIdsToRemove { get; set; } public SyncDataResponse() { - ItemIdsToRemove = new List(); - ItemUserAccess = new Dictionary>(); + ItemIdsToRemove = new string[] { }; } } } diff --git a/MediaBrowser.Model/Sync/SyncDialogOptions.cs b/MediaBrowser.Model/Sync/SyncDialogOptions.cs index a987a6cd6..e55ca4f08 100644 --- a/MediaBrowser.Model/Sync/SyncDialogOptions.cs +++ b/MediaBrowser.Model/Sync/SyncDialogOptions.cs @@ -8,29 +8,29 @@ namespace MediaBrowser.Model.Sync /// Gets or sets the targets. /// /// The targets. - public List Targets { get; set; } + public SyncTarget[] Targets { get; set; } /// /// Gets or sets the options. /// /// The options. - public List Options { get; set; } + public SyncJobOption[] Options { get; set; } /// /// Gets or sets the quality options. /// /// The quality options. - public List QualityOptions { get; set; } + public SyncQualityOption[] QualityOptions { get; set; } /// /// Gets or sets the profile options. /// /// The profile options. - public List ProfileOptions { get; set; } + public SyncProfileOption[] ProfileOptions { get; set; } public SyncDialogOptions() { - Targets = new List(); - Options = new List(); - QualityOptions = new List(); - ProfileOptions = new List(); + Targets = new SyncTarget[] { }; + Options = new SyncJobOption[] { }; + QualityOptions = new SyncQualityOption[] { }; + ProfileOptions = new SyncProfileOption[] { }; } } } diff --git a/MediaBrowser.Model/Sync/SyncJob.cs b/MediaBrowser.Model/Sync/SyncJob.cs index eb153427c..e8b698f62 100644 --- a/MediaBrowser.Model/Sync/SyncJob.cs +++ b/MediaBrowser.Model/Sync/SyncJob.cs @@ -84,7 +84,7 @@ namespace MediaBrowser.Model.Sync /// Gets or sets the requested item ids. /// /// The requested item ids. - public List RequestedItemIds { get; set; } + public string[] RequestedItemIds { get; set; } /// /// Gets or sets the date created. /// @@ -107,7 +107,7 @@ namespace MediaBrowser.Model.Sync public SyncJob() { - RequestedItemIds = new List(); + RequestedItemIds = new string[] { }; } } } diff --git a/MediaBrowser.Model/Sync/SyncJobCreationResult.cs b/MediaBrowser.Model/Sync/SyncJobCreationResult.cs index 6723aa2cf..ee46bc155 100644 --- a/MediaBrowser.Model/Sync/SyncJobCreationResult.cs +++ b/MediaBrowser.Model/Sync/SyncJobCreationResult.cs @@ -5,11 +5,11 @@ namespace MediaBrowser.Model.Sync public class SyncJobCreationResult { public SyncJob Job { get; set; } - public List JobItems { get; set; } + public SyncJobItem[] JobItems { get; set; } public SyncJobCreationResult() { - JobItems = new List(); + JobItems = new SyncJobItem[] { }; } } } diff --git a/MediaBrowser.Model/Sync/SyncJobItem.cs b/MediaBrowser.Model/Sync/SyncJobItem.cs index 9fb275823..5a97bc92e 100644 --- a/MediaBrowser.Model/Sync/SyncJobItem.cs +++ b/MediaBrowser.Model/Sync/SyncJobItem.cs @@ -90,7 +90,7 @@ namespace MediaBrowser.Model.Sync /// Gets or sets the additional files. /// /// The additional files. - public List AdditionalFiles { get; set; } + public ItemFileInfo[] AdditionalFiles { get; set; } /// /// Gets or sets the index of the job item. /// @@ -101,7 +101,7 @@ namespace MediaBrowser.Model.Sync public SyncJobItem() { - AdditionalFiles = new List(); + AdditionalFiles = new ItemFileInfo[] { }; } } } diff --git a/MediaBrowser.Model/Sync/SyncJobRequest.cs b/MediaBrowser.Model/Sync/SyncJobRequest.cs index a96c86ed9..3dc863b75 100644 --- a/MediaBrowser.Model/Sync/SyncJobRequest.cs +++ b/MediaBrowser.Model/Sync/SyncJobRequest.cs @@ -13,7 +13,7 @@ namespace MediaBrowser.Model.Sync /// Gets or sets the item ids. /// /// The item ids. - public List ItemIds { get; set; } + public string[] ItemIds { get; set; } /// /// Gets or sets the category. /// @@ -67,7 +67,7 @@ namespace MediaBrowser.Model.Sync public SyncJobRequest() { - ItemIds = new List(); + ItemIds = new string[] { }; SyncNewContent = true; } } diff --git a/MediaBrowser.Model/Sync/SyncedItem.cs b/MediaBrowser.Model/Sync/SyncedItem.cs index 4dedcfd2d..68bd8a2eb 100644 --- a/MediaBrowser.Model/Sync/SyncedItem.cs +++ b/MediaBrowser.Model/Sync/SyncedItem.cs @@ -50,11 +50,11 @@ namespace MediaBrowser.Model.Sync /// Gets or sets the additional files. /// /// The additional files. - public List AdditionalFiles { get; set; } + public ItemFileInfo[] AdditionalFiles { get; set; } public SyncedItem() { - AdditionalFiles = new List(); + AdditionalFiles = new ItemFileInfo[] { }; } } } diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs index 4154093cb..fce9dea4f 100644 --- a/MediaBrowser.Model/System/SystemInfo.cs +++ b/MediaBrowser.Model/System/SystemInfo.cs @@ -46,7 +46,7 @@ namespace MediaBrowser.Model.System /// Gets or sets the in progress installations. /// /// The in progress installations. - public List InProgressInstallations { get; set; } + public InstallationInfo[] InProgressInstallations { get; set; } /// /// Gets or sets the web socket port number. @@ -58,7 +58,7 @@ namespace MediaBrowser.Model.System /// Gets or sets the completed installations. /// /// The completed installations. - public List CompletedInstallations { get; set; } + public InstallationInfo[] CompletedInstallations { get; set; } /// /// Gets or sets a value indicating whether this instance can self restart. @@ -76,7 +76,7 @@ namespace MediaBrowser.Model.System /// Gets or sets plugin assemblies that failed to load. /// /// The failed assembly loads. - public List FailedPluginAssemblies { get; set; } + public string[] FailedPluginAssemblies { get; set; } /// /// Gets or sets the program data path. @@ -153,11 +153,11 @@ namespace MediaBrowser.Model.System /// public SystemInfo() { - InProgressInstallations = new List(); + InProgressInstallations = new InstallationInfo[] { }; - CompletedInstallations = new List(); + CompletedInstallations = new InstallationInfo[] { }; - FailedPluginAssemblies = new List(); + FailedPluginAssemblies = new string[] { }; } } } diff --git a/MediaBrowser.Model/Updates/PackageInfo.cs b/MediaBrowser.Model/Updates/PackageInfo.cs index 208d5b784..e46d59fc0 100644 --- a/MediaBrowser.Model/Updates/PackageInfo.cs +++ b/MediaBrowser.Model/Updates/PackageInfo.cs @@ -151,7 +151,7 @@ namespace MediaBrowser.Model.Updates /// Gets or sets the versions. /// /// The versions. - public List versions { get; set; } + public PackageVersionInfo[] versions { get; set; } /// /// Gets or sets a value indicating whether [enable in application store]. @@ -170,7 +170,7 @@ namespace MediaBrowser.Model.Updates /// public PackageInfo() { - versions = new List(); + versions = new PackageVersionInfo[] { }; } } } diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs index 139bd6d58..d249b6b00 100644 --- a/MediaBrowser.Providers/Manager/ProviderManager.cs +++ b/MediaBrowser.Providers/Manager/ProviderManager.cs @@ -24,6 +24,7 @@ using MediaBrowser.Controller.Dto; using MediaBrowser.Model.Events; using MediaBrowser.Model.Serialization; using Priority_Queue; +using MediaBrowser.Model.Extensions; namespace MediaBrowser.Providers.Manager { @@ -235,7 +236,7 @@ namespace MediaBrowser.Providers.Manager return GetRemoteImageProviders(item, true).Select(i => new ImageProviderInfo { Name = i.Name, - SupportedImages = i.GetSupportedImages(item).ToList() + SupportedImages = i.GetSupportedImages(item).ToArray() }); } @@ -435,9 +436,9 @@ namespace MediaBrowser.Providers.Manager return 0; } - public IEnumerable GetAllMetadataPlugins() + public MetadataPluginSummary[] GetAllMetadataPlugins() { - var list = new List + return new MetadataPluginSummary[] { GetPluginSummary(), GetPluginSummary(), @@ -462,8 +463,6 @@ namespace MediaBrowser.Providers.Manager GetPluginSummary(), GetPluginSummary() }; - - return list; } private MetadataPluginSummary GetPluginSummary() @@ -485,8 +484,12 @@ namespace MediaBrowser.Providers.Manager var imageProviders = GetImageProviders(dummy, options, new ImageRefreshOptions(new DirectoryService(_logger, _fileSystem)), true).ToList(); - AddMetadataPlugins(summary.Plugins, dummy, options); - AddImagePlugins(summary.Plugins, dummy, imageProviders); + var pluginList = summary.Plugins.ToList(); + + AddMetadataPlugins(pluginList, dummy, options); + AddImagePlugins(pluginList, dummy, imageProviders); + + summary.Plugins = pluginList.ToArray(pluginList.Count); var supportedImageTypes = imageProviders.OfType() .SelectMany(i => i.GetSupportedImages(dummy)) @@ -495,7 +498,7 @@ namespace MediaBrowser.Providers.Manager supportedImageTypes.AddRange(imageProviders.OfType() .SelectMany(i => i.GetSupportedImages(dummy))); - summary.SupportedImageTypes = supportedImageTypes.Distinct().ToList(); + summary.SupportedImageTypes = supportedImageTypes.Distinct().ToArray(); return summary; } diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs index b0785298b..fb1fed8b3 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs @@ -141,7 +141,7 @@ namespace MediaBrowser.Providers.MediaInfo } audio.Album = data.Album; - audio.Artists = data.Artists; + audio.Artists = data.Artists.ToList(); audio.AlbumArtists = data.AlbumArtists; audio.IndexNumber = data.IndexNumber; audio.ParentIndexNumber = data.ParentIndexNumber; diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index 791a5c57b..ea8d7bdb0 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs @@ -80,7 +80,7 @@ namespace MediaBrowser.Providers.MediaInfo try { - List streamFileNames = null; + string[] streamFileNames = null; if (item.VideoType == VideoType.Iso) { @@ -91,7 +91,7 @@ namespace MediaBrowser.Providers.MediaInfo { streamFileNames = FetchFromDvdLib(item, isoMount); - if (streamFileNames.Count == 0) + if (streamFileNames.Length == 0) { _logger.Error("No playable vobs found in dvd structure, skipping ffprobe."); return ItemUpdateType.MetadataImport; @@ -106,7 +106,7 @@ namespace MediaBrowser.Providers.MediaInfo streamFileNames = blurayDiscInfo.Files; - if (streamFileNames.Count == 0) + if (streamFileNames.Length == 0) { _logger.Error("No playable vobs found in bluray structure, skipping ffprobe."); return ItemUpdateType.MetadataImport; @@ -115,7 +115,7 @@ namespace MediaBrowser.Providers.MediaInfo if (streamFileNames == null) { - streamFileNames = new List(); + streamFileNames = new string[] { }; } var result = await GetMediaInfo(item, isoMount, streamFileNames, cancellationToken).ConfigureAwait(false); @@ -138,7 +138,7 @@ namespace MediaBrowser.Providers.MediaInfo private Task GetMediaInfo(Video item, IIsoMount isoMount, - List streamFileNames, + string[] streamFileNames, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); @@ -193,7 +193,7 @@ namespace MediaBrowser.Providers.MediaInfo } video.Container = mediaInfo.Container; - var chapters = mediaInfo.Chapters ?? new List(); + var chapters = mediaInfo.Chapters == null ? new List() : mediaInfo.Chapters.ToList(); if (blurayInfo != null) { FetchBdInfo(video, chapters, mediaStreams, blurayInfo); @@ -266,7 +266,7 @@ namespace MediaBrowser.Providers.MediaInfo //video.PlayableStreamFileNames = blurayInfo.Files.ToList(); // Use BD Info if it has multiple m2ts. Otherwise, treat it like a video file and rely more on ffprobe output - if (blurayInfo.Files.Count > 1) + if (blurayInfo.Files.Length > 1) { int? currentHeight = null; int? currentWidth = null; @@ -551,7 +551,7 @@ namespace MediaBrowser.Providers.MediaInfo } } - private List FetchFromDvdLib(Video item, IIsoMount mount) + private string[] FetchFromDvdLib(Video item, IIsoMount mount) { var path = mount == null ? item.Path : mount.MountedPath; var dvd = new Dvd(path, _fileSystem); @@ -568,7 +568,7 @@ namespace MediaBrowser.Providers.MediaInfo return GetPrimaryPlaylistVobFiles(item, mount, titleNumber) .Select(Path.GetFileName) - .ToList(); + .ToArray(); } private long GetRuntime(Title title) diff --git a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs index fce95364e..fe655759e 100644 --- a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs +++ b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs @@ -48,12 +48,12 @@ namespace MediaBrowser.Providers.Subtitles _subtitleProviders = subtitleProviders.ToArray(); } - public async Task> SearchSubtitles(SubtitleSearchRequest request, CancellationToken cancellationToken) + public async Task SearchSubtitles(SubtitleSearchRequest request, CancellationToken cancellationToken) { var contentType = request.ContentType; var providers = _subtitleProviders .Where(i => i.SupportedMediaTypes.Contains(contentType)) - .ToList(); + .ToArray(); // If not searching all, search one at a time until something is found if (!request.SearchAllProviders) @@ -64,9 +64,9 @@ namespace MediaBrowser.Providers.Subtitles { var searchResults = await provider.Search(request, cancellationToken).ConfigureAwait(false); - var list = searchResults.ToList(); + var list = searchResults.ToArray(); - if (list.Count > 0) + if (list.Length > 0) { Normalize(list); return list; @@ -77,7 +77,7 @@ namespace MediaBrowser.Providers.Subtitles _logger.ErrorException("Error downloading subtitles from {0}", ex, provider.Name); } } - return new List(); + return new RemoteSubtitleInfo[] { }; } var tasks = providers.Select(async i => @@ -86,20 +86,20 @@ namespace MediaBrowser.Providers.Subtitles { var searchResults = await i.Search(request, cancellationToken).ConfigureAwait(false); - var list = searchResults.ToList(); + var list = searchResults.ToArray(); Normalize(list); return list; } catch (Exception ex) { _logger.ErrorException("Error downloading subtitles from {0}", ex, i.Name); - return new List(); + return new RemoteSubtitleInfo[] { }; } }); var results = await Task.WhenAll(tasks).ConfigureAwait(false); - return results.SelectMany(i => i); + return results.SelectMany(i => i).ToArray(); } public async Task DownloadSubtitles(Video video, @@ -173,12 +173,12 @@ namespace MediaBrowser.Providers.Subtitles } } - public Task> SearchSubtitles(Video video, string language, bool? isPerfectMatch, CancellationToken cancellationToken) + public Task SearchSubtitles(Video video, string language, bool? isPerfectMatch, CancellationToken cancellationToken) { if (video.LocationType != LocationType.FileSystem || video.VideoType != VideoType.VideoFile) { - return Task.FromResult>(new List()); + return Task.FromResult(new RemoteSubtitleInfo[] { }); } VideoContentType mediaType; @@ -194,7 +194,7 @@ namespace MediaBrowser.Providers.Subtitles else { // These are the only supported types - return Task.FromResult>(new List()); + return Task.FromResult(new RemoteSubtitleInfo[] { }); } var request = new SubtitleSearchRequest @@ -275,7 +275,7 @@ namespace MediaBrowser.Providers.Subtitles return provider.GetSubtitles(id, cancellationToken); } - public IEnumerable GetProviders(string itemId) + public SubtitleProviderInfo[] GetProviders(string itemId) { var video = _libraryManager.GetItemById(itemId) as Video; VideoContentType mediaType; @@ -291,17 +291,17 @@ namespace MediaBrowser.Providers.Subtitles else { // These are the only supported types - return new List(); + return new SubtitleProviderInfo[] { }; } - var providers = _subtitleProviders - .Where(i => i.SupportedMediaTypes.Contains(mediaType)); + return _subtitleProviders + .Where(i => i.SupportedMediaTypes.Contains(mediaType)) + .Select(i => new SubtitleProviderInfo + { + Name = i.Name, + Id = GetProviderId(i.Name) - return providers.Select(i => new SubtitleProviderInfo - { - Name = i.Name, - Id = GetProviderId(i.Name) - }); + }).ToArray(); } } diff --git a/MediaBrowser.Providers/TV/SeasonMetadataService.cs b/MediaBrowser.Providers/TV/SeasonMetadataService.cs index c10b0ef9d..7cd408791 100644 --- a/MediaBrowser.Providers/TV/SeasonMetadataService.cs +++ b/MediaBrowser.Providers/TV/SeasonMetadataService.cs @@ -9,7 +9,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; - +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; @@ -32,7 +32,7 @@ namespace MediaBrowser.Providers.TV if (isFullRefresh || currentUpdateType > ItemUpdateType.None) { - var episodes = item.GetEpisodes().ToList(); + var episodes = item.GetEpisodes(); updateType |= SavePremiereDate(item, episodes); updateType |= SaveIsVirtualItem(item, episodes); } @@ -66,7 +66,7 @@ namespace MediaBrowser.Providers.TV ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings); } - private ItemUpdateType SavePremiereDate(Season item, List episodes) + private ItemUpdateType SavePremiereDate(Season item, List episodes) { var dates = episodes.Where(i => i.PremiereDate.HasValue).Select(i => i.PremiereDate.Value).ToList(); @@ -86,7 +86,7 @@ namespace MediaBrowser.Providers.TV return ItemUpdateType.None; } - private ItemUpdateType SaveIsVirtualItem(Season item, List episodes) + private ItemUpdateType SaveIsVirtualItem(Season item, List episodes) { var isVirtualItem = item.LocationType == LocationType.Virtual && (episodes.Count == 0 || episodes.All(i => i.LocationType == LocationType.Virtual)); diff --git a/MediaBrowser.Tests/MediaEncoding/Subtitles/AssParserTests.cs b/MediaBrowser.Tests/MediaEncoding/Subtitles/AssParserTests.cs index 47f5891c6..dde9f2fe2 100644 --- a/MediaBrowser.Tests/MediaEncoding/Subtitles/AssParserTests.cs +++ b/MediaBrowser.Tests/MediaEncoding/Subtitles/AssParserTests.cs @@ -17,7 +17,7 @@ namespace MediaBrowser.Tests.MediaEncoding.Subtitles { var expectedSubs = new SubtitleTrackInfo { - TrackEvents = new List { + TrackEvents = new SubtitleTrackEvent[] { new SubtitleTrackEvent { Id = "1", StartPositionTicks = 24000000, @@ -48,8 +48,8 @@ namespace MediaBrowser.Tests.MediaEncoding.Subtitles { var result = sut.Parse(stream, CancellationToken.None); Assert.IsNotNull(result); - Assert.AreEqual(expectedSubs.TrackEvents.Count,result.TrackEvents.Count); - for (int i = 0; i < expectedSubs.TrackEvents.Count; i++) + Assert.AreEqual(expectedSubs.TrackEvents.Length,result.TrackEvents.Length); + for (int i = 0; i < expectedSubs.TrackEvents.Length; i++) { Assert.AreEqual(expectedSubs.TrackEvents[i].Id, result.TrackEvents[i].Id); Assert.AreEqual(expectedSubs.TrackEvents[i].StartPositionTicks, result.TrackEvents[i].StartPositionTicks); diff --git a/MediaBrowser.Tests/MediaEncoding/Subtitles/SrtParserTests.cs b/MediaBrowser.Tests/MediaEncoding/Subtitles/SrtParserTests.cs index 280dc5d78..8acc490e7 100644 --- a/MediaBrowser.Tests/MediaEncoding/Subtitles/SrtParserTests.cs +++ b/MediaBrowser.Tests/MediaEncoding/Subtitles/SrtParserTests.cs @@ -20,7 +20,7 @@ namespace MediaBrowser.Tests.MediaEncoding.Subtitles var expectedSubs = new SubtitleTrackInfo { - TrackEvents = new List { + TrackEvents = new SubtitleTrackEvent[] { new SubtitleTrackEvent { Id = "1", StartPositionTicks = 24000000, @@ -100,8 +100,8 @@ namespace MediaBrowser.Tests.MediaEncoding.Subtitles var result = sut.Parse(stream, CancellationToken.None); Assert.IsNotNull(result); - Assert.AreEqual(expectedSubs.TrackEvents.Count, result.TrackEvents.Count); - for (int i = 0; i < expectedSubs.TrackEvents.Count; i++) + Assert.AreEqual(expectedSubs.TrackEvents.Length, result.TrackEvents.Length); + for (int i = 0; i < expectedSubs.TrackEvents.Length; i++) { Assert.AreEqual(expectedSubs.TrackEvents[i].Id, result.TrackEvents[i].Id); Assert.AreEqual(expectedSubs.TrackEvents[i].StartPositionTicks, result.TrackEvents[i].StartPositionTicks); diff --git a/MediaBrowser.Tests/MediaEncoding/Subtitles/VttWriterTest.cs b/MediaBrowser.Tests/MediaEncoding/Subtitles/VttWriterTest.cs index f6e2c5298..00feb286c 100644 --- a/MediaBrowser.Tests/MediaEncoding/Subtitles/VttWriterTest.cs +++ b/MediaBrowser.Tests/MediaEncoding/Subtitles/VttWriterTest.cs @@ -14,7 +14,7 @@ namespace MediaBrowser.Tests.MediaEncoding.Subtitles { var infoSubs = new SubtitleTrackInfo { - TrackEvents = new List { + TrackEvents = new SubtitleTrackEvent[] { new SubtitleTrackEvent { Id = "1", StartPositionTicks = 24000000, diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index d9e6fdc7d..94c00a602 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.730 + 3.0.734 Emby.Common Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index b79e0c435..99c9af095 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.730 + 3.0.734 Emby.Server.Core Emby Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Emby Server. Copyright © Emby 2013 - + From b783f317febcb545f79de116124d9a95c8384b64 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 19 Aug 2017 18:37:15 -0400 Subject: [PATCH 3/5] update live stream management --- .../LiveTv/EmbyTV/DirectRecorder.cs | 4 +- .../LiveTv/TunerHosts/MulticastStream.cs | 48 +++++--------- .../LiveTv/TunerHosts/QueueStream.cs | 62 +------------------ .../Parsers/BaseNfoParser.cs | 4 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 6 files changed, 25 insertions(+), 99 deletions(-) diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs index 2a2e1886f..8aef37115 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs @@ -49,8 +49,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV _logger.Info("Copying recording stream to file {0}", targetFile); // The media source if infinite so we need to handle stopping ourselves - var durationToken = new CancellationTokenSource(duration); - cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token).Token; + //var durationToken = new CancellationTokenSource(duration); + //cancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token).Token; await directStreamProvider.CopyToAsync(output, cancellationToken).ConfigureAwait(false); } diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/MulticastStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/MulticastStream.cs index 567f4ce20..45a0c348e 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/MulticastStream.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/MulticastStream.cs @@ -39,21 +39,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts if (bytesRead > 0) { - var allStreams = _outputStreams.ToList(); - - //if (allStreams.Count == 1) - //{ - // allStreams[0].Value.Write(buffer, 0, bytesRead); - //} - //else + foreach (var stream in _outputStreams) { - //byte[] copy = new byte[bytesRead]; - //Buffer.BlockCopy(buffer, 0, copy, 0, bytesRead); - - foreach (var stream in allStreams) - { - stream.Value.Queue(buffer, 0, bytesRead); - } + stream.Value.Queue(buffer, 0, bytesRead); } if (onStarted != null) @@ -73,27 +61,21 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts public Task CopyToAsync(Stream stream, CancellationToken cancellationToken) { - var result = new QueueStream(stream, _logger) + var queueStream = new QueueStream(stream, _logger); + + _outputStreams.TryAdd(queueStream.Id, queueStream); + + try { - OnFinished = OnFinished - }; + queueStream.Start(cancellationToken); + } + finally + { + _outputStreams.TryRemove(queueStream.Id, out queueStream); + GC.Collect(); + } - _outputStreams.TryAdd(result.Id, result); - - result.Start(cancellationToken); - - return result.TaskCompletion.Task; - } - - public void RemoveOutputStream(QueueStream stream) - { - QueueStream removed; - _outputStreams.TryRemove(stream.Id, out removed); - } - - private void OnFinished(QueueStream queueStream) - { - RemoveOutputStream(queueStream); + return Task.FromResult(true); } } } diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/QueueStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/QueueStream.cs index f1ec8d5af..07a4daa87 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/QueueStream.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/QueueStream.cs @@ -14,9 +14,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts { private readonly Stream _outputStream; private readonly BlockingCollection> _queue = new BlockingCollection>(); - public TaskCompletionSource TaskCompletion { get; private set; } - public Action OnFinished { get; set; } private readonly ILogger _logger; public Guid Id = Guid.NewGuid(); @@ -24,7 +22,6 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts { _outputStream = outputStream; _logger = logger; - TaskCompletion = new TaskCompletionSource(); } public void Queue(byte[] bytes, int offset, int count) @@ -34,68 +31,15 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts public void Start(CancellationToken cancellationToken) { - Task.Run(() => StartInternal(cancellationToken)); - } - - private void OnClosed() - { - GC.Collect(); - if (OnFinished != null) + while (true) { - OnFinished(this); - } - } - - public void Write(byte[] bytes, int offset, int count) - { - //return _outputStream.WriteAsync(bytes, offset, count, cancellationToken); - - try - { - _outputStream.Write(bytes, offset, count); - } - catch (OperationCanceledException) - { - _logger.Debug("QueueStream cancelled"); - TaskCompletion.TrySetCanceled(); - OnClosed(); - } - catch (Exception ex) - { - _logger.ErrorException("Error in QueueStream", ex); - TaskCompletion.TrySetException(ex); - OnClosed(); - } - } - - private void StartInternal(CancellationToken cancellationToken) - { - try - { - while (true) + foreach (var result in _queue.GetConsumingEnumerable()) { cancellationToken.ThrowIfCancellationRequested(); - foreach (var result in _queue.GetConsumingEnumerable()) - { - _outputStream.Write(result.Item1, result.Item2, result.Item3); - } + _outputStream.Write(result.Item1, result.Item2, result.Item3); } } - catch (OperationCanceledException) - { - _logger.Debug("QueueStream cancelled"); - TaskCompletion.TrySetCanceled(); - } - catch (Exception ex) - { - _logger.ErrorException("Error in QueueStream", ex); - TaskCompletion.TrySetException(ex); - } - finally - { - OnClosed(); - } } } } diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs index 789d840b8..c1c2e7d9d 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs @@ -253,7 +253,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers int value; if (!string.IsNullOrWhiteSpace(tmdbId) && int.TryParse(tmdbId, NumberStyles.Any, CultureInfo.InvariantCulture, out value)) { - item.SetProviderId(MetadataProviders.Tmdb, tmdbId); + item.SetProviderId(MetadataProviders.Tmdb, value.ToString(_usCulture)); } } @@ -269,7 +269,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers int value; if (!string.IsNullOrWhiteSpace(tvdbId) && int.TryParse(tvdbId, NumberStyles.Any, CultureInfo.InvariantCulture, out value)) { - item.SetProviderId(MetadataProviders.Tvdb, tvdbId); + item.SetProviderId(MetadataProviders.Tvdb, value.ToString(_usCulture)); } } } diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 94c00a602..a86735bca 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.734 + 3.0.735 Emby.Common Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 99c9af095..3b9c0c83b 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.734 + 3.0.735 Emby.Server.Core Emby Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Emby Server. Copyright © Emby 2013 - + From ae1a54783765e7bee023ed56e5f1074a5d2c9f5d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 19 Aug 2017 18:37:30 -0400 Subject: [PATCH 4/5] update logging --- Emby.Server.Implementations/Logging/SimpleLogManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Emby.Server.Implementations/Logging/SimpleLogManager.cs b/Emby.Server.Implementations/Logging/SimpleLogManager.cs index 6d1c5b837..a3de8e650 100644 --- a/Emby.Server.Implementations/Logging/SimpleLogManager.cs +++ b/Emby.Server.Implementations/Logging/SimpleLogManager.cs @@ -112,7 +112,7 @@ namespace Emby.Server.Implementations.Logging public class FileLogger : IDisposable { - private readonly Stream _fileStream; + private readonly FileStream _fileStream; private bool _disposed; private readonly CancellationTokenSource _cancellationTokenSource; @@ -146,7 +146,7 @@ namespace Emby.Server.Implementations.Logging if (any) { - _fileStream.Flush(); + _fileStream.Flush(true); } } catch From a02968c568c97da544b239014506a03ecca35c09 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 19 Aug 2017 18:37:55 -0400 Subject: [PATCH 5/5] 3.2.27.4 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SharedVersion.cs b/SharedVersion.cs index 7f7bb8564..c2af686e7 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.27.3")] +[assembly: AssemblyVersion("3.2.27.4")]