From bd31c0175d87ec00a675b92ae9a92af569228775 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 18 Aug 2017 15:34:41 -0400 Subject: [PATCH 01/41] 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 bc88d652c4..39b554afe7 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 1e897016e3..2a45fb3151 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 5c83766fe8..6d1c5b837a 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 2ee2acfc2e..15abaaa62c 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 093d57aa45..e53a796703 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 d72bd532e1..a6664c42f0 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 02/41] 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 | 59 +++---- .../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 | 77 ++++++--- .../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, 992 insertions(+), 1346 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 96b282d04b..5ce1d1925f 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 64e76276cf..65410bd67d 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 7164cf5989..d563b5addd 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 32f542e73f..e29ef78a88 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 39b554afe7..ea6c2aaf5f 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 e41e0ea87f..28a1503700 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 5b168f6cc1..18823fa9dc 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 6743e96fd3..d7cbdf9e58 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 de0dfda2ed..b286a3bb07 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 e1d0a1858f..9dbf299ab8 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 69a205dda9..80a188bc0f 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 71e31d4d4f..accdc5e9d4 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 f150e47859..f1fea2085b 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 c452c01be3..1467d9426a 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 40dccf9bad..bf3afd0507 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 658558ec05..d4c4f27942 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 e066ab61bd..1f2bf97a39 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 0d4303b168..25c3e10e89 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 99b5558a2d..ecad5c0eb2 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 619d2378df..eff2909fdb 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 3fbbc8390e..2882af007f 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 5582d8f35e..cad28c809c 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 cf50e60921..567f4ce204 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 61bc390b40..f1ec8d5af3 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 8d3051a898..a8cd1dc04d 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 7ee6e9e38b..770b881d5c 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 f9fb98f85e..849e02d812 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 db79804978..f49d5a1d10 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 578a2321cc..9b9596934a 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 4ad56411ad..c3970b22f6 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 dc7e839929..ee373139f4 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 03283031eb..018e452bee 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 6e37c1dc12..6f9c856711 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 d3cc18d4be..1629d49b49 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 bce1e66829..c7ceb41bcb 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 8d5f46962c..92128634e3 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 ecb54bf5cb..fa3287ebdd 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 9764a71dbc..bc6101d6cd 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 41b17e535d..52b274653b 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 0ce57a16a8..8a16cbfa16 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 36303c889d..0b39199854 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 e4f3fd3d76..3512a526ba 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 313f7aab50..56caf884bb 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 7dd1afaf45..6c9f5d32bb 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 e2961f630e..e866be9c67 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 eee340a874..2c92505b17 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 810b0f6b27..602a697bf2 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 917a3bc0bc..6511d31279 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 c668d2c756..7873c1cd38 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 eb5365ab8f..45b07712f8 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 b0f086ec5b..bf6b75a3ef 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 58e413cef2..4876351fc0 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 baf1adc192..0000000000 --- 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 64424795fc..79dda87028 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 aef16e4428..07a976f396 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 eb95224b79..f6efe15e6d 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 e8ad9ea954..abe3e5407c 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 fe40ceeebf..18d2611952 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 a4b14d2d49..48765e698a 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 645aacdec6..4d4b4cb273 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 2456dd6c0c..22432bf518 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 cbff7cc2ec..edb9f063dd 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 148e65b492..cd0c5d9e51 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); + if (request.StartIndex.HasValue || request.Limit.HasValue) + { + returnItems = ApplyPaging(episodes, request.StartIndex, request.Limit).ToList(); + } - var returnDtos = (await _dtoService.GetBaseItemDtos(pagedItems, dtoOptions, user).ConfigureAwait(false)); - var dtos = returnDtos.ToArray(returnDtos.Count); + var dtos = (await _dtoService.GetBaseItemDtos(returnItems, dtoOptions, user).ConfigureAwait(false)); - return new ItemsResult + return new QueryResult { - TotalRecordCount = returnList.Count, + TotalRecordCount = episodes.Count, Items = dtos }; } diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs index 30e64d89d1..1d0065c7cf 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 a9c5ae700d..66aa35de9c 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 f3d7772fca..9dd5aa5651 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 ee11626870..87a06e4d59 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 3ed5166a4b..096157e47f 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 49b7f6c15e..acdbf96f42 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 57d3d7e394..dc7d098634 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 636526567e..ecc2726055 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 824bdf8ffb..46e55a21ce 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 7d80d7e12a..976808aad9 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 4a2d390662..7a387e319a 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 89e505579d..0ca7b2e3e5 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 098ba558f8..f05ae4e713 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 963092f522..76ecd81803 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 a6418418e1..c158378a67 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 46ae9230b7..b088347842 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 ce4a482baf..ab4f624e21 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 6ba9577d17..376f65d60d 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 b681fdcb10..8b934bc475 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 3350a65799..545e8518ae 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 d351563450..dd70277a7e 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 4c44a613b1..7ab4e98fcf 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 9323404e38..acfa239d33 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 3b166db922..fa11787f51 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 e9954545ed..b364ab9909 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 b46ece49d4..76182c641b 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 d6855b7924..862894f613 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 823c893ea8..8b4179adc9 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 b552579a8c..c2ce969792 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 d5c85197fa..70e4db84f8 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 0785ee29fc..929f4e649e 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 cb1e3da902..f9d2643145 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 aec0668d43..e36e6ad5db 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 703666d668..77e6a7e405 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 11a9ceac42..265f4f544e 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 d1d5f27bef..2199c21e6a 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 66f64464f1..910d697ec0 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 aa4b36427a..2f60e124ec 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 1b61f079e6..ddfb703212 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 + else if (item is Person) { - names.Insert(0, "folder"); - names.Insert(0, "poster"); + // these prefer folder + imageFileNames = PersonImageFileNames; } - - // Support plex/kodi convention - if (item is Series) + else if (item is Series) { - names.Add("show"); + imageFileNames = SeriesImageFileNames; } - - // Support plex/kodi convention - if (item is Video && !(item is Episode)) + else if (item is Video && !(item is Episode)) + { + imageFileNames = VideoImageFileNames; + } + else { - 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 c5631899e2..920f3e4b2b 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 8dfdbcd7a4..39b40cabc4 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 ddde688b25..8a41decbf7 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 90b3933eb9..80142cf434 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 cd4858d907..2b344df242 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 24c7aef98b..6584bb3ccd 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 14b1875c19..d75547adb1 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 2004cfc1fe..23bbf01939 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 5f9bd772cc..d6f0eafc75 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 e80f59be4c..7430c449f2 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 a464b045bf..034e0fe6a4 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 950d3680df..ae74e255b0 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 f1a001bbab..742253fa35 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 189ed27e46..1cb7836699 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 badd3c5b11..e13b327672 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 f182541d8a..3f639a520a 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 9623a68b08..8453fdf6d6 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 e0e7e55aae..8da20c9f5b 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 1da3bb0acd..2cd9d408db 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 c85818390d..0000000000 --- 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 1bf67f66cc..488b1e7a86 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 9bd15fc8f6..aa8b33c817 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 07a4b5f605..b3d3be70e8 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 374d8d028d..901090717f 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 741f07469c..cfcb229c8f 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 47cec14593..2356a2fa19 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 a4f95c1bcc..0000000000 --- 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 9d7fdd129e..7c9fe07909 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 a8ea864944..67e3d44dac 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 f4d3e21d98..4620fbf0c6 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 a1df35b127..64b628a138 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 25d3b289f0..09ec4b9315 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 9af96df434..937cef0571 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 3880012874..743caa97ee 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 0e4cc0623f..b36a773eb4 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 963e8dd95e..1b573fba7a 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 691dcc6c8f..63b1c9cfdb 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 1f8936d018..b38fec7d47 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 765cfe32fc..d3a3bb1d0b 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 7a2e1f2159..c4dfd25ca4 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 59b39fbc78..ee51010115 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 63deb19dcd..5314e791a3 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 c519d66cb5..199552640f 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 1c60db6ae1..7e38badfcf 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 3b9c59733c..0000000000 --- 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 1ecc1de6c4..6f9923d087 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 80478a9102..0d7eb502f8 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 222c1bd64b..9ae1fae9f4 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 3081d7ee3b..78ee72f619 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 f58e605b28..70c299bc25 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 f92f445860..c6b03200d2 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 52d3fab3c0..adfb84b055 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 c5728ac97e..3d625aa998 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 0df4de86d1..c0941caee5 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 3799e94557..0b017af6e1 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 a987a6cd69..e55ca4f085 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 eb153427c7..e8b698f62d 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 6723aa2cf7..ee46bc155b 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 9fb275823a..5a97bc92e7 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 a96c86ed9c..3dc863b757 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 4dedcfd2dc..68bd8a2ebf 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 4154093cba..fce9dea4f1 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 208d5b784f..e46d59fc07 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 139bd6d588..d249b6b002 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 b0785298b8..fb1fed8b3f 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 791a5c57b3..ea8d7bdb0b 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 fce95364ef..fe655759e1 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 c10b0ef9db..7cd4087911 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 47f5891c6e..dde9f2fe2c 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 280dc5d785..8acc490e7a 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 f6e2c5298e..00feb286c7 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 d9e6fdc7d9..94c00a6027 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 b79e0c4353..99c9af0959 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 03/41] update live stream management --- .../LiveTv/EmbyTV/DirectRecorder.cs | 4 +- .../LiveTv/TunerHosts/MulticastStream.cs | 46 +++++--------- .../LiveTv/TunerHosts/QueueStream.cs | 62 +------------------ .../Parsers/BaseNfoParser.cs | 4 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 6 files changed, 24 insertions(+), 98 deletions(-) diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs index 2a2e1886f6..8aef37115f 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 567f4ce204..45a0c348e1 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) - { - OnFinished = OnFinished - }; - - _outputStreams.TryAdd(result.Id, result); + var queueStream = new QueueStream(stream, _logger); - result.Start(cancellationToken); + _outputStreams.TryAdd(queueStream.Id, queueStream); - return result.TaskCompletion.Task; - } - - public void RemoveOutputStream(QueueStream stream) - { - QueueStream removed; - _outputStreams.TryRemove(stream.Id, out removed); - } + try + { + queueStream.Start(cancellationToken); + } + finally + { + _outputStreams.TryRemove(queueStream.Id, out queueStream); + GC.Collect(); + } - 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 f1ec8d5af3..07a4daa87d 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) - { - 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) { - 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 789d840b82..c1c2e7d9dc 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 94c00a6027..a86735bcac 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 99c9af0959..3b9c0c83be 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 04/41] 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 6d1c5b837a..a3de8e6505 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 05/41] 3.2.27.4 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SharedVersion.cs b/SharedVersion.cs index 7f7bb85641..c2af686e7d 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")] From 1c7283791d134c0d579292916bb954babb3cb015 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 19 Aug 2017 18:54:05 -0400 Subject: [PATCH 06/41] update logging --- Emby.Server.Implementations/Logging/SimpleLogManager.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Emby.Server.Implementations/Logging/SimpleLogManager.cs b/Emby.Server.Implementations/Logging/SimpleLogManager.cs index a3de8e6505..3a69926575 100644 --- a/Emby.Server.Implementations/Logging/SimpleLogManager.cs +++ b/Emby.Server.Implementations/Logging/SimpleLogManager.cs @@ -134,18 +134,11 @@ namespace Emby.Server.Implementations.Logging { try { - var any = false; - foreach (var message in _queue.GetConsumingEnumerable()) { var bytes = Encoding.UTF8.GetBytes(message + Environment.NewLine); _fileStream.Write(bytes, 0, bytes.Length); - any = true; - } - - if (any) - { _fileStream.Flush(true); } } From 1573cc24916239530536c84d4d6a14c5aa351e22 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 19 Aug 2017 18:56:32 -0400 Subject: [PATCH 07/41] 3.2.28.1 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SharedVersion.cs b/SharedVersion.cs index c2af686e7d..9e7217a6de 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.27.4")] +[assembly: AssemblyVersion("3.2.28.1")] From f4765a87cc15efb06331aaeeff3c695be4e77f07 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 20 Aug 2017 15:10:00 -0400 Subject: [PATCH 08/41] update m3u tuner --- .../Library/LibraryManager.cs | 12 +- .../LiveTv/TunerHosts/M3UTunerHost.cs | 127 ++++++++++-------- .../LiveTv/TunerHosts/M3uParser.cs | 18 +-- .../Updates/InstallationManager.cs | 8 +- .../Entities/AggregateFolder.cs | 8 +- .../Entities/CollectionFolder.cs | 8 +- .../Entities/Movies/BoxSet.cs | 38 ------ MediaBrowser.Controller/IO/FileData.cs | 10 +- .../Library/ILibraryManager.cs | 2 +- .../Library/ItemResolveArgs.cs | 29 +--- MediaBrowser.Controller/LiveTv/ChannelInfo.cs | 2 + MediaBrowser.Model/LiveTv/LiveTvOptions.cs | 1 + 12 files changed, 106 insertions(+), 157 deletions(-) diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index bf3afd0507..1bfc93e79a 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -353,7 +353,7 @@ namespace Emby.Server.Implementations.Library } else { - if (item is Photo) + if (!(item is Video)) { return; } @@ -599,18 +599,16 @@ namespace Emby.Server.Implementations.Library // When resolving the root, we need it's grandchildren (children of user views) var flattenFolderDepth = isPhysicalRoot ? 2 : 0; - var fileSystemDictionary = FileData.GetFilteredFileSystemEntries(directoryService, args.Path, _fileSystem, _logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf); + var files = FileData.GetFilteredFileSystemEntries(directoryService, args.Path, _fileSystem, _logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf); // Need to remove subpaths that may have been resolved from shortcuts // Example: if \\server\movies exists, then strip out \\server\movies\action if (isPhysicalRoot) { - var paths = NormalizeRootPathList(fileSystemDictionary.Values); - - fileSystemDictionary = paths.ToDictionary(i => i.FullName); + files = NormalizeRootPathList(files).ToArray(); } - args.FileSystemDictionary = fileSystemDictionary; + args.FileSystemChildren = files; } // Check to see if we should resolve based on our contents @@ -656,7 +654,7 @@ namespace Emby.Server.Implementations.Library return false; } - public IEnumerable NormalizeRootPathList(IEnumerable paths) + public List NormalizeRootPathList(IEnumerable paths) { var originalList = paths.ToList(); diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs index 2c12f4ca15..1bc334f062 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs @@ -25,12 +25,14 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts private readonly IHttpClient _httpClient; private readonly IServerApplicationHost _appHost; private readonly IEnvironmentInfo _environment; + private readonly INetworkManager _networkManager; - public M3UTunerHost(IServerConfigurationManager config, ILogger logger, IJsonSerializer jsonSerializer, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IHttpClient httpClient, IServerApplicationHost appHost, IEnvironmentInfo environment) : base(config, logger, jsonSerializer, mediaEncoder, fileSystem) + public M3UTunerHost(IServerConfigurationManager config, ILogger logger, IJsonSerializer jsonSerializer, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IHttpClient httpClient, IServerApplicationHost appHost, IEnvironmentInfo environment, INetworkManager networkManager) : base(config, logger, jsonSerializer, mediaEncoder, fileSystem) { _httpClient = httpClient; _appHost = appHost; _environment = environment; + _networkManager = networkManager; } public override string Type @@ -38,7 +40,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts get { return "m3u"; } } - public string Name + public virtual string Name { get { return "M3U Tuner"; } } @@ -99,72 +101,83 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } var channels = await GetChannels(info, true, cancellationToken).ConfigureAwait(false); - var m3uchannels = channels.Cast(); - var channel = m3uchannels.FirstOrDefault(c => string.Equals(c.Id, channelId, StringComparison.OrdinalIgnoreCase)); + var channel = channels.FirstOrDefault(c => string.Equals(c.Id, channelId, StringComparison.OrdinalIgnoreCase)); if (channel != null) { - var path = channel.Path; - MediaProtocol protocol = MediaProtocol.File; - if (path.StartsWith("http", StringComparison.OrdinalIgnoreCase)) - { - protocol = MediaProtocol.Http; - } - else if (path.StartsWith("rtmp", StringComparison.OrdinalIgnoreCase)) - { - protocol = MediaProtocol.Rtmp; - } - else if (path.StartsWith("rtsp", StringComparison.OrdinalIgnoreCase)) - { - protocol = MediaProtocol.Rtsp; - } - else if (path.StartsWith("udp", StringComparison.OrdinalIgnoreCase)) - { - protocol = MediaProtocol.Udp; - } - else if (path.StartsWith("rtp", StringComparison.OrdinalIgnoreCase)) - { - protocol = MediaProtocol.Rtmp; - } + return new List { CreateMediaSourceInfo(info, channel) }; + } + return new List(); + } + + protected virtual MediaSourceInfo CreateMediaSourceInfo(TunerHostInfo info, ChannelInfo channel) + { + var path = channel.Path; + MediaProtocol protocol = MediaProtocol.File; + if (path.StartsWith("http", StringComparison.OrdinalIgnoreCase)) + { + protocol = MediaProtocol.Http; + } + else if (path.StartsWith("rtmp", StringComparison.OrdinalIgnoreCase)) + { + protocol = MediaProtocol.Rtmp; + } + else if (path.StartsWith("rtsp", StringComparison.OrdinalIgnoreCase)) + { + protocol = MediaProtocol.Rtsp; + } + else if (path.StartsWith("udp", StringComparison.OrdinalIgnoreCase)) + { + protocol = MediaProtocol.Udp; + } + else if (path.StartsWith("rtp", StringComparison.OrdinalIgnoreCase)) + { + protocol = MediaProtocol.Rtmp; + } + + Uri uri; + var isRemote = true; + if (Uri.TryCreate(path, UriKind.Absolute, out uri)) + { + isRemote = !_networkManager.IsInLocalNetwork(uri.Host); + } - var mediaSource = new MediaSourceInfo + var mediaSource = new MediaSourceInfo + { + Path = path, + Protocol = protocol, + MediaStreams = new List { - Path = channel.Path, - Protocol = protocol, - MediaStreams = new List + new MediaStream { - new MediaStream - { - Type = MediaStreamType.Video, - // Set the index to -1 because we don't know the exact index of the video stream within the container - Index = -1, - IsInterlaced = true - }, - new MediaStream - { - Type = MediaStreamType.Audio, - // Set the index to -1 because we don't know the exact index of the audio stream within the container - Index = -1 - - } + Type = MediaStreamType.Video, + // Set the index to -1 because we don't know the exact index of the video stream within the container + Index = -1, + IsInterlaced = true }, - RequiresOpening = true, - RequiresClosing = true, - RequiresLooping = info.EnableStreamLooping, + new MediaStream + { + Type = MediaStreamType.Audio, + // Set the index to -1 because we don't know the exact index of the audio stream within the container + Index = -1 - ReadAtNativeFramerate = false, + } + }, + RequiresOpening = true, + RequiresClosing = true, + RequiresLooping = info.EnableStreamLooping, - Id = channel.Path.GetMD5().ToString("N"), - IsInfiniteStream = true, - IsRemote = true, + ReadAtNativeFramerate = false, - IgnoreDts = true - }; + Id = channel.Path.GetMD5().ToString("N"), + IsInfiniteStream = true, + IsRemote = isRemote, - mediaSource.InferTotalBitrate(); + IgnoreDts = true + }; - return new List { mediaSource }; - } - return new List(); + mediaSource.InferTotalBitrate(); + + return mediaSource; } protected override Task IsAvailableInternal(TunerHostInfo tuner, string channelId, CancellationToken cancellationToken) diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs index 113e691b6f..ca744b615e 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs @@ -32,7 +32,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts _appHost = appHost; } - public async Task> Parse(string url, string channelIdPrefix, string tunerHostId, CancellationToken cancellationToken) + public async Task> Parse(string url, string channelIdPrefix, string tunerHostId, CancellationToken cancellationToken) { // Read the file and display it line by line. using (var reader = new StreamReader(await GetListingsStream(url, cancellationToken).ConfigureAwait(false))) @@ -41,7 +41,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } } - public List ParseString(string text, string channelIdPrefix, string tunerHostId) + public List ParseString(string text, string channelIdPrefix, string tunerHostId) { // Read the file and display it line by line. using (var reader = new StringReader(text)) @@ -66,9 +66,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } const string ExtInfPrefix = "#EXTINF:"; - private List GetChannels(TextReader reader, string channelIdPrefix, string tunerHostId) + private List GetChannels(TextReader reader, string channelIdPrefix, string tunerHostId) { - var channels = new List(); + var channels = new List(); string line; string extInf = ""; @@ -111,9 +111,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts return channels; } - private M3UChannel GetChannelnfo(string extInf, string tunerHostId, string mediaUrl) + private ChannelInfo GetChannelnfo(string extInf, string tunerHostId, string mediaUrl) { - var channel = new M3UChannel(); + var channel = new ChannelInfo(); channel.TunerHostId = tunerHostId; extInf = extInf.Trim(); @@ -335,10 +335,4 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts return dict; } } - - - public class M3UChannel : ChannelInfo - { - public string Path { get; set; } - } } \ No newline at end of file diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index 6f9c856711..ab1255b574 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -308,9 +308,11 @@ namespace Emby.Server.Implementations.Updates .OrderByDescending(GetPackageVersion).ToArray(); } + IEnumerable packagesList = packages; + if (!string.IsNullOrWhiteSpace(packageType)) { - packages = packages.Where(p => string.Equals(p.type, packageType, StringComparison.OrdinalIgnoreCase)).ToArray(); + packagesList = packagesList.Where(p => string.Equals(p.type, packageType, StringComparison.OrdinalIgnoreCase)); } // If an app version was supplied, filter the versions for each package to only include supported versions @@ -323,7 +325,9 @@ namespace Emby.Server.Implementations.Updates } // Remove packages with no versions - return packages.Where(p => p.versions.Any()).ToArray(); + packagesList = packagesList.Where(p => p.versions.Any()); + + return packagesList.ToArray(); } /// diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs index f88522f78a..db84d6e2f9 100644 --- a/MediaBrowser.Controller/Entities/AggregateFolder.cs +++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs @@ -148,18 +148,16 @@ namespace MediaBrowser.Controller.Entities // When resolving the root, we need it's grandchildren (children of user views) var flattenFolderDepth = isPhysicalRoot ? 2 : 0; - var fileSystemDictionary = FileData.GetFilteredFileSystemEntries(directoryService, args.Path, FileSystem, Logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf); + var files = FileData.GetFilteredFileSystemEntries(directoryService, args.Path, FileSystem, Logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf); // Need to remove subpaths that may have been resolved from shortcuts // Example: if \\server\movies exists, then strip out \\server\movies\action if (isPhysicalRoot) { - var paths = LibraryManager.NormalizeRootPathList(fileSystemDictionary.Values); - - fileSystemDictionary = paths.ToDictionary(i => i.FullName); + files = LibraryManager.NormalizeRootPathList(files).ToArray(); } - args.FileSystemDictionary = fileSystemDictionary; + args.FileSystemChildren = files; } _requiresRefresh = _requiresRefresh || !args.PhysicalLocations.SequenceEqual(PhysicalLocations); diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index d02e469d46..3e2c501b44 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -292,18 +292,16 @@ namespace MediaBrowser.Controller.Entities // When resolving the root, we need it's grandchildren (children of user views) var flattenFolderDepth = isPhysicalRoot ? 2 : 0; - var fileSystemDictionary = FileData.GetFilteredFileSystemEntries(directoryService, args.Path, FileSystem, Logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf); + var files = FileData.GetFilteredFileSystemEntries(directoryService, args.Path, FileSystem, Logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf); // Need to remove subpaths that may have been resolved from shortcuts // Example: if \\server\movies exists, then strip out \\server\movies\action if (isPhysicalRoot) { - var paths = LibraryManager.NormalizeRootPathList(fileSystemDictionary.Values); - - fileSystemDictionary = paths.ToDictionary(i => i.FullName); + files = LibraryManager.NormalizeRootPathList(files).ToArray(); } - args.FileSystemDictionary = fileSystemDictionary; + args.FileSystemChildren = files; } _requiresRefresh = _requiresRefresh || !args.PhysicalLocations.SequenceEqual(PhysicalLocations); diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index 376f65d60d..2768d84659 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -8,7 +8,6 @@ using System; using System.Collections.Generic; using System.Linq; using MediaBrowser.Model.Serialization; -using MediaBrowser.Controller.Entities.Audio; namespace MediaBrowser.Controller.Entities.Movies { @@ -82,20 +81,11 @@ namespace MediaBrowser.Controller.Entities.Movies protected override IEnumerable GetNonCachedChildren(IDirectoryService directoryService) { - if (IsLegacyBoxSet) - { - return base.GetNonCachedChildren(directoryService); - } return new List(); } protected override List LoadChildren() { - if (IsLegacyBoxSet) - { - return base.LoadChildren(); - } - // Save a trip to the database return new List(); } @@ -109,34 +99,6 @@ namespace MediaBrowser.Controller.Entities.Movies } } - [IgnoreDataMember] - protected override bool SupportsShortcutChildren - { - get - { - if (IsLegacyBoxSet) - { - return false; - } - - return false; - } - } - - [IgnoreDataMember] - private bool IsLegacyBoxSet - { - get - { - if (string.IsNullOrWhiteSpace(Path)) - { - return false; - } - - return !FileSystem.ContainsSubPath(ConfigurationManager.ApplicationPaths.DataPath, Path); - } - } - public override bool IsAuthorizedToDelete(User user) { return true; diff --git a/MediaBrowser.Controller/IO/FileData.cs b/MediaBrowser.Controller/IO/FileData.cs index 64a7610fe2..27af60700e 100644 --- a/MediaBrowser.Controller/IO/FileData.cs +++ b/MediaBrowser.Controller/IO/FileData.cs @@ -3,7 +3,7 @@ using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Logging; using System; using System.Collections.Generic; - +using System.Linq; using MediaBrowser.Model.IO; namespace MediaBrowser.Controller.IO @@ -36,7 +36,7 @@ namespace MediaBrowser.Controller.IO /// if set to true [resolve shortcuts]. /// Dictionary{System.StringFileSystemInfo}. /// path - public static Dictionary GetFilteredFileSystemEntries(IDirectoryService directoryService, + public static FileSystemMetadata[] GetFilteredFileSystemEntries(IDirectoryService directoryService, string path, IFileSystem fileSystem, ILogger logger, @@ -57,7 +57,7 @@ namespace MediaBrowser.Controller.IO if (!resolveShortcuts && flattenFolderDepth == 0) { - return GetFileSystemDictionary(entries); + return entries; } var dict = new Dictionary(StringComparer.OrdinalIgnoreCase); @@ -98,7 +98,7 @@ namespace MediaBrowser.Controller.IO { foreach (var child in GetFilteredFileSystemEntries(directoryService, fullName, fileSystem, logger, args, flattenFolderDepth: flattenFolderDepth - 1, resolveShortcuts: resolveShortcuts)) { - dict[child.Key] = child.Value; + dict[child.FullName] = child; } } else @@ -107,7 +107,7 @@ namespace MediaBrowser.Controller.IO } } - return dict; + return dict.Values.ToArray(); } } diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 025254d4b3..cd1781220e 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -277,7 +277,7 @@ namespace MediaBrowser.Controller.Library /// /// The paths. /// IEnumerable{System.String}. - IEnumerable NormalizeRootPathList(IEnumerable paths); + List NormalizeRootPathList(IEnumerable paths); /// /// Registers the item. diff --git a/MediaBrowser.Controller/Library/ItemResolveArgs.cs b/MediaBrowser.Controller/Library/ItemResolveArgs.cs index 76b6d87689..963e4b71b2 100644 --- a/MediaBrowser.Controller/Library/ItemResolveArgs.cs +++ b/MediaBrowser.Controller/Library/ItemResolveArgs.cs @@ -40,20 +40,7 @@ namespace MediaBrowser.Controller.Library /// Gets the file system children. /// /// The file system children. - public IEnumerable FileSystemChildren - { - get - { - var dict = FileSystemDictionary; - - if (dict == null) - { - return new List(); - } - - return dict.Values; - } - } + public FileSystemMetadata[] FileSystemChildren { get; set; } public LibraryOptions LibraryOptions { get; set; } @@ -62,12 +49,6 @@ namespace MediaBrowser.Controller.Library return LibraryOptions ?? (LibraryOptions = (Parent == null ? new LibraryOptions() : BaseItem.LibraryManager.GetLibraryOptions(Parent))); } - /// - /// Gets or sets the file system dictionary. - /// - /// The file system dictionary. - public Dictionary FileSystemDictionary { get; set; } - /// /// Gets or sets the parent. /// @@ -224,13 +205,11 @@ namespace MediaBrowser.Controller.Library throw new ArgumentNullException(); } - if (FileSystemDictionary != null) + foreach (var file in FileSystemChildren) { - FileSystemMetadata entry; - - if (FileSystemDictionary.TryGetValue(path, out entry)) + if (string.Equals(file.FullName, path, StringComparison.Ordinal)) { - return entry; + return file; } } diff --git a/MediaBrowser.Controller/LiveTv/ChannelInfo.cs b/MediaBrowser.Controller/LiveTv/ChannelInfo.cs index 6682942ad8..892a7d5b78 100644 --- a/MediaBrowser.Controller/LiveTv/ChannelInfo.cs +++ b/MediaBrowser.Controller/LiveTv/ChannelInfo.cs @@ -25,6 +25,8 @@ namespace MediaBrowser.Controller.LiveTv /// The id of the channel. public string Id { get; set; } + public string Path { get; set; } + public string TunerChannelId { get; set; } public string CallSign { get; set; } diff --git a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs index 64b628a138..15f60d8317 100644 --- a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs +++ b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs @@ -48,6 +48,7 @@ namespace MediaBrowser.Model.LiveTv public bool AllowHWTranscoding { get; set; } public bool EnableStreamLooping { get; set; } public bool EnableNewHdhrChannelIds { get; set; } + public string Source { get; set; } public TunerHostInfo() { From 2e5db767f349bcbc3ac0b7a24b670ea6c74d84ab Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 20 Aug 2017 17:07:47 -0400 Subject: [PATCH 09/41] 3.2.28.2 --- .../Collections/CollectionManager.cs | 23 +++++++++++++------ .../Updates/InstallationManager.cs | 1 + .../Collections/ICollectionManager.cs | 7 ++++-- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 ++-- SharedVersion.cs | 2 +- 6 files changed, 26 insertions(+), 13 deletions(-) diff --git a/Emby.Server.Implementations/Collections/CollectionManager.cs b/Emby.Server.Implementations/Collections/CollectionManager.cs index 18823fa9dc..0fc8fdc48c 100644 --- a/Emby.Server.Implementations/Collections/CollectionManager.cs +++ b/Emby.Server.Implementations/Collections/CollectionManager.cs @@ -149,12 +149,17 @@ namespace Emby.Server.Implementations.Collections return GetCollectionsFolder(string.Empty); } - public Task AddToCollection(Guid collectionId, string[] ids) + public Task AddToCollection(Guid collectionId, IEnumerable ids) { return AddToCollection(collectionId, ids, true, new MetadataRefreshOptions(_fileSystem)); } - private async Task AddToCollection(Guid collectionId, string[] ids, bool fireEvent, MetadataRefreshOptions refreshOptions) + public Task AddToCollection(Guid collectionId, IEnumerable ids) + { + return AddToCollection(collectionId, ids.Select(i => i.ToString("N")), true, new MetadataRefreshOptions(_fileSystem)); + } + + private async Task AddToCollection(Guid collectionId, IEnumerable ids, bool fireEvent, MetadataRefreshOptions refreshOptions) { var collection = _libraryManager.GetItemById(collectionId) as BoxSet; @@ -167,9 +172,9 @@ namespace Emby.Server.Implementations.Collections var itemList = new List(); var currentLinkedChildrenIds = collection.GetLinkedChildren().Select(i => i.Id).ToList(); - foreach (var itemId in ids) + foreach (var id in ids) { - var guidId = new Guid(itemId); + var guidId = new Guid(id); var item = _libraryManager.GetItemById(guidId); if (string.IsNullOrWhiteSpace(item.Path)) @@ -214,7 +219,12 @@ namespace Emby.Server.Implementations.Collections } } - public async Task RemoveFromCollection(Guid collectionId, string[] itemIds) + public Task RemoveFromCollection(Guid collectionId, IEnumerable itemIds) + { + return RemoveFromCollection(collectionId, itemIds.Select(i => new Guid(i))); + } + + public async Task RemoveFromCollection(Guid collectionId, IEnumerable itemIds) { var collection = _libraryManager.GetItemById(collectionId) as BoxSet; @@ -226,9 +236,8 @@ namespace Emby.Server.Implementations.Collections var list = new List(); var itemList = new List(); - foreach (var itemId in itemIds) + foreach (var guidId in itemIds) { - var guidId = new Guid(itemId); var childItem = _libraryManager.GetItemById(guidId); var child = collection.LinkedChildren.FirstOrDefault(i => (i.ItemId.HasValue && i.ItemId.Value == guidId) || (childItem != null && string.Equals(childItem.Path, i.Path, StringComparison.OrdinalIgnoreCase))); diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index ab1255b574..4d1e1eaac7 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -290,6 +290,7 @@ namespace Emby.Server.Implementations.Updates protected PackageInfo[] FilterPackages(List packages) { + foreach (var package in packages) { package.versions = package.versions.Where(v => !string.IsNullOrWhiteSpace(v.sourceUrl)) diff --git a/MediaBrowser.Controller/Collections/ICollectionManager.cs b/MediaBrowser.Controller/Collections/ICollectionManager.cs index 0ca7b2e3e5..d89843cc0d 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, string[] itemIds); + Task AddToCollection(Guid collectionId, IEnumerable itemIds); /// /// Removes from collection. @@ -44,7 +44,10 @@ namespace MediaBrowser.Controller.Collections /// The collection identifier. /// The item ids. /// Task. - Task RemoveFromCollection(Guid collectionId, string[] itemIds); + Task RemoveFromCollection(Guid collectionId, IEnumerable itemIds); + + Task AddToCollection(Guid collectionId, IEnumerable itemIds); + Task RemoveFromCollection(Guid collectionId, IEnumerable itemIds); /// /// Collapses the items within box sets. diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index a86735bcac..e4eff48886 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.735 + 3.0.736 Emby.Common Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 3b9c0c83be..f153d3e6b7 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.735 + 3.0.736 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 - + diff --git a/SharedVersion.cs b/SharedVersion.cs index 9e7217a6de..0f504796b3 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.28.1")] +[assembly: AssemblyVersion("3.2.28.2")] From 3c1fe6ff83c45133287ea3dac2f553da763739b6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 22 Aug 2017 01:41:02 -0400 Subject: [PATCH 10/41] add experimental warning for folder rip transcoding --- Emby.Server.Implementations/Data/SqliteItemRepository.cs | 2 +- Emby.Server.Implementations/Data/SqliteUserDataRepository.cs | 2 +- Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs | 4 ++-- MediaBrowser.Model/Configuration/ServerConfiguration.cs | 1 + SharedVersion.cs | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index d7cbdf9e58..064a66cd0a 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -114,7 +114,7 @@ namespace Emby.Server.Implementations.Data { get { - return true; + return false; } } diff --git a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs index bf6388f5d8..b76555bde5 100644 --- a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs @@ -95,7 +95,7 @@ namespace Emby.Server.Implementations.Data { get { - return true; + return false; } } diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/DirectRecorder.cs index 8aef37115f..2a2e1886f6 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/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index db66837e45..5177a757a9 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -217,6 +217,7 @@ namespace MediaBrowser.Model.Configuration EnableHttps = false; EnableDashboardResponseCaching = true; EnableAnonymousUsageReporting = true; + EnableCaseSensitiveItemIds = true; EnableAutomaticRestart = true; diff --git a/SharedVersion.cs b/SharedVersion.cs index 0f504796b3..fba02a2b01 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.28.2")] +[assembly: AssemblyVersion("3.2.28.3")] From 89722aa077ad6feff038f761144e3d78c0612f97 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 22 Aug 2017 01:41:20 -0400 Subject: [PATCH 11/41] resolve defect with folder rip transcoding --- MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 8b4179adc9..d99103852a 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -1664,15 +1664,15 @@ namespace MediaBrowser.Controller.MediaEncoding if (mediaSource.VideoType.Value == VideoType.BluRay || mediaSource.VideoType.Value == VideoType.Dvd) { - state.PlayableStreamFileNames = Video.QueryPlayableStreamFiles(state.MediaPath, mediaSource.VideoType.Value); + state.PlayableStreamFileNames = Video.QueryPlayableStreamFiles(state.MediaPath, mediaSource.VideoType.Value).Select(Path.GetFileName).ToArray(); } else if (mediaSource.VideoType.Value == VideoType.Iso && state.IsoType == IsoType.BluRay) { - state.PlayableStreamFileNames = Video.QueryPlayableStreamFiles(state.MediaPath, VideoType.BluRay); + state.PlayableStreamFileNames = Video.QueryPlayableStreamFiles(state.MediaPath, VideoType.BluRay).Select(Path.GetFileName).ToArray(); } else if (mediaSource.VideoType.Value == VideoType.Iso && state.IsoType == IsoType.Dvd) { - state.PlayableStreamFileNames = Video.QueryPlayableStreamFiles(state.MediaPath, VideoType.Dvd); + state.PlayableStreamFileNames = Video.QueryPlayableStreamFiles(state.MediaPath, VideoType.Dvd).Select(Path.GetFileName).ToArray(); } else { From 9f3389ff07f270b9e85d737f8184578705f940e3 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 22 Aug 2017 14:47:53 -0400 Subject: [PATCH 12/41] update mac project --- MediaBrowser.Server.Mac.sln | 68 ------------------- MediaBrowser.Server.Mac/MacAppHost.cs | 4 +- MediaBrowser.Server.Mac/Main.cs | 26 +++---- .../Native/MonoFileSystem.cs | 2 +- 4 files changed, 13 insertions(+), 87 deletions(-) diff --git a/MediaBrowser.Server.Mac.sln b/MediaBrowser.Server.Mac.sln index ba912566ac..051ea660bd 100644 --- a/MediaBrowser.Server.Mac.sln +++ b/MediaBrowser.Server.Mac.sln @@ -17,8 +17,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Model", "Media EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Providers", "MediaBrowser.Providers\MediaBrowser.Providers.csproj", "{442B5058-DCAF-4263-BB6A-F21E31120A1B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.Server.Implementations", "MediaBrowser.Server.Implementations\MediaBrowser.Server.Implementations.csproj", "{2E781478-814D-4A48-9D80-BFF206441A65}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.WebDashboard", "MediaBrowser.WebDashboard\MediaBrowser.WebDashboard.csproj", "{5624B7B5-B5A7-41D8-9F10-CC5611109619}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaBrowser.XbmcMetadata", "MediaBrowser.XbmcMetadata\MediaBrowser.XbmcMetadata.csproj", "{23499896-B135-4527-8574-C26E926EA99E}" @@ -41,8 +39,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RSSDP", "RSSDP\RSSDP.csproj EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.Drawing.Skia", "Emby.Drawing.Skia\Emby.Drawing.Skia.csproj", "{2312DA6D-FF86-4597-9777-BCEEC32D96DD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emby.Common.Implementations", "Emby.Common.Implementations\Emby.Common.Implementations.csproj", "{1E37A338-9F57-4B70-BD6D-BB9C591E319B}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SocketHttpListener", "SocketHttpListener\SocketHttpListener.csproj", "{1D74413B-E7CF-455B-B021-F52BDF881542}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Nat", "Mono.Nat\Mono.Nat.csproj", "{CB7F2326-6497-4A3D-BA03-48513B17A7BE}" @@ -210,26 +206,6 @@ Global {442B5058-DCAF-4263-BB6A-F21E31120A1B}.Signed|Any CPU.Build.0 = Release Mono|Any CPU {442B5058-DCAF-4263-BB6A-F21E31120A1B}.Signed|x86.ActiveCfg = Release Mono|Any CPU {442B5058-DCAF-4263-BB6A-F21E31120A1B}.Signed|x86.Build.0 = Release Mono|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.AppStore|Any CPU.ActiveCfg = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.AppStore|Any CPU.Build.0 = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.AppStore|x86.ActiveCfg = Release Mono|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.AppStore|x86.Build.0 = Release Mono|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Debug|x86.ActiveCfg = Debug|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Debug|x86.Build.0 = Debug|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release Mono|Any CPU.ActiveCfg = Release Mono|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release Mono|Any CPU.Build.0 = Release Mono|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release Mono|x86.ActiveCfg = Release Mono|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release Mono|x86.Build.0 = Release Mono|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release|Any CPU.Build.0 = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release|x86.ActiveCfg = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Release|x86.Build.0 = Release|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Signed|Any CPU.ActiveCfg = Release Mono|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Signed|Any CPU.Build.0 = Release Mono|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Signed|x86.ActiveCfg = Release Mono|Any CPU - {2E781478-814D-4A48-9D80-BFF206441A65}.Signed|x86.Build.0 = Release Mono|Any CPU {5624B7B5-B5A7-41D8-9F10-CC5611109619}.AppStore|Any CPU.ActiveCfg = Release|Any CPU {5624B7B5-B5A7-41D8-9F10-CC5611109619}.AppStore|Any CPU.Build.0 = Release|Any CPU {5624B7B5-B5A7-41D8-9F10-CC5611109619}.AppStore|x86.ActiveCfg = Release Mono|Any CPU @@ -470,50 +446,6 @@ Global {2312DA6D-FF86-4597-9777-BCEEC32D96DD}.Signed|x64.Build.0 = Release|Any CPU {2312DA6D-FF86-4597-9777-BCEEC32D96DD}.Signed|x86.ActiveCfg = Release|Any CPU {2312DA6D-FF86-4597-9777-BCEEC32D96DD}.Signed|x86.Build.0 = Release|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.AppStore|Any CPU.Build.0 = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.AppStore|x86.ActiveCfg = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.AppStore|x86.Build.0 = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Debug|x86.ActiveCfg = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Debug|x86.Build.0 = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Release Mono|Any CPU.ActiveCfg = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Release Mono|Any CPU.Build.0 = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Release Mono|x86.ActiveCfg = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Release Mono|x86.Build.0 = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Release|Any CPU.Build.0 = Release|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Release|x86.ActiveCfg = Release|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Release|x86.Build.0 = Release|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Signed|Any CPU.ActiveCfg = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Signed|Any CPU.Build.0 = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Signed|x86.ActiveCfg = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Signed|x86.Build.0 = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Debug|Win32.ActiveCfg = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Debug|Win32.Build.0 = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Debug|x64.ActiveCfg = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Debug|x64.Build.0 = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Release Mono|Mixed Platforms.ActiveCfg = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Release Mono|Mixed Platforms.Build.0 = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Release Mono|Win32.ActiveCfg = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Release Mono|Win32.Build.0 = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Release Mono|x64.ActiveCfg = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Release Mono|x64.Build.0 = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Release|Win32.ActiveCfg = Release|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Release|Win32.Build.0 = Release|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Release|x64.ActiveCfg = Release|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Release|x64.Build.0 = Release|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Signed|Mixed Platforms.ActiveCfg = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Signed|Mixed Platforms.Build.0 = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Signed|Win32.ActiveCfg = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Signed|Win32.Build.0 = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Signed|x64.ActiveCfg = Debug|Any CPU - {1E37A338-9F57-4B70-BD6D-BB9C591E319B}.Signed|x64.Build.0 = Debug|Any CPU {1D74413B-E7CF-455B-B021-F52BDF881542}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU {1D74413B-E7CF-455B-B021-F52BDF881542}.AppStore|Any CPU.Build.0 = Debug|Any CPU {1D74413B-E7CF-455B-B021-F52BDF881542}.AppStore|x86.ActiveCfg = Debug|Any CPU diff --git a/MediaBrowser.Server.Mac/MacAppHost.cs b/MediaBrowser.Server.Mac/MacAppHost.cs index 2f8ee983ca..7ad96d2bf2 100644 --- a/MediaBrowser.Server.Mac/MacAppHost.cs +++ b/MediaBrowser.Server.Mac/MacAppHost.cs @@ -19,11 +19,11 @@ namespace MediaBrowser.Server.Mac { public class MacAppHost : ApplicationHost { - public MacAppHost(ServerApplicationPaths applicationPaths, ILogManager logManager, StartupOptions options, IFileSystem fileSystem, IPowerManagement powerManagement, string releaseAssetFilename, IEnvironmentInfo environmentInfo, MediaBrowser.Controller.Drawing.IImageEncoder imageEncoder, ISystemEvents systemEvents, IMemoryStreamFactory memoryStreamFactory, MediaBrowser.Common.Net.INetworkManager networkManager, Action certificateGenerator, Func defaultUsernameFactory) : base(applicationPaths, logManager, options, fileSystem, powerManagement, releaseAssetFilename, environmentInfo, imageEncoder, systemEvents, memoryStreamFactory, networkManager, certificateGenerator, defaultUsernameFactory) + public MacAppHost(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) { } - public override bool CanSelfRestart + public override bool CanSelfRestart { get { diff --git a/MediaBrowser.Server.Mac/Main.cs b/MediaBrowser.Server.Mac/Main.cs index cedeeb22ec..e70ef01eb8 100644 --- a/MediaBrowser.Server.Mac/Main.cs +++ b/MediaBrowser.Server.Mac/Main.cs @@ -1,5 +1,4 @@ using MediaBrowser.Model.Logging; -using MediaBrowser.Server.Implementations; using System; using System.Diagnostics; using System.Globalization; @@ -20,21 +19,18 @@ using MonoMac.ObjCRuntime; using Emby.Server.Core; using Emby.Server.Core.Cryptography; using Emby.Server.Implementations; -using Emby.Common.Implementations.Logging; using Emby.Server.Implementations.Logging; -using Emby.Common.Implementations.EnvironmentInfo; using Emby.Server.Mac.Native; using Emby.Server.Implementations.IO; -using Emby.Common.Implementations.Networking; -using Emby.Common.Implementations.Cryptography; using Mono.Unix.Native; using MediaBrowser.Model.System; using MediaBrowser.Model.IO; -using Emby.Server.Implementations.Logging; using Emby.Drawing; using Emby.Drawing.Skia; using MediaBrowser.Controller.Drawing; using MediaBrowser.Model.Drawing; +using Emby.Server.Implementations.EnvironmentInfo; +using Emby.Server.Implementations.Networking; namespace MediaBrowser.Server.Mac { @@ -60,7 +56,7 @@ namespace MediaBrowser.Server.Mac var appPaths = CreateApplicationPaths(appFolderPath, customProgramDataPath); - var logManager = new NlogManager(appPaths.LogDirectoryPath, "server"); + var logManager = new SimpleLogManager(appPaths.LogDirectoryPath, "server"); logManager.ReloadLogger(LogSeverity.Info); logManager.AddConsoleOutput(); @@ -90,9 +86,7 @@ namespace MediaBrowser.Server.Mac // Within the mac bundle, go uo two levels then down into Resources folder var resourcesPath = Path.Combine(Path.GetDirectoryName(appFolderPath), "Resources"); - Action createDirectoryFn = (string obj) => Directory.CreateDirectory(obj); - - return new ServerApplicationPaths(programDataPath, appFolderPath, resourcesPath, createDirectoryFn); + return new ServerApplicationPaths(programDataPath, appFolderPath, resourcesPath); } /// @@ -161,7 +155,7 @@ namespace MediaBrowser.Server.Mac { var info = new EnvironmentInfo() { - CustomOperatingSystem = MediaBrowser.Model.System.OperatingSystem.OSX + OperatingSystem = MediaBrowser.Model.System.OperatingSystem.OSX }; var uname = GetUnixName(); @@ -186,23 +180,23 @@ namespace MediaBrowser.Server.Mac if (archX86.IsMatch(uname.machine)) { - info.CustomArchitecture = Architecture.X86; + info.SystemArchitecture = Architecture.X86; } else if (string.Equals(uname.machine, "x86_64", StringComparison.OrdinalIgnoreCase)) { - info.CustomArchitecture = Architecture.X64; + info.SystemArchitecture = Architecture.X64; } else if (uname.machine.StartsWith("arm", StringComparison.OrdinalIgnoreCase)) { - info.CustomArchitecture = Architecture.Arm; + info.SystemArchitecture = Architecture.Arm; } else if (System.Environment.Is64BitOperatingSystem) { - info.CustomArchitecture = Architecture.X64; + info.SystemArchitecture = Architecture.X64; } else { - info.CustomArchitecture = Architecture.X86; + info.SystemArchitecture = Architecture.X86; } return info; diff --git a/MediaBrowser.Server.Mac/Native/MonoFileSystem.cs b/MediaBrowser.Server.Mac/Native/MonoFileSystem.cs index 7aeff5ac8c..1fd140fb9e 100644 --- a/MediaBrowser.Server.Mac/Native/MonoFileSystem.cs +++ b/MediaBrowser.Server.Mac/Native/MonoFileSystem.cs @@ -1,4 +1,4 @@ -using Emby.Common.Implementations.IO; +using Emby.Server.Implementations.IO; using MediaBrowser.Model.Logging; using Mono.Unix.Native; using MediaBrowser.Model.System; From a38567e787a9b7c2b2f729c95103ef6ddb9344d2 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 22 Aug 2017 14:50:58 -0400 Subject: [PATCH 13/41] update mac project --- MediaBrowser.Server.Mac/Main.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/MediaBrowser.Server.Mac/Main.cs b/MediaBrowser.Server.Mac/Main.cs index e70ef01eb8..3863937f8a 100644 --- a/MediaBrowser.Server.Mac/Main.cs +++ b/MediaBrowser.Server.Mac/Main.cs @@ -119,10 +119,7 @@ namespace MediaBrowser.Server.Mac environmentInfo, imageEncoder, new SystemEvents(logManager.GetLogger("SystemEvents")), - new MemoryStreamProvider(), - new NetworkManager(logManager.GetLogger("NetworkManager")), - GenerateCertificate, - () => Environment.UserName); + new NetworkManager(logManager.GetLogger("NetworkManager"))); if (options.ContainsOption("-v")) { Console.WriteLine (AppHost.ApplicationVersion.ToString()); @@ -146,11 +143,6 @@ namespace MediaBrowser.Server.Mac } } - private static void GenerateCertificate(string certPath, string certHost, string certPassword) - { - CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, certPassword, _logger); - } - private static EnvironmentInfo GetEnvironmentInfo() { var info = new EnvironmentInfo() From 5ced09d169fa323a1db0d332cfbfed27b3e72c8c Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 23 Aug 2017 12:43:52 -0400 Subject: [PATCH 14/41] removed dead code --- Emby.Dlna/ContentDirectory/ControlHandler.cs | 18 ------------------ Emby.Dlna/Didl/DidlBuilder.cs | 14 -------------- 2 files changed, 32 deletions(-) diff --git a/Emby.Dlna/ContentDirectory/ControlHandler.cs b/Emby.Dlna/ContentDirectory/ControlHandler.cs index 5ce1d1925f..205f4e8900 100644 --- a/Emby.Dlna/ContentDirectory/ControlHandler.cs +++ b/Emby.Dlna/ContentDirectory/ControlHandler.cs @@ -508,23 +508,6 @@ namespace Emby.Dlna.ContentDirectory if (stubType.HasValue) { - if (stubType.Value == StubType.People) - { - var items = _libraryManager.GetPeopleItems(new InternalPeopleQuery - { - ItemId = item.Id - - }); - - var result = new QueryResult - { - Items = items.Select(i => new ServerItem(i)).ToArray(items.Count), - TotalRecordCount = items.Count - }; - - return ApplyPaging(result, startIndex, limit); - } - var person = item as Person; if (person != null) { @@ -1356,7 +1339,6 @@ namespace Emby.Dlna.ContentDirectory public enum StubType { Folder = 0, - People = 1, Latest = 2, Playlists = 3, Albums = 4, diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs index 65410bd67d..45becd482a 100644 --- a/Emby.Dlna/Didl/DidlBuilder.cs +++ b/Emby.Dlna/Didl/DidlBuilder.cs @@ -391,14 +391,6 @@ namespace Emby.Dlna.Didl private string GetDisplayName(BaseItem item, StubType? itemStubType, BaseItem context) { - if (itemStubType.HasValue && itemStubType.Value == StubType.People) - { - if (item is Video) - { - return _localization.GetLocalizedString("HeaderCastCrew"); - } - return _localization.GetLocalizedString("HeaderPeople"); - } if (itemStubType.HasValue && itemStubType.Value == StubType.Latest) { return _localization.GetLocalizedString("ViewTypeMusicLatest"); @@ -961,12 +953,6 @@ namespace Emby.Dlna.Didl private void AddCover(BaseItem item, BaseItem context, StubType? stubType, XmlWriter writer) { - if (stubType.HasValue && stubType.Value == StubType.People) - { - AddEmbeddedImageAsCover("people", writer); - return; - } - ImageDownloadInfo imageInfo = null; if (context is UserView) From db4e0a38e90c3b90a6e46d055396233b92a5aa19 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 23 Aug 2017 12:44:13 -0400 Subject: [PATCH 15/41] update mac project --- MediaBrowser.Server.Mac/Emby.Server.Mac.csproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/MediaBrowser.Server.Mac/Emby.Server.Mac.csproj b/MediaBrowser.Server.Mac/Emby.Server.Mac.csproj index 161a4076a0..fe9ab13fad 100644 --- a/MediaBrowser.Server.Mac/Emby.Server.Mac.csproj +++ b/MediaBrowser.Server.Mac/Emby.Server.Mac.csproj @@ -92,10 +92,6 @@ False ..\packages\Mono.Posix.4.0.0.0\lib\net40\Mono.Posix.dll - - ..\packages\NLog.4.4.12\lib\net45\NLog.dll - True - ..\packages\ServiceStack.Text.4.5.8\lib\net45\ServiceStack.Text.dll True From 4f7695556346e3d980bba7f7de8fe306084436e2 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 23 Aug 2017 12:45:04 -0400 Subject: [PATCH 16/41] fix MissingEpisodeProvider repeatedly adding and removing unaired items --- MediaBrowser.Providers/TV/MissingEpisodeProvider.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs index 45e10a76e4..cfe20c741f 100644 --- a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs @@ -191,6 +191,8 @@ namespace MediaBrowser.Providers.TV }); } + private const double UnairedEpisodeThresholdDays = 2; + /// /// Adds the missing episodes. /// @@ -248,8 +250,7 @@ namespace MediaBrowser.Providers.TV var targetSeries = DetermineAppropriateSeries(series, tuple.Item1); - var unairedThresholdDays = 2; - now = now.AddDays(0 - unairedThresholdDays); + now = now.AddDays(0 - UnairedEpisodeThresholdDays); if (airDate.Value < now) { @@ -329,9 +330,13 @@ namespace MediaBrowser.Providers.TV return true; } - if (!allowMissingEpisodes && i.Episode.IsMissingEpisode && !i.Episode.IsUnaired) + if (!allowMissingEpisodes && i.Episode.IsMissingEpisode) { - return true; + // If it's missing, but not unaired, remove it + if (!i.Episode.PremiereDate.HasValue || i.Episode.PremiereDate.Value.ToLocalTime().Date.AddDays(UnairedEpisodeThresholdDays) < DateTime.Now.Date) + { + return true; + } } return false; From 12854950f29180f65ac44aad756379081dc1c555 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 23 Aug 2017 12:45:58 -0400 Subject: [PATCH 17/41] add comment --- Emby.Server.Implementations/IO/LibraryMonitor.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Emby.Server.Implementations/IO/LibraryMonitor.cs b/Emby.Server.Implementations/IO/LibraryMonitor.cs index 1467d9426a..3994e2b007 100644 --- a/Emby.Server.Implementations/IO/LibraryMonitor.cs +++ b/Emby.Server.Implementations/IO/LibraryMonitor.cs @@ -85,6 +85,8 @@ namespace Emby.Server.Implementations.IO public bool IsPathLocked(string path) { + // This method is not used by the core but it used by auto-organize + var lockedPaths = _tempIgnoredPaths.Keys.ToList(); return lockedPaths.Any(i => _fileSystem.AreEqual(i, path) || _fileSystem.ContainsSubPath(i, path)); } From b04e80b28babc5a336f6c217d0604cb23b88dc8e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 23 Aug 2017 12:46:57 -0400 Subject: [PATCH 18/41] remove unused localization strings --- .../Emby.Server.Implementations.csproj | 1 - .../Localization/Core/core.json | 179 ------------------ .../Localization/Core/en-US.json | 14 -- .../Localization/LocalizationManager.cs | 2 +- 4 files changed, 1 insertion(+), 195 deletions(-) delete mode 100644 Emby.Server.Implementations/Localization/Core/core.json diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 2a45fb3151..1dbb10b488 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -698,7 +698,6 @@ - diff --git a/Emby.Server.Implementations/Localization/Core/core.json b/Emby.Server.Implementations/Localization/Core/core.json deleted file mode 100644 index 976faa8cbc..0000000000 --- a/Emby.Server.Implementations/Localization/Core/core.json +++ /dev/null @@ -1,179 +0,0 @@ -{ - "AppDeviceValues": "App: {0}, Device: {1}", - "UserDownloadingItemWithValues": "{0} is downloading {1}", - "FolderTypeMixed": "Mixed content", - "FolderTypeMovies": "Movies", - "FolderTypeMusic": "Music", - "FolderTypeAdultVideos": "Adult videos", - "FolderTypePhotos": "Photos", - "FolderTypeMusicVideos": "Music videos", - "FolderTypeHomeVideos": "Home videos", - "FolderTypeGames": "Games", - "FolderTypeBooks": "Books", - "FolderTypeTvShows": "TV", - "FolderTypeInherit": "Inherit", - "HeaderCastCrew": "Cast & Crew", - "HeaderPeople": "People", - "ValueSpecialEpisodeName": "Special - {0}", - "LabelChapterName": "Chapter {0}", - "NameSeasonNumber": "Season {0}", - "LabelExit": "Exit", - "LabelVisitCommunity": "Visit Community", - "LabelGithub": "Github", - "LabelApiDocumentation": "Api Documentation", - "LabelDeveloperResources": "Developer Resources", - "LabelBrowseLibrary": "Browse Library", - "LabelConfigureServer": "Configure Emby", - "LabelRestartServer": "Restart Server", - "CategorySync": "Sync", - "CategoryUser": "User", - "CategorySystem": "System", - "CategoryApplication": "Application", - "CategoryPlugin": "Plugin", - "NotificationOptionPluginError": "Plugin failure", - "NotificationOptionApplicationUpdateAvailable": "Application update available", - "NotificationOptionApplicationUpdateInstalled": "Application update installed", - "NotificationOptionPluginUpdateInstalled": "Plugin update installed", - "NotificationOptionPluginInstalled": "Plugin installed", - "NotificationOptionPluginUninstalled": "Plugin uninstalled", - "NotificationOptionVideoPlayback": "Video playback started", - "NotificationOptionAudioPlayback": "Audio playback started", - "NotificationOptionGamePlayback": "Game playback started", - "NotificationOptionVideoPlaybackStopped": "Video playback stopped", - "NotificationOptionAudioPlaybackStopped": "Audio playback stopped", - "NotificationOptionGamePlaybackStopped": "Game playback stopped", - "NotificationOptionTaskFailed": "Scheduled task failure", - "NotificationOptionInstallationFailed": "Installation failure", - "NotificationOptionNewLibraryContent": "New content added", - "NotificationOptionNewLibraryContentMultiple": "New content added (multiple)", - "NotificationOptionCameraImageUploaded": "Camera image uploaded", - "NotificationOptionUserLockedOut": "User locked out", - "NotificationOptionServerRestartRequired": "Server restart required", - "ViewTypePlaylists": "Playlists", - "ViewTypeMovies": "Movies", - "ViewTypeTvShows": "TV", - "ViewTypeGames": "Games", - "ViewTypeMusic": "Music", - "ViewTypeMusicGenres": "Genres", - "ViewTypeMusicArtists": "Artists", - "ViewTypeBoxSets": "Collections", - "ViewTypeChannels": "Channels", - "ViewTypeLiveTV": "Live TV", - "ViewTypeLiveTvNowPlaying": "Now Airing", - "ViewTypeLatestGames": "Latest Games", - "ViewTypeRecentlyPlayedGames": "Recently Played", - "ViewTypeGameFavorites": "Favorites", - "ViewTypeGameSystems": "Game Systems", - "ViewTypeGameGenres": "Genres", - "ViewTypeTvResume": "Resume", - "ViewTypeTvNextUp": "Next Up", - "ViewTypeTvLatest": "Latest", - "ViewTypeTvShowSeries": "Series", - "ViewTypeTvGenres": "Genres", - "ViewTypeTvFavoriteSeries": "Favorite Series", - "ViewTypeTvFavoriteEpisodes": "Favorite Episodes", - "ViewTypeMovieResume": "Resume", - "ViewTypeMovieLatest": "Latest", - "ViewTypeMovieMovies": "Movies", - "ViewTypeMovieCollections": "Collections", - "ViewTypeMovieFavorites": "Favorites", - "ViewTypeMovieGenres": "Genres", - "ViewTypeMusicLatest": "Latest", - "ViewTypeMusicPlaylists": "Playlists", - "ViewTypeMusicAlbums": "Albums", - "ViewTypeMusicAlbumArtists": "Album Artists", - "HeaderOtherDisplaySettings": "Display Settings", - "ViewTypeMusicSongs": "Songs", - "ViewTypeMusicFavorites": "Favorites", - "ViewTypeMusicFavoriteAlbums": "Favorite Albums", - "ViewTypeMusicFavoriteArtists": "Favorite Artists", - "ViewTypeMusicFavoriteSongs": "Favorite Songs", - "ViewTypeFolders": "Folders", - "ViewTypeLiveTvRecordingGroups": "Recordings", - "ViewTypeLiveTvChannels": "Channels", - "ScheduledTaskFailedWithName": "{0} failed", - "LabelRunningTimeValue": "Running time: {0}", - "ScheduledTaskStartedWithName": "{0} started", - "VersionNumber": "Version {0}", - "PluginInstalledWithName": "{0} was installed", - "PluginUpdatedWithName": "{0} was updated", - "PluginUninstalledWithName": "{0} was uninstalled", - "ItemAddedWithName": "{0} was added to the library", - "ItemRemovedWithName": "{0} was removed from the library", - "LabelIpAddressValue": "Ip address: {0}", - "DeviceOnlineWithName": "{0} is connected", - "UserOnlineFromDevice": "{0} is online from {1}", - "ProviderValue": "Provider: {0}", - "SubtitlesDownloadedForItem": "Subtitles downloaded for {0}", - "UserConfigurationUpdatedWithName": "User configuration has been updated for {0}", - "UserCreatedWithName": "User {0} has been created", - "UserPasswordChangedWithName": "Password has been changed for user {0}", - "UserDeletedWithName": "User {0} has been deleted", - "MessageServerConfigurationUpdated": "Server configuration has been updated", - "MessageNamedServerConfigurationUpdatedWithValue": "Server configuration section {0} has been updated", - "MessageApplicationUpdated": "Emby Server has been updated", - "FailedLoginAttemptWithUserName": "Failed login attempt from {0}", - "AuthenticationSucceededWithUserName": "{0} successfully authenticated", - "DeviceOfflineWithName": "{0} has disconnected", - "UserLockedOutWithName": "User {0} has been locked out", - "UserOfflineFromDevice": "{0} has disconnected from {1}", - "UserStartedPlayingItemWithValues": "{0} has started playing {1}", - "UserStoppedPlayingItemWithValues": "{0} has stopped playing {1}", - "SubtitlesDownloadedForItem": "Subtitles downloaded for {0}", - "SubtitleDownloadFailureForItem": "Subtitles failed to download for {0}", - "HeaderUnidentified": "Unidentified", - "HeaderImagePrimary": "Primary", - "HeaderImageBackdrop": "Backdrop", - "HeaderImageLogo": "Logo", - "HeaderUserPrimaryImage": "User Image", - "HeaderOverview": "Overview", - "HeaderShortOverview": "Short Overview", - "HeaderType": "Type", - "HeaderSeverity": "Severity", - "HeaderUser": "User", - "HeaderName": "Name", - "HeaderDate": "Date", - "HeaderPremiereDate": "Premiere Date", - "HeaderDateAdded": "Date Added", - "HeaderReleaseDate": "Release date", - "HeaderRuntime": "Runtime", - "HeaderPlayCount": "Play Count", - "HeaderSeason": "Season", - "HeaderSeasonNumber": "Season number", - "HeaderSeries": "Series:", - "HeaderNetwork": "Network", - "HeaderYear": "Year:", - "HeaderYears": "Years:", - "HeaderParentalRating": "Parental Rating", - "HeaderCommunityRating": "Community rating", - "HeaderTrailers": "Trailers", - "HeaderSpecials": "Specials", - "HeaderGameSystems": "Game Systems", - "HeaderPlayers": "Players:", - "HeaderAlbumArtists": "Album Artists", - "HeaderAlbums": "Albums", - "HeaderDisc": "Disc", - "HeaderTrack": "Track", - "HeaderAudio": "Audio", - "HeaderVideo": "Video", - "HeaderEmbeddedImage": "Embedded image", - "HeaderResolution": "Resolution", - "HeaderSubtitles": "Subtitles", - "HeaderGenres": "Genres", - "HeaderCountries": "Countries", - "HeaderStatus": "Status", - "HeaderTracks": "Tracks", - "HeaderMusicArtist": "Music artist", - "HeaderLocked": "Locked", - "HeaderStudios": "Studios", - "HeaderActor": "Actors", - "HeaderComposer": "Composers", - "HeaderDirector": "Directors", - "HeaderGuestStar": "Guest star", - "HeaderProducer": "Producers", - "HeaderWriter": "Writers", - "HeaderParentalRatings": "Parental Ratings", - "HeaderCommunityRatings": "Community ratings", - "StartupEmbyServerIsLoading": "Emby Server is loading. Please try again shortly.", - "DbUpgradeMessage": "Please wait while your Emby Server database is upgraded. {0}% complete." -} diff --git a/Emby.Server.Implementations/Localization/Core/en-US.json b/Emby.Server.Implementations/Localization/Core/en-US.json index 133644ff7b..c7f8652334 100644 --- a/Emby.Server.Implementations/Localization/Core/en-US.json +++ b/Emby.Server.Implementations/Localization/Core/en-US.json @@ -1,5 +1,4 @@ { - "DbUpgradeMessage": "Please wait while your Emby Server database is upgraded. {0}% complete.", "AppDeviceValues": "App: {0}, Device: {1}", "UserDownloadingItemWithValues": "{0} is downloading {1}", "FolderTypeMixed": "Mixed content", @@ -13,15 +12,12 @@ "FolderTypeBooks": "Books", "FolderTypeTvShows": "TV", "FolderTypeInherit": "Inherit", - "HeaderCastCrew": "Cast & Crew", - "HeaderPeople": "People", "ValueSpecialEpisodeName": "Special - {0}", "LabelChapterName": "Chapter {0}", "NameSeasonUnknown": "Season Unknown", "NameSeasonNumber": "Season {0}", "LabelExit": "Exit", "LabelVisitCommunity": "Visit Community", - "LabelGithub": "Github", "LabelApiDocumentation": "Api Documentation", "LabelDeveloperResources": "Developer Resources", "LabelBrowseLibrary": "Browse Library", @@ -164,15 +160,5 @@ "HeaderStatus": "Status", "HeaderTracks": "Tracks", "HeaderMusicArtist": "Music artist", - "HeaderLocked": "Locked", - "HeaderStudios": "Studios", - "HeaderActor": "Actors", - "HeaderComposer": "Composers", - "HeaderDirector": "Directors", - "HeaderGuestStar": "Guest star", - "HeaderProducer": "Producers", - "HeaderWriter": "Writers", - "HeaderParentalRatings": "Parental Ratings", - "HeaderCommunityRatings": "Community ratings", "StartupEmbyServerIsLoading": "Emby Server is loading. Please try again shortly." } \ No newline at end of file diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.cs index a8cd1dc04d..278a39cd1e 100644 --- a/Emby.Server.Implementations/Localization/LocalizationManager.cs +++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs @@ -335,7 +335,7 @@ namespace Emby.Server.Implementations.Localization const string prefix = "Core"; var key = prefix + culture; - return _dictionaries.GetOrAdd(key, k => GetDictionary(prefix, culture, "core.json")); + return _dictionaries.GetOrAdd(key, k => GetDictionary(prefix, culture, "en-US.json")); } private Dictionary GetDictionary(string prefix, string culture, string baseFilename) From 8732a603458ed32cf9e5834edc012b0409538294 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 23 Aug 2017 12:48:03 -0400 Subject: [PATCH 19/41] set season name in SeasonResolver --- .../Library/Resolvers/TV/SeasonResolver.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs index 84ceac65e6..830bd9d85c 100644 --- a/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/TV/SeasonResolver.cs @@ -1,6 +1,8 @@ -using MediaBrowser.Controller.Configuration; +using System.Globalization; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; +using MediaBrowser.Model.Globalization; using MediaBrowser.Naming.Common; using MediaBrowser.Naming.TV; @@ -17,15 +19,18 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV private readonly IServerConfigurationManager _config; private readonly ILibraryManager _libraryManager; + private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); + private readonly ILocalizationManager _localization; /// /// Initializes a new instance of the class. /// /// The config. - public SeasonResolver(IServerConfigurationManager config, ILibraryManager libraryManager) + public SeasonResolver(IServerConfigurationManager config, ILibraryManager libraryManager, ILocalizationManager localization) { _config = config; _libraryManager = libraryManager; + _localization = localization; } /// @@ -47,9 +52,13 @@ namespace Emby.Server.Implementations.Library.Resolvers.TV SeriesName = series.Name }; - if (season.IndexNumber.HasValue && season.IndexNumber.Value == 0) + if (season.IndexNumber.HasValue) { - season.Name = _config.Configuration.SeasonZeroDisplayName; + var seasonNumber = season.IndexNumber.Value; + + season.Name = seasonNumber == 0 ? + _config.Configuration.SeasonZeroDisplayName : + string.Format(_localization.GetLocalizedString("NameSeasonNumber"), seasonNumber.ToString(UsCulture)); } return season; From 636943be4b1674a14d09bef22471fd977bc56e11 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 23 Aug 2017 12:48:51 -0400 Subject: [PATCH 20/41] shorten package cache time --- .../Updates/InstallationManager.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index 4d1e1eaac7..393fb76e2f 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -277,15 +277,7 @@ namespace Emby.Server.Implementations.Updates private TimeSpan GetCacheLength() { - switch (GetSystemUpdateLevel()) - { - case PackageVersionClass.Beta: - return TimeSpan.FromMinutes(30); - case PackageVersionClass.Dev: - return TimeSpan.FromMinutes(3); - default: - return TimeSpan.FromHours(24); - } + return TimeSpan.FromMinutes(3); } protected PackageInfo[] FilterPackages(List packages) From f694ae7e95d7b6e682831ea26e5b2aa5b08fae55 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 23 Aug 2017 12:49:42 -0400 Subject: [PATCH 21/41] add null checks to ScheduleDirect --- .../LiveTv/Listings/SchedulesDirect.cs | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs index e12acf1408..6fe3615d38 100644 --- a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs +++ b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs @@ -247,7 +247,10 @@ namespace Emby.Server.Implementations.LiveTv.Listings ProgramAudio audioType = ProgramAudio.Stereo; bool repeat = programInfo.@new == null; - string newID = programInfo.programID + "T" + startAt.Ticks + "C" + channelId; + + var programId = programInfo.programID ?? string.Empty; + + string newID = programId + "T" + startAt.Ticks + "C" + channelId; if (programInfo.audioProperties != null) { @@ -300,7 +303,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings Etag = programInfo.md5 }; - var showId = programInfo.programID ?? string.Empty; + var showId = programId; if (!info.IsSeries) { @@ -339,11 +342,11 @@ namespace Emby.Server.Implementations.LiveTv.Listings if (details.descriptions != null) { - if (details.descriptions.description1000 != null) + if (details.descriptions.description1000 != null && details.descriptions.description1000.Count > 0) { info.Overview = details.descriptions.description1000[0].description; } - else if (details.descriptions.description100 != null) + else if (details.descriptions.description100 != null && details.descriptions.description100.Count > 0) { info.Overview = details.descriptions.description100[0].description; } @@ -351,16 +354,19 @@ namespace Emby.Server.Implementations.LiveTv.Listings if (info.IsSeries) { - info.SeriesId = programInfo.programID.Substring(0, 10); + info.SeriesId = programId.Substring(0, 10); if (details.metadata != null) { var gracenote = details.metadata.Find(x => x.Gracenote != null).Gracenote; - info.SeasonNumber = gracenote.season; - - if (gracenote.episode > 0) + if (gracenote != null) { - info.EpisodeNumber = gracenote.episode; + info.SeasonNumber = gracenote.season; + + if (gracenote.episode > 0) + { + info.EpisodeNumber = gracenote.episode; + } } } } From 6736f79abe3da4cdb8747ef83a02ff512230a614 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 23 Aug 2017 13:08:17 -0400 Subject: [PATCH 22/41] removed dead code --- Emby.Server.Implementations/Dto/DtoService.cs | 27 +++++-------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index 9dbf299ab8..c6243a0a6f 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -115,14 +115,10 @@ namespace Emby.Server.Implementations.Dto var programTuples = new List>(); var channelTuples = new List>(); - var refreshQueue = options.Fields.Contains(ItemFields.RefreshState) - ? _providerManager.GetRefreshQueue() - : null; - var index = 0; foreach (var item in items) { - var dto = GetBaseItemDtoInternal(item, options, refreshQueue, user, owner); + var dto = GetBaseItemDtoInternal(item, options, user, owner); var tvChannel = item as LiveTvChannel; if (tvChannel != null) @@ -176,11 +172,7 @@ namespace Emby.Server.Implementations.Dto { var syncDictionary = GetSyncedItemProgress(options); - var refreshQueue = options.Fields.Contains(ItemFields.RefreshState) - ? _providerManager.GetRefreshQueue() - : null; - - var dto = GetBaseItemDtoInternal(item, options, refreshQueue, user, owner); + var dto = GetBaseItemDtoInternal(item, options, user, owner); var tvChannel = item as LiveTvChannel; if (tvChannel != null) { @@ -312,7 +304,7 @@ namespace Emby.Server.Implementations.Dto } } - private BaseItemDto GetBaseItemDtoInternal(BaseItem item, DtoOptions options, Dictionary currentRefreshQueue, User user = null, BaseItem owner = null) + private BaseItemDto GetBaseItemDtoInternal(BaseItem item, DtoOptions options, User user = null, BaseItem owner = null) { var fields = options.Fields; @@ -412,14 +404,10 @@ namespace Emby.Server.Implementations.Dto dto.Etag = item.GetEtag(user); } - if (currentRefreshQueue != null) - { - //dto.RefreshState = item.GetRefreshState(currentRefreshQueue); - } - + var liveTvManager = _livetvManager(); if (item is ILiveTvRecording) { - _livetvManager().AddInfoToRecordingDto(item, dto, user); + liveTvManager.AddInfoToRecordingDto(item, dto, user); } return dto; @@ -427,10 +415,7 @@ namespace Emby.Server.Implementations.Dto public BaseItemDto GetItemByNameDto(BaseItem item, DtoOptions options, List taggedItems, Dictionary syncProgress, User user = null) { - var refreshQueue = options.Fields.Contains(ItemFields.RefreshState) - ? _providerManager.GetRefreshQueue() - : null; - var dto = GetBaseItemDtoInternal(item, options, refreshQueue, user); + var dto = GetBaseItemDtoInternal(item, options, user); if (taggedItems != null && options.Fields.Contains(ItemFields.ItemCounts)) { From 2d0c98733aa7cfe3337034bca815e807b203ac24 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 23 Aug 2017 13:27:53 -0400 Subject: [PATCH 23/41] normalize media source container --- Emby.Server.Implementations/Dto/DtoService.cs | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index c6243a0a6f..2ea88b52a4 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -369,6 +369,8 @@ namespace Emby.Server.Implementations.Dto { dto.MediaSources = _mediaSourceManager().GetStaticMediaSources(hasMediaSources, true, user); } + + NormalizeMediaSourceContainers(dto); } } @@ -413,6 +415,45 @@ namespace Emby.Server.Implementations.Dto return dto; } + private void NormalizeMediaSourceContainers(BaseItemDto dto) + { + foreach (var mediaSource in dto.MediaSources) + { + var container = mediaSource.Container; + if (string.IsNullOrWhiteSpace(container)) + { + continue; + } + var containers = container.Split(new[] { ',' }); + if (containers.Length < 2) + { + continue; + } + + var path = mediaSource.Path; + string fileExtensionContainer = null; + + if (!string.IsNullOrWhiteSpace(path)) + { + path = Path.GetExtension(path); + if (!string.IsNullOrWhiteSpace(path)) + { + path = Path.GetExtension(path); + if (!string.IsNullOrWhiteSpace(path)) + { + path = path.TrimStart('.'); + } + if (!string.IsNullOrWhiteSpace(path) && containers.Contains(path, StringComparer.OrdinalIgnoreCase)) + { + fileExtensionContainer = path; + } + } + } + + mediaSource.Container = fileExtensionContainer ?? containers[0]; + } + } + public BaseItemDto GetItemByNameDto(BaseItem item, DtoOptions options, List taggedItems, Dictionary syncProgress, User user = null) { var dto = GetBaseItemDtoInternal(item, options, user); From 26f6f594cee19f0af4e609659efdddb466dc8731 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 23 Aug 2017 14:00:42 -0400 Subject: [PATCH 24/41] improve handling of disconnected drives --- MediaBrowser.Controller/Entities/Folder.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index b088347842..11c0a57473 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -648,15 +648,15 @@ namespace MediaBrowser.Controller.Entities public static bool IsPathOffline(string path, List allLibraryPaths) { - if (FileSystem.FileExists(path)) - { - return false; - } + //if (FileSystem.FileExists(path)) + //{ + // return false; + //} var originalPath = path; // Depending on whether the path is local or unc, it may return either null or '\' at the top - while (!string.IsNullOrEmpty(path) && path.Length > 1) + while (!string.IsNullOrWhiteSpace(path) && path.Length > 1) { if (FileSystem.DirectoryExists(path)) { From af02f9d692a74749921815ab356c1180fcae6f08 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 23 Aug 2017 14:44:40 -0400 Subject: [PATCH 25/41] add mpdecimate option --- .../LiveTv/TunerHosts/M3UTunerHost.cs | 1 + .../MediaEncoding/EncodingHelper.cs | 10 ++++++++++ .../MediaEncoding/EncodingJobInfo.cs | 5 +++++ MediaBrowser.Model/Dto/MediaSourceInfo.cs | 1 + MediaBrowser.Model/LiveTv/LiveTvOptions.cs | 1 + 5 files changed, 18 insertions(+) diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs index 1bc334f062..eac8455791 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs @@ -165,6 +165,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts RequiresOpening = true, RequiresClosing = true, RequiresLooping = info.EnableStreamLooping, + EnableMpDecimate = info.EnableMpDecimate, ReadAtNativeFramerate = false, diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index d99103852a..736f1b32f5 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -778,6 +778,11 @@ namespace MediaBrowser.Controller.MediaEncoding return false; } + if (state.EnableMpDecimate) + { + return false; + } + if (videoStream.IsInterlaced) { if (request.DeInterlace) @@ -1449,6 +1454,11 @@ namespace MediaBrowser.Controller.MediaEncoding } } + if (state.EnableMpDecimate) + { + filters.Add("mpdecimate,setpts=N/FRAME_RATE/TB"); + } + if (filters.Count > 0) { output += string.Format(" -vf \"{0}\"", string.Join(",", filters.ToArray())); diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs index c2ce969792..e76217fda6 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs @@ -127,6 +127,11 @@ namespace MediaBrowser.Controller.MediaEncoding } } + public bool EnableMpDecimate + { + get { return MediaSource.EnableMpDecimate; } + } + public string AlbumCoverPath { get; set; } public string InputAudioSync { get; set; } diff --git a/MediaBrowser.Model/Dto/MediaSourceInfo.cs b/MediaBrowser.Model/Dto/MediaSourceInfo.cs index 488b1e7a86..8f3f0648d3 100644 --- a/MediaBrowser.Model/Dto/MediaSourceInfo.cs +++ b/MediaBrowser.Model/Dto/MediaSourceInfo.cs @@ -41,6 +41,7 @@ namespace MediaBrowser.Model.Dto public string OpenToken { get; set; } public bool RequiresClosing { get; set; } public bool SupportsProbing { get; set; } + public bool EnableMpDecimate { get; set; } public string LiveStreamId { get; set; } public int? BufferMs { get; set; } diff --git a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs index 15f60d8317..2c2f22e867 100644 --- a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs +++ b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs @@ -47,6 +47,7 @@ namespace MediaBrowser.Model.LiveTv public bool ImportFavoritesOnly { get; set; } public bool AllowHWTranscoding { get; set; } public bool EnableStreamLooping { get; set; } + public bool EnableMpDecimate { get; set; } public bool EnableNewHdhrChannelIds { get; set; } public string Source { get; set; } From d39a704b420a3a5a3fa835ec2bb32baf840f495a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 23 Aug 2017 15:21:20 -0400 Subject: [PATCH 26/41] update nuget --- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index e4eff48886..45a0529f9a 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.736 + 3.0.737 Emby.Common Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index f153d3e6b7..e5a0d454f0 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.736 + 3.0.737 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 82ab91f20971f46b8da97c0557fb0db38fe856bb Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 23 Aug 2017 15:45:40 -0400 Subject: [PATCH 27/41] add property to indicate support for on the fly subtitle extraction --- Emby.Dlna/Didl/DidlBuilder.cs | 2 +- .../Configuration/EncodingOptions.cs | 3 +- MediaBrowser.Model/Dlna/ITranscoderSupport.cs | 5 ++++ MediaBrowser.Model/Dlna/StreamBuilder.cs | 19 +++++++++---- MediaBrowser.Model/Dlna/StreamInfo.cs | 28 +++++++++---------- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +-- 7 files changed, 38 insertions(+), 25 deletions(-) diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs index 45becd482a..844a6a5ce6 100644 --- a/Emby.Dlna/Didl/DidlBuilder.cs +++ b/Emby.Dlna/Didl/DidlBuilder.cs @@ -236,7 +236,7 @@ namespace Emby.Dlna.Didl AddVideoResource(writer, video, deviceId, filter, contentFeature, streamInfo); } - var subtitleProfiles = streamInfo.GetSubtitleProfiles(false, _serverAddress, _accessToken) + var subtitleProfiles = streamInfo.GetSubtitleProfiles(_mediaEncoder, false, _serverAddress, _accessToken) .Where(subtitle => subtitle.DeliveryMethod == SubtitleDeliveryMethod.External) .ToList(); diff --git a/MediaBrowser.Model/Configuration/EncodingOptions.cs b/MediaBrowser.Model/Configuration/EncodingOptions.cs index d619e31409..b093d82e33 100644 --- a/MediaBrowser.Model/Configuration/EncodingOptions.cs +++ b/MediaBrowser.Model/Configuration/EncodingOptions.cs @@ -14,6 +14,7 @@ namespace MediaBrowser.Model.Configuration public int H264Crf { get; set; } public string H264Preset { get; set; } public bool EnableHardwareEncoding { get; set; } + public bool EnableSubtitleExtraction { get; set; } public string[] HardwareDecodingCodecs { get; set; } @@ -26,7 +27,7 @@ namespace MediaBrowser.Model.Configuration VaapiDevice = "/dev/dri/card0"; H264Crf = 23; EnableHardwareEncoding = true; - + EnableSubtitleExtraction = true; HardwareDecodingCodecs = new string[] { "h264", "vc1" }; } } diff --git a/MediaBrowser.Model/Dlna/ITranscoderSupport.cs b/MediaBrowser.Model/Dlna/ITranscoderSupport.cs index fd615733d3..14723bd273 100644 --- a/MediaBrowser.Model/Dlna/ITranscoderSupport.cs +++ b/MediaBrowser.Model/Dlna/ITranscoderSupport.cs @@ -4,6 +4,7 @@ { bool CanEncodeToAudioCodec(string codec); bool CanEncodeToSubtitleCodec(string codec); + bool CanExtractSubtitles(string codec); } public class FullTranscoderSupport : ITranscoderSupport @@ -16,5 +17,9 @@ { return true; } + public bool CanExtractSubtitles(string codec) + { + return true; + } } } diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index 1cb7836699..10c6a05c0f 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -686,7 +686,7 @@ namespace MediaBrowser.Model.Dlna if (subtitleStream != null) { - SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile.SubtitleProfiles, directPlay.Value, null, null); + SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile.SubtitleProfiles, directPlay.Value, _transcoderSupport, null, null); playlistItem.SubtitleDeliveryMethod = subtitleProfile.Method; playlistItem.SubtitleFormat = subtitleProfile.Format; @@ -728,7 +728,7 @@ namespace MediaBrowser.Model.Dlna if (subtitleStream != null) { - SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile.SubtitleProfiles, PlayMethod.Transcode, transcodingProfile.Protocol, transcodingProfile.Container); + SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile.SubtitleProfiles, PlayMethod.Transcode, _transcoderSupport, transcodingProfile.Protocol, transcodingProfile.Container); playlistItem.SubtitleDeliveryMethod = subtitleProfile.Method; playlistItem.SubtitleFormat = subtitleProfile.Format; @@ -1183,7 +1183,7 @@ namespace MediaBrowser.Model.Dlna { if (subtitleStream != null) { - SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile.SubtitleProfiles, playMethod, null, null); + SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile.SubtitleProfiles, playMethod, _transcoderSupport, null, null); if (subtitleProfile.Method != SubtitleDeliveryMethod.External && subtitleProfile.Method != SubtitleDeliveryMethod.Embed) { @@ -1202,7 +1202,7 @@ namespace MediaBrowser.Model.Dlna return new Tuple(result, TranscodeReason.ContainerBitrateExceedsLimit); } - public static SubtitleProfile GetSubtitleProfile(MediaStream subtitleStream, SubtitleProfile[] subtitleProfiles, PlayMethod playMethod, string transcodingSubProtocol, string transcodingContainer) + public static SubtitleProfile GetSubtitleProfile(MediaStream subtitleStream, SubtitleProfile[] subtitleProfiles, PlayMethod playMethod, ITranscoderSupport transcoderSupport, string transcodingSubProtocol, string transcodingContainer) { if (!subtitleStream.IsExternal && (playMethod != PlayMethod.Transcode || !string.Equals(transcodingSubProtocol, "hls", StringComparison.OrdinalIgnoreCase))) { @@ -1256,7 +1256,9 @@ namespace MediaBrowser.Model.Dlna } // Look for an external or hls profile that matches the stream type (text/graphical) and doesn't require conversion - return GetExternalSubtitleProfile(subtitleStream, subtitleProfiles, playMethod, false) ?? GetExternalSubtitleProfile(subtitleStream, subtitleProfiles, playMethod, true) ?? new SubtitleProfile + return GetExternalSubtitleProfile(subtitleStream, subtitleProfiles, playMethod, transcoderSupport, false) ?? + GetExternalSubtitleProfile(subtitleStream, subtitleProfiles, playMethod, transcoderSupport, true) ?? + new SubtitleProfile { Method = SubtitleDeliveryMethod.Encode, Format = subtitleStream.Codec @@ -1291,7 +1293,7 @@ namespace MediaBrowser.Model.Dlna return false; } - private static SubtitleProfile GetExternalSubtitleProfile(MediaStream subtitleStream, SubtitleProfile[] subtitleProfiles, PlayMethod playMethod, bool allowConversion) + private static SubtitleProfile GetExternalSubtitleProfile(MediaStream subtitleStream, SubtitleProfile[] subtitleProfiles, PlayMethod playMethod, ITranscoderSupport transcoderSupport, bool allowConversion) { foreach (SubtitleProfile profile in subtitleProfiles) { @@ -1310,6 +1312,11 @@ namespace MediaBrowser.Model.Dlna continue; } + if (!subtitleStream.IsExternal && !transcoderSupport.CanExtractSubtitles(subtitleStream.Codec)) + { + continue; + } + if ((profile.Method == SubtitleDeliveryMethod.External && subtitleStream.IsTextSubtitleStream == MediaStream.IsTextFormat(profile.Format)) || (profile.Method == SubtitleDeliveryMethod.Hls && subtitleStream.IsTextSubtitleStream)) { diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.cs index f863d8c954..c63e74eafa 100644 --- a/MediaBrowser.Model/Dlna/StreamInfo.cs +++ b/MediaBrowser.Model/Dlna/StreamInfo.cs @@ -309,14 +309,14 @@ namespace MediaBrowser.Model.Dlna return list; } - public List GetExternalSubtitles(bool includeSelectedTrackOnly, string baseUrl, string accessToken) + public List GetExternalSubtitles(ITranscoderSupport transcoderSupport, bool includeSelectedTrackOnly, string baseUrl, string accessToken) { - return GetExternalSubtitles(includeSelectedTrackOnly, false, baseUrl, accessToken); + return GetExternalSubtitles(transcoderSupport, includeSelectedTrackOnly, false, baseUrl, accessToken); } - public List GetExternalSubtitles(bool includeSelectedTrackOnly, bool enableAllProfiles, string baseUrl, string accessToken) + public List GetExternalSubtitles(ITranscoderSupport transcoderSupport, bool includeSelectedTrackOnly, bool enableAllProfiles, string baseUrl, string accessToken) { - List list = GetSubtitleProfiles(includeSelectedTrackOnly, enableAllProfiles, baseUrl, accessToken); + List list = GetSubtitleProfiles(transcoderSupport, includeSelectedTrackOnly, enableAllProfiles, baseUrl, accessToken); List newList = new List(); // First add the selected track @@ -331,12 +331,12 @@ namespace MediaBrowser.Model.Dlna return newList; } - public List GetSubtitleProfiles(bool includeSelectedTrackOnly, string baseUrl, string accessToken) + public List GetSubtitleProfiles(ITranscoderSupport transcoderSupport, bool includeSelectedTrackOnly, string baseUrl, string accessToken) { - return GetSubtitleProfiles(includeSelectedTrackOnly, false, baseUrl, accessToken); + return GetSubtitleProfiles(transcoderSupport, includeSelectedTrackOnly, false, baseUrl, accessToken); } - public List GetSubtitleProfiles(bool includeSelectedTrackOnly, bool enableAllProfiles, string baseUrl, string accessToken) + public List GetSubtitleProfiles(ITranscoderSupport transcoderSupport, bool includeSelectedTrackOnly, bool enableAllProfiles, string baseUrl, string accessToken) { List list = new List(); @@ -352,7 +352,7 @@ namespace MediaBrowser.Model.Dlna { if (stream.Type == MediaStreamType.Subtitle && stream.Index == SubtitleStreamIndex.Value) { - AddSubtitleProfiles(list, stream, enableAllProfiles, baseUrl, accessToken, startPositionTicks); + AddSubtitleProfiles(list, stream, transcoderSupport, enableAllProfiles, baseUrl, accessToken, startPositionTicks); } } } @@ -363,7 +363,7 @@ namespace MediaBrowser.Model.Dlna { if (stream.Type == MediaStreamType.Subtitle && (!SubtitleStreamIndex.HasValue || stream.Index != SubtitleStreamIndex.Value)) { - AddSubtitleProfiles(list, stream, enableAllProfiles, baseUrl, accessToken, startPositionTicks); + AddSubtitleProfiles(list, stream, transcoderSupport, enableAllProfiles, baseUrl, accessToken, startPositionTicks); } } } @@ -371,28 +371,28 @@ namespace MediaBrowser.Model.Dlna return list; } - private void AddSubtitleProfiles(List list, MediaStream stream, bool enableAllProfiles, string baseUrl, string accessToken, long startPositionTicks) + private void AddSubtitleProfiles(List list, MediaStream stream, ITranscoderSupport transcoderSupport, bool enableAllProfiles, string baseUrl, string accessToken, long startPositionTicks) { if (enableAllProfiles) { foreach (SubtitleProfile profile in DeviceProfile.SubtitleProfiles) { - SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks, new[] { profile }); + SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks, new[] { profile }, transcoderSupport); list.Add(info); } } else { - SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks, DeviceProfile.SubtitleProfiles); + SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks, DeviceProfile.SubtitleProfiles, transcoderSupport); list.Add(info); } } - private SubtitleStreamInfo GetSubtitleStreamInfo(MediaStream stream, string baseUrl, string accessToken, long startPositionTicks, SubtitleProfile[] subtitleProfiles) + private SubtitleStreamInfo GetSubtitleStreamInfo(MediaStream stream, string baseUrl, string accessToken, long startPositionTicks, SubtitleProfile[] subtitleProfiles, ITranscoderSupport transcoderSupport) { - SubtitleProfile subtitleProfile = StreamBuilder.GetSubtitleProfile(stream, subtitleProfiles, PlayMethod, SubProtocol, Container); + SubtitleProfile subtitleProfile = StreamBuilder.GetSubtitleProfile(stream, subtitleProfiles, PlayMethod, transcoderSupport, SubProtocol, Container); SubtitleStreamInfo info = new SubtitleStreamInfo { IsForced = stream.IsForced, diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 45a0529f9a..eb8a55b4c7 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.737 + 3.0.740 Emby.Common Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index e5a0d454f0..5c16159c73 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.737 + 3.0.740 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 afd94407f9bad2030344e93c1ce04008209a65af Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 23 Aug 2017 15:45:52 -0400 Subject: [PATCH 28/41] rework active recordings --- Emby.Server.Implementations/Dto/DtoService.cs | 15 ++ .../LiveTv/EmbyTV/EmbyTV.cs | 108 +++++++++++++-- .../LiveTv/EmbyTV/RecordingHelper.cs | 4 + .../LiveTv/LiveTvManager.cs | 129 ++++++++++++------ .../LiveTv/LiveTvMediaSourceProvider.cs | 22 ++- .../Entities/IHasMediaSources.cs | 2 +- MediaBrowser.Controller/Entities/Video.cs | 39 +++++- .../LiveTv/ILiveTvManager.cs | 4 + .../LiveTv/ILiveTvRecording.cs | 9 ++ MediaBrowser.Controller/LiveTv/TimerInfo.cs | 3 + 10 files changed, 270 insertions(+), 65 deletions(-) diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index 2ea88b52a4..17e91bfa88 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -411,6 +411,21 @@ namespace Emby.Server.Implementations.Dto { liveTvManager.AddInfoToRecordingDto(item, dto, user); } + else + { + var activeRecording = liveTvManager.GetActiveRecordingInfo(item.Path); + if (activeRecording != null) + { + dto.Type = "Recording"; + dto.CanDownload = false; + if (!string.IsNullOrWhiteSpace(dto.SeriesName)) + { + dto.EpisodeTitle = dto.Name; + dto.Name = dto.SeriesName; + } + liveTvManager.AddInfoToRecordingDto(item, dto, activeRecording, user); + } + } return dto; } diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index ecad5c0eb2..f3d40ae19e 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -830,6 +830,9 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV existingTimer.IsKids = updatedTimer.IsKids; existingTimer.IsNews = updatedTimer.IsNews; existingTimer.IsMovie = updatedTimer.IsMovie; + existingTimer.IsSeries = updatedTimer.IsSeries; + existingTimer.IsLive = updatedTimer.IsLive; + existingTimer.IsPremiere = updatedTimer.IsPremiere; existingTimer.IsProgramSeries = updatedTimer.IsProgramSeries; existingTimer.IsRepeat = updatedTimer.IsRepeat; existingTimer.IsSports = updatedTimer.IsSports; @@ -861,7 +864,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV public async Task> GetRecordingsAsync(CancellationToken cancellationToken) { - return _activeRecordings.Values.ToList().Select(GetRecordingInfo).ToList(); + return new List(); + //return _activeRecordings.Values.ToList().Select(GetRecordingInfo).ToList(); } public string GetActiveRecordingPath(string id) @@ -875,6 +879,28 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV return null; } + public IEnumerable GetAllActiveRecordings() + { + return _activeRecordings.Values; + } + + public ActiveRecordingInfo GetActiveRecordingInfo(string path) + { + if (string.IsNullOrWhiteSpace(path)) + { + return null; + } + + foreach (var recording in _activeRecordings.Values) + { + if (string.Equals(recording.Path, path, StringComparison.Ordinal)) + { + return recording; + } + } + return null; + } + private RecordingInfo GetRecordingInfo(ActiveRecordingInfo info) { var timer = info.Timer; @@ -1245,6 +1271,33 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV throw new FileNotFoundException(); } + public async Task> GetRecordingStreamMediaSources(ActiveRecordingInfo info, CancellationToken cancellationToken) + { + var stream = new MediaSourceInfo + { + Path = _appHost.GetLocalApiUrl("127.0.0.1") + "/LiveTv/LiveRecordings/" + info.Id + "/stream", + Id = info.Id, + SupportsDirectPlay = false, + SupportsDirectStream = true, + SupportsTranscoding = true, + IsInfiniteStream = true, + RequiresOpening = false, + RequiresClosing = false, + Protocol = MediaBrowser.Model.MediaInfo.MediaProtocol.Http, + BufferMs = 0, + IgnoreDts = true, + IgnoreIndex = true + }; + + var isAudio = false; + await new LiveStreamHelper(_mediaEncoder, _logger).AddMediaInfoWithProbe(stream, isAudio, cancellationToken).ConfigureAwait(false); + + return new List + { + stream + }; + } + public async Task CloseLiveStream(string id, CancellationToken cancellationToken) { // Ignore the consumer id @@ -1327,7 +1380,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV var activeRecordingInfo = new ActiveRecordingInfo { CancellationTokenSource = new CancellationTokenSource(), - Timer = timer + Timer = timer, + Id = timer.Id }; if (_activeRecordings.TryAdd(timer.Id, activeRecordingInfo)) @@ -1493,7 +1547,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV recordPath = recorder.GetOutputPath(mediaStreamInfo, recordPath); recordPath = EnsureFileUnique(recordPath, timer.Id); - _libraryManager.RegisterIgnoredPath(recordPath); _libraryMonitor.ReportFileSystemChangeBeginning(recordPath); _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(recordPath)); activeRecordingInfo.Path = recordPath; @@ -1512,6 +1565,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV _timerProvider.AddOrUpdate(timer, false); SaveRecordingMetadata(timer, recordPath, seriesPath); + TriggerRefresh(recordPath); EnforceKeepUpTo(timer, seriesPath); }; @@ -1543,7 +1597,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } } - _libraryManager.UnRegisterIgnoredPath(recordPath); + TriggerRefresh(recordPath); _libraryMonitor.ReportFileSystemChangeComplete(recordPath, true); ActiveRecordingInfo removed; @@ -1574,6 +1628,44 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV OnRecordingStatusChanged(); } + private void TriggerRefresh(string path) + { + var item = GetAffectedBaseItem(_fileSystem.GetDirectoryName(path)); + + if (item != null) + { + item.ChangedExternally(); + } + } + + private BaseItem GetAffectedBaseItem(string path) + { + BaseItem item = null; + + while (item == null && !string.IsNullOrEmpty(path)) + { + item = _libraryManager.FindByPath(path, null); + + path = _fileSystem.GetDirectoryName(path); + } + + if (item != null) + { + // If the item has been deleted find the first valid parent that still exists + while (!_fileSystem.DirectoryExists(item.Path) && !_fileSystem.FileExists(item.Path)) + { + item = item.GetParent(); + + if (item == null) + { + break; + } + } + } + + return item; + } + private void OnRecordingStatusChanged() { EventHelper.FireEventIfNotNull(RecordingStatusChanged, this, new RecordingStatusChangedEventArgs @@ -2621,14 +2713,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV return list; } - class ActiveRecordingInfo - { - public string Path { get; set; } - public TimerInfo Timer { get; set; } - public ProgramInfo Program { get; set; } - public CancellationTokenSource CancellationTokenSource { get; set; } - } - private const int TunerDiscoveryDurationMs = 3000; public async Task> DiscoverTuners(bool newDevicesOnly, CancellationToken cancellationToken) diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs index 94be4a02ef..b5de6ef01e 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs @@ -58,6 +58,10 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV timerInfo.OriginalAirDate = programInfo.OriginalAirDate; timerInfo.IsProgramSeries = programInfo.IsSeries; + timerInfo.IsSeries = programInfo.IsSeries; + timerInfo.IsLive = programInfo.IsLive; + timerInfo.IsPremiere = programInfo.IsPremiere; + timerInfo.HomePageUrl = programInfo.HomePageUrl; timerInfo.CommunityRating = programInfo.CommunityRating; timerInfo.Overview = programInfo.Overview; diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index 2882af007f..bf30546aba 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -60,7 +60,7 @@ namespace Emby.Server.Implementations.LiveTv private readonly LiveTvDtoService _tvDtoService; - private readonly List _services = new List(); + private ILiveTvService[] _services = new ILiveTvService[] { }; private readonly SemaphoreSlim _refreshRecordingsLock = new SemaphoreSlim(1, 1); @@ -124,7 +124,7 @@ namespace Emby.Server.Implementations.LiveTv /// The listing providers. public void AddParts(IEnumerable services, IEnumerable tunerHosts, IEnumerable listingProviders) { - _services.AddRange(services); + _services = services.ToArray(); _tunerHosts.AddRange(tunerHosts); _listingProviders.AddRange(listingProviders); @@ -1221,9 +1221,9 @@ namespace Emby.Server.Implementations.LiveTv await EmbyTV.EmbyTV.Current.ScanForTunerDeviceChanges(cancellationToken).ConfigureAwait(false); var numComplete = 0; - double progressPerService = _services.Count == 0 + double progressPerService = _services.Length == 0 ? 0 - : 1 / _services.Count; + : 1 / _services.Length; var newChannelIdList = new List(); var newProgramIdList = new List(); @@ -1255,7 +1255,7 @@ namespace Emby.Server.Implementations.LiveTv numComplete++; double percent = numComplete; - percent /= _services.Count; + percent /= _services.Length; progress.Report(100 * percent); } @@ -1561,11 +1561,6 @@ namespace Emby.Server.Implementations.LiveTv return new QueryResult(); } - if ((query.IsInProgress ?? false)) - { - return new QueryResult(); - } - var folderIds = EmbyTV.EmbyTV.Current.GetRecordingFolders() .SelectMany(i => i.Locations) .Distinct(StringComparer.OrdinalIgnoreCase) @@ -1577,13 +1572,10 @@ namespace Emby.Server.Implementations.LiveTv var excludeItemTypes = new List(); - if (!query.IsInProgress.HasValue) - { - folderIds.Add(internalLiveTvFolderId); + folderIds.Add(internalLiveTvFolderId); - excludeItemTypes.Add(typeof(LiveTvChannel).Name); - excludeItemTypes.Add(typeof(LiveTvProgram).Name); - } + excludeItemTypes.Add(typeof(LiveTvChannel).Name); + excludeItemTypes.Add(typeof(LiveTvProgram).Name); if (folderIds.Count == 0) { @@ -1632,6 +1624,19 @@ namespace Emby.Server.Implementations.LiveTv } } + if ((query.IsInProgress ?? false)) + { + // TODO: filter + var allActivePaths = EmbyTV.EmbyTV.Current.GetAllActiveRecordings().Select(i => i.Path).ToArray(); + var items = allActivePaths.Select(i => _libraryManager.FindByPath(i, false)).Where(i => i != null).ToArray(); + + return new QueryResult + { + Items = items, + TotalRecordCount = items.Length + }; + } + return _libraryManager.GetItemsResult(new InternalItemsQuery(user) { MediaTypes = new[] { MediaType.Video }, @@ -1659,11 +1664,6 @@ namespace Emby.Server.Implementations.LiveTv return new QueryResult(); } - if (_services.Count > 1) - { - return new QueryResult(); - } - if (user == null || (query.IsInProgress ?? false)) { return new QueryResult(); @@ -1722,13 +1722,9 @@ namespace Emby.Server.Implementations.LiveTv var folder = await GetInternalLiveTvFolder(cancellationToken).ConfigureAwait(false); - if (_services.Count == 1 && (!query.IsInProgress.HasValue || !query.IsInProgress.Value) && (!query.IsLibraryItem.HasValue || query.IsLibraryItem.Value)) + // TODO: Figure out how to merge emby recordings + service recordings + if (_services.Length == 1) { - if (!query.IsInProgress.HasValue) - { - await RefreshRecordings(folder.Id, cancellationToken).ConfigureAwait(false); - } - return GetEmbyRecordings(query, options, folder.Id, user); } @@ -1920,6 +1916,11 @@ namespace Emby.Server.Implementations.LiveTv await AddRecordingInfo(programTuples, CancellationToken.None).ConfigureAwait(false); } + public ActiveRecordingInfo GetActiveRecordingInfo(string path) + { + return EmbyTV.EmbyTV.Current.GetActiveRecordingInfo(path); + } + public void AddInfoToRecordingDto(BaseItem item, BaseItemDto dto, User user = null) { var recording = (ILiveTvRecording)item; @@ -1949,27 +1950,72 @@ namespace Emby.Server.Implementations.LiveTv dto.IsKids = info.IsKids; dto.IsPremiere = info.IsPremiere; - dto.CanDelete = user == null - ? recording.CanDelete() - : recording.CanDelete(user); - - if (dto.MediaSources == null) + if (info.Status == RecordingStatus.InProgress && info.EndDate.HasValue) { - dto.MediaSources = recording.GetMediaSources(true); + var now = DateTime.UtcNow.Ticks; + var start = info.StartDate.Ticks; + var end = info.EndDate.Value.Ticks; + + var pct = now - start; + pct /= end; + pct *= 100; + dto.CompletionPercentage = pct; } - if (dto.MediaStreams == null) + if (channel != null) { - dto.MediaStreams = dto.MediaSources.SelectMany(i => i.MediaStreams).ToArray(); + dto.ChannelName = channel.Name; + + if (channel.HasImage(ImageType.Primary)) + { + dto.ChannelPrimaryImageTag = _tvDtoService.GetImageTag(channel); + } } + } - if (info.Status == RecordingStatus.InProgress && info.EndDate.HasValue) + public void AddInfoToRecordingDto(BaseItem item, BaseItemDto dto, ActiveRecordingInfo activeRecordingInfo, User user = null) + { + var service = EmbyTV.EmbyTV.Current; + + var info = activeRecordingInfo.Timer; + + var channel = string.IsNullOrWhiteSpace(info.ChannelId) ? null : GetInternalChannel(_tvDtoService.GetInternalChannelId(service.Name, info.ChannelId)); + + dto.SeriesTimerId = string.IsNullOrEmpty(info.SeriesTimerId) + ? null + : _tvDtoService.GetInternalSeriesTimerId(service.Name, info.SeriesTimerId).ToString("N"); + + dto.TimerId = string.IsNullOrEmpty(info.Id) + ? null + : _tvDtoService.GetInternalTimerId(service.Name, info.Id).ToString("N"); + + var startDate = info.StartDate; + var endDate = info.EndDate; + + dto.StartDate = startDate; + dto.EndDate = endDate; + dto.Status = info.Status.ToString(); + dto.IsRepeat = info.IsRepeat; + dto.EpisodeTitle = info.EpisodeTitle; + dto.IsMovie = info.IsMovie; + dto.IsSeries = info.IsSeries; + dto.IsSports = info.IsSports; + dto.IsLive = info.IsLive; + dto.IsNews = info.IsNews; + dto.IsKids = info.IsKids; + dto.IsPremiere = info.IsPremiere; + + if (info.Status == RecordingStatus.InProgress) { + startDate = info.StartDate.AddSeconds(0 - info.PrePaddingSeconds); + endDate = info.EndDate.AddSeconds(info.PostPaddingSeconds); + var now = DateTime.UtcNow.Ticks; - var start = info.StartDate.Ticks; - var end = info.EndDate.Value.Ticks; + var start = startDate.Ticks; + var end = endDate.Ticks; var pct = now - start; + pct /= end; pct *= 100; dto.CompletionPercentage = pct; @@ -2098,7 +2144,6 @@ namespace Emby.Server.Implementations.LiveTv if (service is EmbyTV.EmbyTV) { - // We can't trust that we'll be able to direct stream it through emby server, no matter what the provider says return service.DeleteRecordingAsync(GetItemExternalId(recording), CancellationToken.None); } @@ -2348,7 +2393,6 @@ namespace Emby.Server.Implementations.LiveTv var currentChannelsDict = new Dictionary(); var addCurrentProgram = options.AddCurrentProgram; - var addMediaSources = options.Fields.Contains(ItemFields.MediaSources); var addServiceName = options.Fields.Contains(ItemFields.ServiceName); foreach (var tuple in tuples) @@ -2367,11 +2411,6 @@ namespace Emby.Server.Implementations.LiveTv currentChannelsDict[dto.Id] = dto; - if (addMediaSources) - { - dto.MediaSources = channel.GetMediaSources(true); - } - if (addCurrentProgram) { var channelIdString = channel.Id.ToString("N"); diff --git a/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs b/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs index 5436a12b8d..0e52f874d4 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs @@ -43,9 +43,11 @@ namespace Emby.Server.Implementations.LiveTv if (baseItem.SourceType == SourceType.LiveTV) { - if (string.IsNullOrWhiteSpace(baseItem.Path)) + var activeRecordingInfo = _liveTvManager.GetActiveRecordingInfo(item.Path); + + if (string.IsNullOrWhiteSpace(baseItem.Path) || activeRecordingInfo != null) { - return GetMediaSourcesInternal(item, cancellationToken); + return GetMediaSourcesInternal(item, activeRecordingInfo, cancellationToken); } } @@ -56,7 +58,7 @@ namespace Emby.Server.Implementations.LiveTv private const char StreamIdDelimeter = '_'; private const string StreamIdDelimeterString = "_"; - private async Task> GetMediaSourcesInternal(IHasMediaSources item, CancellationToken cancellationToken) + private async Task> GetMediaSourcesInternal(IHasMediaSources item, ActiveRecordingInfo activeRecordingInfo, CancellationToken cancellationToken) { IEnumerable sources; @@ -67,12 +69,20 @@ namespace Emby.Server.Implementations.LiveTv if (item is ILiveTvRecording) { sources = await _liveTvManager.GetRecordingMediaSources(item, cancellationToken) - .ConfigureAwait(false); + .ConfigureAwait(false); } else { - sources = await _liveTvManager.GetChannelMediaSources(item, cancellationToken) - .ConfigureAwait(false); + if (activeRecordingInfo != null) + { + sources = await EmbyTV.EmbyTV.Current.GetRecordingStreamMediaSources(activeRecordingInfo, cancellationToken) + .ConfigureAwait(false); + } + else + { + sources = await _liveTvManager.GetChannelMediaSources(item, cancellationToken) + .ConfigureAwait(false); + } } } catch (NotImplementedException) diff --git a/MediaBrowser.Controller/Entities/IHasMediaSources.cs b/MediaBrowser.Controller/Entities/IHasMediaSources.cs index bf4acdfbd6..54786134f3 100644 --- a/MediaBrowser.Controller/Entities/IHasMediaSources.cs +++ b/MediaBrowser.Controller/Entities/IHasMediaSources.cs @@ -4,7 +4,7 @@ using MediaBrowser.Model.Entities; namespace MediaBrowser.Controller.Entities { - public interface IHasMediaSources : IHasUserData + public interface IHasMediaSources : IHasMetadata { /// /// Gets the media sources. diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index fa11787f51..3918ac8fc1 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -160,7 +160,7 @@ namespace MediaBrowser.Controller.Entities public string[] GetPlayableStreamFileNames() { - return GetPlayableStreamFiles().Select(System.IO.Path.GetFileName).ToArray(); + return GetPlayableStreamFiles().Select(System.IO.Path.GetFileName).ToArray(); } /// @@ -234,6 +234,35 @@ namespace MediaBrowser.Controller.Entities return LocalAlternateVersions.Select(i => LibraryManager.GetNewItemId(i, typeof(Video))); } + [IgnoreDataMember] + public override SourceType SourceType + { + get + { + if (IsActiveRecording()) + { + return SourceType.LiveTV; + } + + return base.SourceType; + } + } + + protected bool IsActiveRecording() + { + return LiveTvManager.GetActiveRecordingInfo(Path) != null; + } + + public override bool CanDelete() + { + if (IsActiveRecording()) + { + return false; + } + + return base.CanDelete(); + } + [IgnoreDataMember] protected virtual bool EnableDefaultVideoUserDataKeys { @@ -616,6 +645,14 @@ namespace MediaBrowser.Controller.Entities var list = GetAllVideosForMediaSources(); var result = list.Select(i => GetVersionInfo(enablePathSubstitution, i.Item1, i.Item2)).ToList(); + if (IsActiveRecording()) + { + foreach (var mediaSource in result) + { + mediaSource.Type = MediaSourceType.Placeholder; + } + } + return result.OrderBy(i => { if (i.VideoType == VideoType.VideoFile) diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 862894f613..6ff630590a 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -384,5 +384,9 @@ namespace MediaBrowser.Controller.LiveTv string GetEmbyTvActiveRecordingPath(string id); Task GetEmbyTvLiveStream(string id); + + ActiveRecordingInfo GetActiveRecordingInfo(string path); + + void AddInfoToRecordingDto(BaseItem item, BaseItemDto dto, ActiveRecordingInfo activeRecordingInfo, User user = null); } } diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs b/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs index 43fc307f48..4b757f0b9b 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs @@ -36,4 +36,13 @@ namespace MediaBrowser.Controller.LiveTv DateTime? EndDate { get; set; } DateTime DateCreated { get; set; } } + + public class ActiveRecordingInfo + { + public string Id { get; set; } + public string Path { get; set; } + public TimerInfo Timer { get; set; } + public ProgramInfo Program { get; set; } + public CancellationTokenSource CancellationTokenSource { get; set; } + } } diff --git a/MediaBrowser.Controller/LiveTv/TimerInfo.cs b/MediaBrowser.Controller/LiveTv/TimerInfo.cs index 0b94c85fae..a0002241db 100644 --- a/MediaBrowser.Controller/LiveTv/TimerInfo.cs +++ b/MediaBrowser.Controller/LiveTv/TimerInfo.cs @@ -109,6 +109,9 @@ namespace MediaBrowser.Controller.LiveTv public bool IsKids { get; set; } public bool IsSports { get; set; } public bool IsNews { get; set; } + public bool IsSeries { get; set; } + public bool IsLive { get; set; } + public bool IsPremiere { get; set; } public int? ProductionYear { get; set; } public string EpisodeTitle { get; set; } public DateTime? OriginalAirDate { get; set; } From 5e0f8fd8c486ac37e487786c10c2d3f9e1293ce8 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 23 Aug 2017 16:12:27 -0400 Subject: [PATCH 29/41] add encoding option to dictate whether or not subtitles can be extracted on the fly --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SharedVersion.cs b/SharedVersion.cs index fba02a2b01..8a24a887f3 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.28.3")] +[assembly: AssemblyVersion("3.2.28.4")] From e441e2f53db0b587c9864fe91d7008a2344d147b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 24 Aug 2017 15:52:19 -0400 Subject: [PATCH 30/41] update active recordings --- .../ContentDirectory/ContentDirectory.cs | 18 +++- Emby.Dlna/Didl/Filter.cs | 7 +- Emby.Dlna/Didl/StringWriterWithEncoding.cs | 1 - Emby.Dlna/PlayTo/PlayToController.cs | 5 +- Emby.Dlna/Profiles/PanasonicVieraProfile.cs | 101 ------------------ Emby.Dlna/Ssdp/Extensions.cs | 9 +- Emby.Drawing.ImageMagick/ImageHelpers.cs | 6 +- .../ImageMagickEncoder.cs | 7 +- .../StripCollageBuilder.cs | 12 +-- Emby.Drawing/ImageProcessor.cs | 24 +++-- .../ApplicationHost.cs | 10 +- .../Channels/ChannelManager.cs | 2 +- .../Data/SqliteItemRepository.cs | 6 +- Emby.Server.Implementations/Dto/DtoService.cs | 2 +- .../Resolvers/SpecialFolderResolver.cs | 2 +- .../LiveTv/EmbyTV/EmbyTV.cs | 61 ++--------- .../Notifications/Notifications.cs | 4 +- .../Services/ServiceHandler.cs | 8 +- .../Sorting/ArtistComparer.cs | 2 +- .../Updates/InstallationManager.cs | 91 ++++++++++------ MediaBrowser.Api/ChannelService.cs | 2 +- MediaBrowser.Api/ConfigurationService.cs | 1 - MediaBrowser.Api/Devices/DeviceService.cs | 3 +- MediaBrowser.Api/Dlna/DlnaServerService.cs | 1 - MediaBrowser.Api/Dlna/DlnaService.cs | 4 +- MediaBrowser.Api/Images/ImageService.cs | 15 +-- MediaBrowser.Api/ItemUpdateService.cs | 2 +- MediaBrowser.Api/LocalizationService.cs | 1 - MediaBrowser.Api/Movies/CollectionService.cs | 1 - MediaBrowser.Api/Movies/MoviesService.cs | 2 +- MediaBrowser.Api/PlaylistService.cs | 4 +- .../Reports/Data/ReportBuilder.cs | 2 +- MediaBrowser.Api/SearchService.cs | 8 +- MediaBrowser.Api/SuggestionsService.cs | 1 - MediaBrowser.Api/TvShowsService.cs | 1 - .../UserLibrary/ArtistsService.cs | 2 +- .../UserLibrary/BaseItemsByNameService.cs | 12 +-- .../UserLibrary/GameGenresService.cs | 2 +- MediaBrowser.Api/UserLibrary/GenresService.cs | 2 +- .../UserLibrary/MusicGenresService.cs | 2 +- .../UserLibrary/PersonsService.cs | 12 +-- .../UserLibrary/StudiosService.cs | 6 +- MediaBrowser.Api/UserLibrary/YearsService.cs | 6 +- MediaBrowser.Api/VideosService.cs | 1 - .../Updates/IInstallationManager.cs | 4 +- .../Drawing/IImageProcessor.cs | 4 +- .../Entities/AggregateFolder.cs | 31 +++--- .../Entities/Audio/Audio.cs | 22 ++-- .../Entities/Audio/IHasAlbumArtist.cs | 16 +-- .../Entities/Audio/MusicAlbum.cs | 62 ++++++----- .../Entities/Audio/MusicArtist.cs | 20 ++-- .../Entities/Audio/MusicGenre.cs | 1 - MediaBrowser.Controller/Entities/BaseItem.cs | 2 +- MediaBrowser.Controller/Entities/Book.cs | 2 +- .../Entities/CollectionFolder.cs | 26 ++--- MediaBrowser.Controller/Entities/Game.cs | 1 - MediaBrowser.Controller/Entities/GameGenre.cs | 1 - MediaBrowser.Controller/Entities/Genre.cs | 1 - .../Entities/ICollectionFolder.cs | 2 +- .../Entities/InternalPeopleQuery.cs | 4 +- .../Entities/Movies/BoxSet.cs | 5 +- .../Entities/MusicVideo.cs | 6 +- .../Entities/PeopleHelper.cs | 10 +- MediaBrowser.Controller/Entities/Person.cs | 1 - MediaBrowser.Controller/Entities/Photo.cs | 12 ++- MediaBrowser.Controller/Entities/Studio.cs | 1 - MediaBrowser.Controller/Entities/TV/Season.cs | 2 +- MediaBrowser.Controller/Entities/TV/Series.cs | 10 +- MediaBrowser.Controller/Entities/User.cs | 19 +++- .../Entities/UserRootFolder.cs | 2 +- MediaBrowser.Controller/Entities/UserView.cs | 4 +- MediaBrowser.Controller/Entities/Year.cs | 1 - MediaBrowser.Controller/IO/FileData.cs | 11 +- .../Library/ItemResolveArgs.cs | 14 ++- .../Library/NameExtensions.cs | 44 -------- .../LiveTv/LiveTvAudioRecording.cs | 1 - .../LiveTv/LiveTvProgram.cs | 1 - .../LiveTv/LiveTvVideoRecording.cs | 1 - .../Providers/DirectoryService.cs | 16 ++- .../Providers/IDirectoryService.cs | 2 +- .../Providers/MetadataResult.cs | 11 +- MediaBrowser.Controller/Providers/SongInfo.cs | 5 +- .../Session/SessionInfo.cs | 15 ++- .../Images/EpisodeLocalImageProvider.cs | 71 ++++++------ .../Images/LocalImageProvider.cs | 1 - MediaBrowser.Model/Dto/BaseItemDto.cs | 2 +- MediaBrowser.Model/Dto/MediaSourceInfo.cs | 17 ++- MediaBrowser.Model/Extensions/ListHelper.cs | 11 +- .../Services/QueryParamCollection.cs | 67 +++++++++--- .../Updates/PackageVersionInfo.cs | 2 + .../Books/AudioBookMetadataService.cs | 4 +- .../Books/AudioPodcastMetadataService.cs | 4 +- .../BoxSets/BoxSetMetadataService.cs | 6 +- .../Chapters/ChapterManager.cs | 1 - .../Manager/GenericPriorityQueue.cs | 1 - .../Manager/GenericPriorityQueueNode.cs | 1 - .../Manager/IFixedSizePriorityQueue.cs | 1 - .../Manager/IPriorityQueue.cs | 1 - .../Manager/SimplePriorityQueue.cs | 1 - .../MediaInfo/AudioImageProvider.cs | 2 +- .../MediaInfo/FFProbeAudioInfo.cs | 2 +- .../Music/AlbumMetadataService.cs | 4 +- .../Music/ArtistMetadataService.cs | 2 +- .../Music/AudioMetadataService.cs | 4 +- .../Music/MusicVideoMetadataService.cs | 4 +- .../Playlists/PlaylistMetadataService.cs | 7 +- MediaBrowser.Server.Mono/Program.cs | 5 +- .../Native/LoopUtil.cs | 1 - MediaBrowser.XbmcMetadata/EntryPoint.cs | 1 - .../Parsers/MovieNfoParser.cs | 7 +- .../Savers/AlbumNfoSaver.cs | 5 +- .../Savers/ArtistNfoSaver.cs | 7 +- .../Savers/MovieNfoSaver.cs | 4 +- Mono.Nat/NatUtility.cs | 1 - Mono.Nat/Pmp/Searchers/PmpSearcher.cs | 1 - Mono.Nat/Upnp/Upnp.cs | 1 - Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- RSSDP/CustomHttpHeaders.cs | 1 - RSSDP/DeviceAvailableEventArgs.cs | 1 - RSSDP/DeviceEventArgs.cs | 1 - RSSDP/DeviceUnavailableEventArgs.cs | 1 - RSSDP/DiscoveredSsdpDevice.cs | 1 - RSSDP/DisposableManagedObjectBase.cs | 1 - RSSDP/IUPnPDeviceValidator.cs | 4 +- RSSDP/RequestReceivedEventArgs.cs | 1 - RSSDP/ResponseReceivedEventArgs.cs | 1 - RSSDP/SsdpCommunicationsServer.cs | 2 +- RSSDP/SsdpConstants.cs | 1 - RSSDP/SsdpDevice.cs | 7 +- RSSDP/SsdpDeviceExtensions.cs | 1 - RSSDP/SsdpDeviceIcon.cs | 1 - RSSDP/SsdpDeviceLocator.cs | 1 - RSSDP/SsdpDeviceLocatorBase.cs | 37 ++++--- RSSDP/SsdpDeviceProperties.cs | 1 - RSSDP/SsdpDeviceProperty.cs | 1 - RSSDP/SsdpDevicePublisher.cs | 1 - RSSDP/SsdpEmbeddedDevice.cs | 1 - RSSDP/SsdpRootDevice.cs | 1 - RSSDP/UPnP10DeviceValidator.cs | 10 +- SocketHttpListener/Net/BoundaryType.cs | 1 - SocketHttpListener/Net/CookieHelper.cs | 1 - SocketHttpListener/Net/EndPointManager.cs | 5 +- SocketHttpListener/Net/EntitySendFormat.cs | 1 - .../Net/HttpListenerResponse.Managed.cs | 1 - .../Net/HttpListenerResponse.cs | 1 - .../Net/HttpRequestStream.Managed.cs | 1 - SocketHttpListener/Net/HttpRequestStream.cs | 1 - .../Net/HttpResponseStream.Managed.cs | 1 - SocketHttpListener/Net/HttpResponseStream.cs | 1 - .../Net/HttpStatusDescription.cs | 1 - SocketHttpListener/Net/UriScheme.cs | 1 - SocketHttpListener/Net/WebHeaderCollection.cs | 12 +-- SocketHttpListener/Net/WebHeaderEncoding.cs | 1 - SocketHttpListener/Primitives/ICertificate.cs | 1 - .../Primitives/IStreamFactory.cs | 1 - .../Primitives/ITextEncoding.cs | 1 - 157 files changed, 571 insertions(+), 657 deletions(-) diff --git a/Emby.Dlna/ContentDirectory/ContentDirectory.cs b/Emby.Dlna/ContentDirectory/ContentDirectory.cs index 92d388e3b2..d547ad8d43 100644 --- a/Emby.Dlna/ContentDirectory/ContentDirectory.cs +++ b/Emby.Dlna/ContentDirectory/ContentDirectory.cs @@ -10,7 +10,6 @@ using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Logging; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.TV; using MediaBrowser.Model.Globalization; @@ -129,9 +128,20 @@ namespace Emby.Dlna.ContentDirectory } } - // No configuration so it's going to be pretty arbitrary - return _userManager.Users.FirstOrDefault(i => i.Policy.IsAdministrator) ?? - _userManager.Users.First(); + foreach (var user in _userManager.Users) + { + if (user.Policy.IsAdministrator) + { + return user; + } + } + + foreach (var user in _userManager.Users) + { + return user; + } + + return null; } public void Dispose() diff --git a/Emby.Dlna/Didl/Filter.cs b/Emby.Dlna/Didl/Filter.cs index 5e9aeb530a..2c9a1ea184 100644 --- a/Emby.Dlna/Didl/Filter.cs +++ b/Emby.Dlna/Didl/Filter.cs @@ -1,13 +1,12 @@ using MediaBrowser.Model.Extensions; using System; using System.Collections.Generic; -using System.Linq; namespace Emby.Dlna.Didl { public class Filter { - private readonly List _fields; + private readonly string[] _fields; private readonly bool _all; public Filter() @@ -20,9 +19,7 @@ namespace Emby.Dlna.Didl { _all = StringHelper.EqualsIgnoreCase(filter, "*"); - var list = (filter ?? string.Empty).Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).ToList(); - - _fields = list; + _fields = (filter ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } public bool Contains(string field) diff --git a/Emby.Dlna/Didl/StringWriterWithEncoding.cs b/Emby.Dlna/Didl/StringWriterWithEncoding.cs index 052d6610b1..b5c565801f 100644 --- a/Emby.Dlna/Didl/StringWriterWithEncoding.cs +++ b/Emby.Dlna/Didl/StringWriterWithEncoding.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/Emby.Dlna/PlayTo/PlayToController.cs b/Emby.Dlna/PlayTo/PlayToController.cs index d563b5addd..4b77f998d3 100644 --- a/Emby.Dlna/PlayTo/PlayToController.cs +++ b/Emby.Dlna/PlayTo/PlayToController.cs @@ -13,7 +13,6 @@ using MediaBrowser.Model.System; using System; using System.Collections.Generic; using System.Globalization; -using System.Linq; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common.Configuration; @@ -49,7 +48,7 @@ namespace Emby.Dlna.PlayTo { get { - var lastDateKnownActivity = new[] { _creationTime, _device.DateLastActivity }.Max(); + var lastDateKnownActivity = _creationTime > _device.DateLastActivity ? _creationTime : _device.DateLastActivity; if (DateTime.UtcNow >= lastDateKnownActivity.AddSeconds(120)) { @@ -565,7 +564,7 @@ namespace Emby.Dlna.PlayTo streamInfo.TargetVideoCodecTag, streamInfo.IsTargetAVC); - return list.FirstOrDefault(); + return list.Count == 0 ? null : list[0]; } return null; diff --git a/Emby.Dlna/Profiles/PanasonicVieraProfile.cs b/Emby.Dlna/Profiles/PanasonicVieraProfile.cs index 63c7e3a8e0..095788485b 100644 --- a/Emby.Dlna/Profiles/PanasonicVieraProfile.cs +++ b/Emby.Dlna/Profiles/PanasonicVieraProfile.cs @@ -30,107 +30,6 @@ namespace Emby.Dlna.Profiles TimelineOffsetSeconds = 10; - TranscodingProfiles = new[] - { - new TranscodingProfile - { - Container = "mp3", - AudioCodec = "mp3", - Type = DlnaProfileType.Audio - }, - new TranscodingProfile - { - Container = "ts", - AudioCodec = "ac3", - VideoCodec = "h264", - Type = DlnaProfileType.Video - }, - new TranscodingProfile - { - Container = "jpeg", - Type = DlnaProfileType.Photo - } - }; - - DirectPlayProfiles = new[] - { - new DirectPlayProfile - { - Container = "mpeg,mpg", - VideoCodec = "mpeg2video,mpeg4", - AudioCodec = "ac3,mp3,pcm_dvd", - Type = DlnaProfileType.Video - }, - - new DirectPlayProfile - { - Container = "mkv", - VideoCodec = "h264,mpeg2video", - AudioCodec = "aac,ac3,dca,mp3,mp2,pcm,dts", - Type = DlnaProfileType.Video - }, - - new DirectPlayProfile - { - Container = "ts", - VideoCodec = "h264,mpeg2video", - AudioCodec = "aac,mp3,mp2", - Type = DlnaProfileType.Video - }, - - new DirectPlayProfile - { - Container = "mp4,m4v", - VideoCodec = "h264", - AudioCodec = "aac,ac3,mp3,pcm", - Type = DlnaProfileType.Video - }, - - new DirectPlayProfile - { - Container = "mov", - VideoCodec = "h264", - AudioCodec = "aac,pcm", - Type = DlnaProfileType.Video - }, - - new DirectPlayProfile - { - Container = "avi", - VideoCodec = "mpeg4", - AudioCodec = "pcm", - Type = DlnaProfileType.Video - }, - - new DirectPlayProfile - { - Container = "flv", - VideoCodec = "h264", - AudioCodec = "aac", - Type = DlnaProfileType.Video - }, - - new DirectPlayProfile - { - Container = "mp3", - AudioCodec = "mp3", - Type = DlnaProfileType.Audio - }, - - new DirectPlayProfile - { - Container = "mp4", - AudioCodec = "aac", - Type = DlnaProfileType.Audio - }, - - new DirectPlayProfile - { - Container = "jpeg", - Type = DlnaProfileType.Photo - } - }; - ContainerProfiles = new[] { new ContainerProfile diff --git a/Emby.Dlna/Ssdp/Extensions.cs b/Emby.Dlna/Ssdp/Extensions.cs index 611bf7e022..41a361515b 100644 --- a/Emby.Dlna/Ssdp/Extensions.cs +++ b/Emby.Dlna/Ssdp/Extensions.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using System.Net; using System.Threading.Tasks; using System.Xml.Linq; @@ -24,10 +23,12 @@ namespace Emby.Dlna.Ssdp public static string GetDescendantValue(this XElement container, XName name) { - var node = container.Descendants(name) - .FirstOrDefault(); + foreach (var node in container.Descendants(name)) + { + return node.Value; + } - return node == null ? null : node.Value; + return null; } } } diff --git a/Emby.Drawing.ImageMagick/ImageHelpers.cs b/Emby.Drawing.ImageMagick/ImageHelpers.cs index c623c21aa2..8666933995 100644 --- a/Emby.Drawing.ImageMagick/ImageHelpers.cs +++ b/Emby.Drawing.ImageMagick/ImageHelpers.cs @@ -6,13 +6,13 @@ namespace Emby.Drawing.ImageMagick { internal static class ImageHelpers { - internal static List ProjectPaths(List paths, int count) + internal static List ProjectPaths(string[] paths, int count) { if (count <= 0) { throw new ArgumentOutOfRangeException("count"); } - if (paths.Count == 0) + if (paths.Length == 0) { throw new ArgumentOutOfRangeException("paths"); } @@ -24,7 +24,7 @@ namespace Emby.Drawing.ImageMagick return list.Take(count).ToList(); } - private static void AddToList(List list, List paths, int count) + private static void AddToList(List list, string[] paths, int count) { while (list.Count < count) { diff --git a/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs b/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs index ea8687de01..9abf85e70f 100644 --- a/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs +++ b/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs @@ -7,7 +7,6 @@ using MediaBrowser.Model.Drawing; using MediaBrowser.Model.Logging; using System; using System.IO; -using System.Linq; using MediaBrowser.Model.IO; using MediaBrowser.Model.System; @@ -306,15 +305,15 @@ namespace Emby.Drawing.ImageMagick if (ratio >= 1.4) { - new StripCollageBuilder(_appPaths, _fileSystem).BuildThumbCollage(options.InputPaths.ToList(), options.OutputPath, options.Width, options.Height); + new StripCollageBuilder(_appPaths, _fileSystem).BuildThumbCollage(options.InputPaths, options.OutputPath, options.Width, options.Height); } else if (ratio >= .9) { - new StripCollageBuilder(_appPaths, _fileSystem).BuildSquareCollage(options.InputPaths.ToList(), options.OutputPath, options.Width, options.Height); + new StripCollageBuilder(_appPaths, _fileSystem).BuildSquareCollage(options.InputPaths, options.OutputPath, options.Width, options.Height); } else { - new StripCollageBuilder(_appPaths, _fileSystem).BuildPosterCollage(options.InputPaths.ToList(), options.OutputPath, options.Width, options.Height); + new StripCollageBuilder(_appPaths, _fileSystem).BuildPosterCollage(options.InputPaths, options.OutputPath, options.Width, options.Height); } } diff --git a/Emby.Drawing.ImageMagick/StripCollageBuilder.cs b/Emby.Drawing.ImageMagick/StripCollageBuilder.cs index 63cf8fe5f9..26c6c868db 100644 --- a/Emby.Drawing.ImageMagick/StripCollageBuilder.cs +++ b/Emby.Drawing.ImageMagick/StripCollageBuilder.cs @@ -19,7 +19,7 @@ namespace Emby.Drawing.ImageMagick _fileSystem = fileSystem; } - public void BuildPosterCollage(List paths, string outputPath, int width, int height) + public void BuildPosterCollage(string[] paths, string outputPath, int width, int height) { using (var wand = BuildPosterCollageWand(paths, width, height)) { @@ -27,7 +27,7 @@ namespace Emby.Drawing.ImageMagick } } - public void BuildSquareCollage(List paths, string outputPath, int width, int height) + public void BuildSquareCollage(string[] paths, string outputPath, int width, int height) { using (var wand = BuildSquareCollageWand(paths, width, height)) { @@ -35,7 +35,7 @@ namespace Emby.Drawing.ImageMagick } } - public void BuildThumbCollage(List paths, string outputPath, int width, int height) + public void BuildThumbCollage(string[] paths, string outputPath, int width, int height) { using (var wand = BuildThumbCollageWand(paths, width, height)) { @@ -43,7 +43,7 @@ namespace Emby.Drawing.ImageMagick } } - private MagickWand BuildPosterCollageWand(List paths, int width, int height) + private MagickWand BuildPosterCollageWand(string[] paths, int width, int height) { var inputPaths = ImageHelpers.ProjectPaths(paths, 3); using (var wandImages = new MagickWand(inputPaths.ToArray())) @@ -108,7 +108,7 @@ namespace Emby.Drawing.ImageMagick } } - private MagickWand BuildThumbCollageWand(List paths, int width, int height) + private MagickWand BuildThumbCollageWand(string[] paths, int width, int height) { var inputPaths = ImageHelpers.ProjectPaths(paths, 4); using (var wandImages = new MagickWand(inputPaths.ToArray())) @@ -173,7 +173,7 @@ namespace Emby.Drawing.ImageMagick } } - private MagickWand BuildSquareCollageWand(List paths, int width, int height) + private MagickWand BuildSquareCollageWand(string[] paths, int width, int height) { var inputPaths = ImageHelpers.ProjectPaths(paths, 4); var outputWand = new MagickWand(width, height, new PixelWand("none", 1)); diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index bd23eba7aa..63fa5f1f5e 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -44,7 +44,7 @@ namespace Emby.Drawing /// Image processors are specialized metadata providers that run after the normal ones /// /// The image enhancers. - public IEnumerable ImageEnhancers { get; private set; } + public IImageEnhancer[] ImageEnhancers { get; private set; } /// /// The _logger @@ -71,7 +71,7 @@ namespace Emby.Drawing _libraryManager = libraryManager; _appPaths = appPaths; - ImageEnhancers = new List(); + ImageEnhancers = new IImageEnhancer[] {}; _saveImageSizeTimer = timerFactory.Create(SaveImageSizeCallback, null, Timeout.Infinite, Timeout.Infinite); ImageHelper.ImageProcessor = this; @@ -618,7 +618,7 @@ namespace Emby.Drawing var supportedEnhancers = GetSupportedEnhancers(item, image.Type); - return GetImageCacheTag(item, image, supportedEnhancers.ToList()); + return GetImageCacheTag(item, image, supportedEnhancers); } /// @@ -672,7 +672,7 @@ namespace Emby.Drawing /// Task{System.String}. public async Task GetEnhancedImage(IHasMetadata item, ImageType imageType, int imageIndex) { - var enhancers = GetSupportedEnhancers(item, imageType).ToList(); + var enhancers = GetSupportedEnhancers(item, imageType); var imageInfo = item.GetImageInfo(imageType, imageIndex); @@ -866,21 +866,25 @@ namespace Emby.Drawing _logger.Info("Completed creation of image collage and saved to {0}", options.OutputPath); } - public IEnumerable GetSupportedEnhancers(IHasMetadata item, ImageType imageType) + public List GetSupportedEnhancers(IHasMetadata item, ImageType imageType) { - return ImageEnhancers.Where(i => + var list = new List(); + + foreach (var i in ImageEnhancers) { try { - return i.Supports(item, imageType); + if (i.Supports(item, imageType)) + { + list.Add(i); + } } catch (Exception ex) { _logger.ErrorException("Error in image enhancer: {0}", ex, i.GetType().Name); - - return false; } - }); + } + return list; } private bool _disposed; diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index ea6c2aaf5f..6441fe4f2d 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -861,7 +861,7 @@ namespace Emby.Server.Implementations SecurityManager = new PluginSecurityManager(this, HttpClient, JsonSerializer, ApplicationPaths, LogManager, FileSystemManager, CryptographyProvider); RegisterSingleInstance(SecurityManager); - InstallationManager = new InstallationManager(LogManager.GetLogger("InstallationManager"), this, ApplicationPaths, HttpClient, JsonSerializer, SecurityManager, ConfigurationManager, FileSystemManager, CryptographyProvider); + InstallationManager = new InstallationManager(LogManager.GetLogger("InstallationManager"), this, ApplicationPaths, HttpClient, JsonSerializer, SecurityManager, ConfigurationManager, FileSystemManager, CryptographyProvider, PackageRuntime); RegisterSingleInstance(InstallationManager); ZipClient = new ZipClient(FileSystemManager); @@ -1048,6 +1048,14 @@ namespace Emby.Server.Implementations await ((UserManager)UserManager).Initialize().ConfigureAwait(false); } + protected virtual string PackageRuntime + { + get + { + return "netframework"; + } + } + public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths, bool isStartup) { logger.LogMultiline("Emby", LogSeverity.Info, GetBaseExceptionMessage(appPaths)); diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index 28a1503700..d8d69a62ed 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -1330,7 +1330,7 @@ namespace Emby.Server.Implementations.Channels var hasArtists = item as IHasArtist; if (hasArtists != null) { - hasArtists.Artists = info.Artists; + hasArtists.Artists = info.Artists.ToArray(); } var hasAlbumArtists = item as IHasAlbumArtist; diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 064a66cd0a..423ad2782b 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -1028,9 +1028,9 @@ namespace Emby.Server.Implementations.Data var hasArtists = item as IHasArtist; if (hasArtists != null) { - if (hasArtists.Artists.Count > 0) + if (hasArtists.Artists.Length > 0) { - artists = string.Join("|", hasArtists.Artists.ToArray()); + artists = string.Join("|", hasArtists.Artists); } } saveItemStatement.TryBind("@Artists", artists); @@ -1908,7 +1908,7 @@ namespace Emby.Server.Implementations.Data var hasArtists = item as IHasArtist; if (hasArtists != null && !reader.IsDBNull(index)) { - hasArtists.Artists = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList(); + hasArtists.Artists = reader.GetString(index).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); } index++; diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index 17e91bfa88..0282572708 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -1617,7 +1617,7 @@ namespace Emby.Server.Implementations.Dto return null; } - var supportedEnhancers = _imageProcessor.GetSupportedEnhancers(item, ImageType.Primary).ToList(); + var supportedEnhancers = _imageProcessor.GetSupportedEnhancers(item, ImageType.Primary); ImageSize size; diff --git a/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs b/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs index 6c7c1f052f..6a1f8ec6f2 100644 --- a/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs +++ b/Emby.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs @@ -53,7 +53,7 @@ namespace Emby.Server.Implementations.Library.Resolvers return new CollectionFolder { CollectionType = GetCollectionType(args), - PhysicalLocationsList = args.PhysicalLocations.ToList() + PhysicalLocationsList = args.PhysicalLocations }; } } diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index f3d40ae19e..2e12f46bf9 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -607,20 +607,22 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV var timer = _timerProvider.GetTimer(timerId); if (timer != null) { + timer.Status = RecordingStatus.Cancelled; + if (string.IsNullOrWhiteSpace(timer.SeriesTimerId) || isSeriesCancelled) { _timerProvider.Delete(timer); } else { - timer.Status = RecordingStatus.Cancelled; _timerProvider.AddOrUpdate(timer, false); } } ActiveRecordingInfo activeRecordingInfo; if (_activeRecordings.TryGetValue(timerId, out activeRecordingInfo)) - { + { + activeRecordingInfo.Timer = timer; activeRecordingInfo.CancellationTokenSource.Cancel(); } } @@ -865,7 +867,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV public async Task> GetRecordingsAsync(CancellationToken cancellationToken) { return new List(); - //return _activeRecordings.Values.ToList().Select(GetRecordingInfo).ToList(); } public string GetActiveRecordingPath(string id) @@ -881,7 +882,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV public IEnumerable GetAllActiveRecordings() { - return _activeRecordings.Values; + return _activeRecordings.Values.Where(i => i.Timer.Status == RecordingStatus.InProgress && !i.CancellationTokenSource.IsCancellationRequested); } public ActiveRecordingInfo GetActiveRecordingInfo(string path) @@ -893,59 +894,19 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV foreach (var recording in _activeRecordings.Values) { - if (string.Equals(recording.Path, path, StringComparison.Ordinal)) + if (string.Equals(recording.Path, path, StringComparison.Ordinal) && !recording.CancellationTokenSource.IsCancellationRequested) { + var timer = recording.Timer; + if (timer.Status != RecordingStatus.InProgress) + { + return null; + } return recording; } } return null; } - private RecordingInfo GetRecordingInfo(ActiveRecordingInfo info) - { - var timer = info.Timer; - var program = info.Program; - - var result = new RecordingInfo - { - ChannelId = timer.ChannelId, - CommunityRating = timer.CommunityRating, - DateLastUpdated = DateTime.UtcNow, - EndDate = timer.EndDate, - EpisodeTitle = timer.EpisodeTitle, - Genres = timer.Genres, - Id = "recording" + timer.Id, - IsKids = timer.IsKids, - IsMovie = timer.IsMovie, - IsNews = timer.IsNews, - IsRepeat = timer.IsRepeat, - IsSeries = timer.IsProgramSeries, - IsSports = timer.IsSports, - Name = timer.Name, - OfficialRating = timer.OfficialRating, - OriginalAirDate = timer.OriginalAirDate, - Overview = timer.Overview, - ProgramId = timer.ProgramId, - SeriesTimerId = timer.SeriesTimerId, - StartDate = timer.StartDate, - Status = RecordingStatus.InProgress, - TimerId = timer.Id - }; - - if (program != null) - { - result.Audio = program.Audio; - result.ImagePath = program.ImagePath; - result.ImageUrl = program.ImageUrl; - result.IsHD = program.IsHD; - result.IsLive = program.IsLive; - result.IsPremiere = program.IsPremiere; - result.ShowId = program.ShowId; - } - - return result; - } - public Task> GetTimersAsync(CancellationToken cancellationToken) { var excludeStatues = new List diff --git a/Emby.Server.Implementations/Notifications/Notifications.cs b/Emby.Server.Implementations/Notifications/Notifications.cs index f95b3f701a..ac3cc75647 100644 --- a/Emby.Server.Implementations/Notifications/Notifications.cs +++ b/Emby.Server.Implementations/Notifications/Notifications.cs @@ -422,7 +422,7 @@ namespace Emby.Server.Implementations.Notifications { var artists = hasArtist.AllArtists; - if (artists.Count > 0) + if (artists.Length > 0) { name = hasArtist.AllArtists[0] + " - " + name; } @@ -440,7 +440,7 @@ namespace Emby.Server.Implementations.Notifications name = item.SeriesName + " - " + name; } - if (item.Artists != null && item.Artists.Count > 0) + if (item.Artists != null && item.Artists.Length > 0) { name = item.Artists[0] + " - " + name; } diff --git a/Emby.Server.Implementations/Services/ServiceHandler.cs b/Emby.Server.Implementations/Services/ServiceHandler.cs index 526e62d398..f9fcfdbabd 100644 --- a/Emby.Server.Implementations/Services/ServiceHandler.cs +++ b/Emby.Server.Implementations/Services/ServiceHandler.cs @@ -215,13 +215,13 @@ namespace Emby.Server.Implementations.Services if (name == null) continue; //thank you ASP.NET var values = request.QueryString.GetValues(name); - if (values.Length == 1) + if (values.Count == 1) { map[name] = values[0]; } else { - for (var i = 0; i < values.Length; i++) + for (var i = 0; i < values.Count; i++) { map[name + (i == 0 ? "" : "#" + i)] = values[i]; } @@ -235,13 +235,13 @@ namespace Emby.Server.Implementations.Services if (name == null) continue; //thank you ASP.NET var values = request.FormData.GetValues(name); - if (values.Length == 1) + if (values.Count == 1) { map[name] = values[0]; } else { - for (var i = 0; i < values.Length; i++) + for (var i = 0; i < values.Count; i++) { map[name + (i == 0 ? "" : "#" + i)] = values[i]; } diff --git a/Emby.Server.Implementations/Sorting/ArtistComparer.cs b/Emby.Server.Implementations/Sorting/ArtistComparer.cs index edb195820f..616aff673d 100644 --- a/Emby.Server.Implementations/Sorting/ArtistComparer.cs +++ b/Emby.Server.Implementations/Sorting/ArtistComparer.cs @@ -36,7 +36,7 @@ namespace Emby.Server.Implementations.Sorting return string.Empty; } - return audio.Artists.Count == 0 ? null : audio.Artists[0]; + return audio.Artists.Length == 0 ? null : audio.Artists[0]; } /// diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index 393fb76e2f..75328a39a3 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -122,7 +122,10 @@ namespace Emby.Server.Implementations.Updates private readonly ICryptoProvider _cryptographyProvider; - public InstallationManager(ILogger logger, IApplicationHost appHost, IApplicationPaths appPaths, IHttpClient httpClient, IJsonSerializer jsonSerializer, ISecurityManager securityManager, IConfigurationManager config, IFileSystem fileSystem, ICryptoProvider cryptographyProvider) + // netframework or netcore + private readonly string _packageRuntime; + + public InstallationManager(ILogger logger, IApplicationHost appHost, IApplicationPaths appPaths, IHttpClient httpClient, IJsonSerializer jsonSerializer, ISecurityManager securityManager, IConfigurationManager config, IFileSystem fileSystem, ICryptoProvider cryptographyProvider, string packageRuntime) { if (logger == null) { @@ -140,6 +143,7 @@ namespace Emby.Server.Implementations.Updates _config = config; _fileSystem = fileSystem; _cryptographyProvider = cryptographyProvider; + _packageRuntime = packageRuntime; _logger = logger; } @@ -157,7 +161,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) @@ -171,7 +175,7 @@ namespace Emby.Server.Implementations.Updates { "systemid", _applicationHost.SystemId } }; - using (var json = await _httpClient.Post("https://www.mb3admin.com/admin/service/package/retrieveall", data, cancellationToken).ConfigureAwait(false)) + using (var json = await _httpClient.Post("https://www.mb3admin.com/admin/service/package/retrieveall?includeAllRuntimes=true", data, cancellationToken).ConfigureAwait(false)) { cancellationToken.ThrowIfCancellationRequested(); @@ -195,7 +199,7 @@ 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 @@ -209,7 +213,7 @@ namespace Emby.Server.Implementations.Updates UpdateCachedPackages(CancellationToken.None, false); } - return packages; + return FilterPackages(packages); } } catch (Exception) @@ -221,7 +225,7 @@ namespace Emby.Server.Implementations.Updates await UpdateCachedPackages(cancellationToken, true).ConfigureAwait(false); using (var stream = _fileSystem.OpenRead(PackageCachePath)) { - return _jsonSerializer.DeserializeFromStream(stream); + return FilterPackages(_jsonSerializer.DeserializeFromStream(stream)); } } @@ -244,7 +248,7 @@ namespace Emby.Server.Implementations.Updates var tempFile = await _httpClient.GetTempFile(new HttpRequestOptions { - Url = "https://www.mb3admin.com/admin/service/MB3Packages.json", + Url = "https://www.mb3admin.com/admin/service/EmbyPackages.json", CancellationToken = cancellationToken, Progress = new SimpleProgress() @@ -280,47 +284,74 @@ namespace Emby.Server.Implementations.Updates return TimeSpan.FromMinutes(3); } - protected PackageInfo[] FilterPackages(List packages) + protected List FilterPackages(IEnumerable packages) { + var list = new List(); foreach (var package in packages) { - package.versions = package.versions.Where(v => !string.IsNullOrWhiteSpace(v.sourceUrl)) - .OrderByDescending(GetPackageVersion).ToArray(); + var versions = new List(); + foreach (var version in package.versions) + { + if (string.IsNullOrWhiteSpace(version.sourceUrl)) + { + continue; + } + + if (string.IsNullOrWhiteSpace(version.runtimes) || version.runtimes.IndexOf(_packageRuntime, StringComparison.OrdinalIgnoreCase) == -1) + { + continue; + } + + versions.Add(version); + } + + package.versions = versions + .OrderByDescending(GetPackageVersion) + .ToArray(); + + if (package.versions.Length == 0) + { + continue; + } + + list.Add(package); } // Remove packages with no versions - return packages.Where(p => p.versions.Any()).ToArray(); + return list; } - protected PackageInfo[] FilterPackages(PackageInfo[] packages, string packageType, Version applicationVersion) + protected List FilterPackages(IEnumerable packages, string packageType, Version applicationVersion) { - foreach (var package in packages) - { - package.versions = package.versions.Where(v => !string.IsNullOrWhiteSpace(v.sourceUrl)) - .OrderByDescending(GetPackageVersion).ToArray(); - } + var packagesList = FilterPackages(packages); - IEnumerable packagesList = packages; + var returnList = new List(); - if (!string.IsNullOrWhiteSpace(packageType)) - { - packagesList = packagesList.Where(p => string.Equals(p.type, packageType, StringComparison.OrdinalIgnoreCase)); - } + var filterOnPackageType = !string.IsNullOrWhiteSpace(packageType); - // If an app version was supplied, filter the versions for each package to only include supported versions - if (applicationVersion != null) + foreach (var p in packagesList) { - foreach (var package in packages) + if (filterOnPackageType && !string.Equals(p.type, packageType, StringComparison.OrdinalIgnoreCase)) { - package.versions = package.versions.Where(v => IsPackageVersionUpToDate(v, applicationVersion)).ToArray(); + continue; } - } - // Remove packages with no versions - packagesList = packagesList.Where(p => p.versions.Any()); + // If an app version was supplied, filter the versions for each package to only include supported versions + if (applicationVersion != null) + { + p.versions = p.versions.Where(v => IsPackageVersionUpToDate(v, applicationVersion)).ToArray(); + } + + if (p.versions.Length == 0) + { + continue; + } + + returnList.Add(p); + } - return packagesList.ToArray(); + return returnList; } /// diff --git a/MediaBrowser.Api/ChannelService.cs b/MediaBrowser.Api/ChannelService.cs index c7ceb41bcb..35ac2b4828 100644 --- a/MediaBrowser.Api/ChannelService.cs +++ b/MediaBrowser.Api/ChannelService.cs @@ -231,7 +231,7 @@ namespace MediaBrowser.Api SortOrder = request.SortOrder, SortBy = (request.SortBy ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToArray(), Filters = request.GetFilters().ToArray(), - Fields = request.GetItemFields().ToArray() + Fields = request.GetItemFields() }, CancellationToken.None).ConfigureAwait(false); diff --git a/MediaBrowser.Api/ConfigurationService.cs b/MediaBrowser.Api/ConfigurationService.cs index 92128634e3..643ecd9c86 100644 --- a/MediaBrowser.Api/ConfigurationService.cs +++ b/MediaBrowser.Api/ConfigurationService.cs @@ -6,7 +6,6 @@ using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Serialization; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Threading.Tasks; using MediaBrowser.Controller.IO; diff --git a/MediaBrowser.Api/Devices/DeviceService.cs b/MediaBrowser.Api/Devices/DeviceService.cs index 544960f5f5..012f0ddb27 100644 --- a/MediaBrowser.Api/Devices/DeviceService.cs +++ b/MediaBrowser.Api/Devices/DeviceService.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Devices; @@ -143,7 +142,7 @@ namespace MediaBrowser.Api.Devices } else { - var file = Request.Files.First(); + var file = Request.Files.Length == 0 ? null : Request.Files[0]; var task = _deviceManager.AcceptCameraUpload(deviceId, file.InputStream, new LocalFileInfo { diff --git a/MediaBrowser.Api/Dlna/DlnaServerService.cs b/MediaBrowser.Api/Dlna/DlnaServerService.cs index fc8c0edf6b..389244aa96 100644 --- a/MediaBrowser.Api/Dlna/DlnaServerService.cs +++ b/MediaBrowser.Api/Dlna/DlnaServerService.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; using System.Globalization; using System.IO; -using System.Linq; using System.Threading.Tasks; using MediaBrowser.Controller.IO; diff --git a/MediaBrowser.Api/Dlna/DlnaService.cs b/MediaBrowser.Api/Dlna/DlnaService.cs index fa3287ebdd..4dd71f4463 100644 --- a/MediaBrowser.Api/Dlna/DlnaService.cs +++ b/MediaBrowser.Api/Dlna/DlnaService.cs @@ -1,7 +1,7 @@ -using MediaBrowser.Controller.Dlna; +using System.Linq; +using MediaBrowser.Controller.Dlna; using MediaBrowser.Controller.Net; using MediaBrowser.Model.Dlna; -using System.Linq; using MediaBrowser.Model.Services; namespace MediaBrowser.Api.Dlna diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs index 318360336a..309c7195ba 100644 --- a/MediaBrowser.Api/Images/ImageService.cs +++ b/MediaBrowser.Api/Images/ImageService.cs @@ -556,20 +556,7 @@ namespace MediaBrowser.Api.Images throw new ResourceNotFoundException(string.Format("{0} does not have an image of type {1}", item.Name, request.Type)); } - var supportedImageEnhancers = request.EnableImageEnhancers ? _imageProcessor.ImageEnhancers.Where(i => - { - try - { - return i.Supports(item, request.Type); - } - catch (Exception ex) - { - Logger.ErrorException("Error in image enhancer: {0}", ex, i.GetType().Name); - - return false; - } - - }).ToList() : new List(); + var supportedImageEnhancers = request.EnableImageEnhancers ? _imageProcessor.GetSupportedEnhancers(item, request.Type) : new List(); var cropwhitespace = request.Type == ImageType.Logo || request.Type == ImageType.Art diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index 56caf884bb..47bd46ea5d 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -352,7 +352,7 @@ namespace MediaBrowser.Api hasArtists.Artists = request .ArtistItems .Select(i => i.Name) - .ToList(); + .ToArray(); } } diff --git a/MediaBrowser.Api/LocalizationService.cs b/MediaBrowser.Api/LocalizationService.cs index 2c92505b17..56d32fc374 100644 --- a/MediaBrowser.Api/LocalizationService.cs +++ b/MediaBrowser.Api/LocalizationService.cs @@ -2,7 +2,6 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.Globalization; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.Services; namespace MediaBrowser.Api diff --git a/MediaBrowser.Api/Movies/CollectionService.cs b/MediaBrowser.Api/Movies/CollectionService.cs index 6511d31279..c63712f4cc 100644 --- a/MediaBrowser.Api/Movies/CollectionService.cs +++ b/MediaBrowser.Api/Movies/CollectionService.cs @@ -4,7 +4,6 @@ using MediaBrowser.Controller.Net; using MediaBrowser.Model.Collections; using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using MediaBrowser.Model.Services; diff --git a/MediaBrowser.Api/Movies/MoviesService.cs b/MediaBrowser.Api/Movies/MoviesService.cs index 7873c1cd38..3e42026b14 100644 --- a/MediaBrowser.Api/Movies/MoviesService.cs +++ b/MediaBrowser.Api/Movies/MoviesService.cs @@ -426,7 +426,7 @@ namespace MediaBrowser.Api.Movies { var people = _libraryManager.GetPeople(new InternalPeopleQuery { - PersonTypes = new List + PersonTypes = new string[] { PersonType.Director } diff --git a/MediaBrowser.Api/PlaylistService.cs b/MediaBrowser.Api/PlaylistService.cs index 07a976f396..54c995d3d1 100644 --- a/MediaBrowser.Api/PlaylistService.cs +++ b/MediaBrowser.Api/PlaylistService.cs @@ -1,11 +1,11 @@ -using MediaBrowser.Controller.Dto; +using System.Linq; +using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Playlists; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Playlists; using MediaBrowser.Model.Querying; -using System.Linq; using System.Threading.Tasks; using MediaBrowser.Model.Services; using MediaBrowser.Model.Extensions; diff --git a/MediaBrowser.Api/Reports/Data/ReportBuilder.cs b/MediaBrowser.Api/Reports/Data/ReportBuilder.cs index 6b10fcb05d..6a1502c7e6 100644 --- a/MediaBrowser.Api/Reports/Data/ReportBuilder.cs +++ b/MediaBrowser.Api/Reports/Data/ReportBuilder.cs @@ -533,7 +533,7 @@ namespace MediaBrowser.Api.Reports break; case HeaderMetadata.Tracks: - option.Column = (i, r) => this.GetObject>(i, (x) => x.Tracks.ToList(), new List /// The physical locations. - public IEnumerable PhysicalLocations + public string[] PhysicalLocations { get { var paths = string.IsNullOrWhiteSpace(Path) ? new string[] { } : new[] { Path }; - return AdditionalLocations == null ? paths : paths.Concat(AdditionalLocations); + return AdditionalLocations == null ? paths : paths.Concat(AdditionalLocations).ToArray(); } } diff --git a/MediaBrowser.Controller/Library/NameExtensions.cs b/MediaBrowser.Controller/Library/NameExtensions.cs index 693b7b2217..bab334a6d2 100644 --- a/MediaBrowser.Controller/Library/NameExtensions.cs +++ b/MediaBrowser.Controller/Library/NameExtensions.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Globalization; -using System.Linq; using MediaBrowser.Controller.Extensions; using MediaBrowser.Model.Extensions; @@ -9,25 +7,6 @@ namespace MediaBrowser.Controller.Library { public static class NameExtensions { - public static bool EqualsAny(IEnumerable names, string x) - { - x = NormalizeForComparison(x); - - return names.Any(y => string.Compare(x, y, StringComparison.OrdinalIgnoreCase) == 0); - //return names.Any(y => string.Compare(x, y, CultureInfo.InvariantCulture, CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace) == 0); - } - - private static string NormalizeForComparison(string name) - { - if (name == null) - { - return string.Empty; - } - - return name; - //return name.RemoveDiacritics(); - } - private static string RemoveDiacritics(string name) { if (name == null) @@ -44,27 +23,4 @@ namespace MediaBrowser.Controller.Library return names.DistinctBy(RemoveDiacritics, StringComparer.OrdinalIgnoreCase); } } - - public class DistinctNameComparer : IComparer, IEqualityComparer - { - public int Compare(string x, string y) - { - if (string.IsNullOrWhiteSpace(x) && string.IsNullOrWhiteSpace(y)) - { - return 0; - } - - return string.Compare(x.RemoveDiacritics(), y.RemoveDiacritics(), StringComparison.OrdinalIgnoreCase); - } - - public bool Equals(string x, string y) - { - return Compare(x, y) == 0; - } - - public int GetHashCode(string obj) - { - return (obj ?? string.Empty).GetHashCode(); - } - } } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs index 25bc10dec0..c29d732532 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs @@ -6,7 +6,6 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.LiveTv; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.Serialization; using System.Threading.Tasks; using MediaBrowser.Controller.Library; diff --git a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs index 3efbc41f1d..1607dbcba1 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs @@ -9,7 +9,6 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Providers; using MediaBrowser.Model.Serialization; -using MediaBrowser.Model.Extensions; namespace MediaBrowser.Controller.LiveTv { diff --git a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs index 2c26d35560..950949f37a 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs @@ -5,7 +5,6 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.LiveTv; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.Serialization; using System.Threading.Tasks; using MediaBrowser.Controller.Library; diff --git a/MediaBrowser.Controller/Providers/DirectoryService.cs b/MediaBrowser.Controller/Providers/DirectoryService.cs index 337bb23a48..d957470d3b 100644 --- a/MediaBrowser.Controller/Providers/DirectoryService.cs +++ b/MediaBrowser.Controller/Providers/DirectoryService.cs @@ -4,7 +4,6 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; - using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; @@ -73,14 +72,23 @@ namespace MediaBrowser.Controller.Providers return entries; } - public IEnumerable GetFiles(string path) + public List GetFiles(string path) { return GetFiles(path, false); } - public IEnumerable GetFiles(string path, bool clearCache) + public List GetFiles(string path, bool clearCache) { - return GetFileSystemEntries(path, clearCache).Where(i => !i.IsDirectory); + var list = new List(); + var items = GetFileSystemEntries(path, clearCache); + foreach (var item in items) + { + if (!item.IsDirectory) + { + list.Add(item); + } + } + return list; } public FileSystemMetadata GetFile(string path) diff --git a/MediaBrowser.Controller/Providers/IDirectoryService.cs b/MediaBrowser.Controller/Providers/IDirectoryService.cs index 3747039482..6f864f4be2 100644 --- a/MediaBrowser.Controller/Providers/IDirectoryService.cs +++ b/MediaBrowser.Controller/Providers/IDirectoryService.cs @@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Providers public interface IDirectoryService { FileSystemMetadata[] GetFileSystemEntries(string path); - IEnumerable GetFiles(string path); + List GetFiles(string path); FileSystemMetadata GetFile(string path); } } \ No newline at end of file diff --git a/MediaBrowser.Controller/Providers/MetadataResult.cs b/MediaBrowser.Controller/Providers/MetadataResult.cs index 99402a9694..5ed55ea162 100644 --- a/MediaBrowser.Controller/Providers/MetadataResult.cs +++ b/MediaBrowser.Controller/Providers/MetadataResult.cs @@ -1,7 +1,6 @@ using MediaBrowser.Controller.Entities; using System; using System.Collections.Generic; -using System.Linq; namespace MediaBrowser.Controller.Providers { @@ -51,7 +50,15 @@ namespace MediaBrowser.Controller.Providers UserDataList = new List(); } - var userData = UserDataList.FirstOrDefault(i => string.Equals(userId, i.UserId.ToString("N"), StringComparison.OrdinalIgnoreCase)); + UserItemData userData = null; + + foreach (var i in UserDataList) + { + if (string.Equals(userId, i.UserId.ToString("N"), StringComparison.OrdinalIgnoreCase)) + { + userData = i; + } + } if (userData == null) { diff --git a/MediaBrowser.Controller/Providers/SongInfo.cs b/MediaBrowser.Controller/Providers/SongInfo.cs index 988e931cd3..e3a6f5d37e 100644 --- a/MediaBrowser.Controller/Providers/SongInfo.cs +++ b/MediaBrowser.Controller/Providers/SongInfo.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; namespace MediaBrowser.Controller.Providers { @@ -6,11 +5,11 @@ namespace MediaBrowser.Controller.Providers { public string[] AlbumArtists { get; set; } public string Album { get; set; } - public List Artists { get; set; } + public string[] Artists { get; set; } public SongInfo() { - Artists = new List(); + Artists = EmptyStringArray; AlbumArtists = EmptyStringArray; } } diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index 265f4f544e..90c1de2f2b 100644 --- a/MediaBrowser.Controller/Session/SessionInfo.cs +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -2,7 +2,6 @@ using MediaBrowser.Model.Session; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Threading; @@ -194,7 +193,19 @@ namespace MediaBrowser.Controller.Session public bool ContainsUser(Guid userId) { - return (UserId ?? Guid.Empty) == userId || AdditionalUsers.Any(i => userId == new Guid(i.UserId)); + if ((UserId ?? Guid.Empty) == userId) + { + return true; + } + + foreach (var additionalUser in AdditionalUsers) + { + if (userId == new Guid(additionalUser.UserId)) + { + return true; + } + } + return false; } private readonly object _progressLock = new object(); diff --git a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs index 881d2a85a8..9195a9cd41 100644 --- a/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs +++ b/MediaBrowser.LocalMetadata/Images/EpisodeLocalImageProvider.cs @@ -4,10 +4,8 @@ using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; -using System.IO; using System.Linq; -using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; namespace MediaBrowser.LocalMetadata.Images @@ -40,49 +38,50 @@ namespace MediaBrowser.LocalMetadata.Images { var parentPath = _fileSystem.GetDirectoryName(item.Path); - var parentPathFiles = directoryService.GetFiles(parentPath) - .ToList(); + var parentPathFiles = directoryService.GetFiles(parentPath); var nameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(item.Path); return GetFilesFromParentFolder(nameWithoutExtension, parentPathFiles); } - private List GetFilesFromParentFolder(string filenameWithoutExtension, IEnumerable parentPathFiles) + private List GetFilesFromParentFolder(string filenameWithoutExtension, List parentPathFiles) { var thumbName = filenameWithoutExtension + "-thumb"; - return parentPathFiles - .Where(i => - { - if (i.IsDirectory) - { - return false; - } - - if (BaseItem.SupportedImageExtensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase)) - { - var currentNameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(i); - - if (string.Equals(filenameWithoutExtension, currentNameWithoutExtension, StringComparison.OrdinalIgnoreCase)) - { - return true; - } - - if (string.Equals(thumbName, currentNameWithoutExtension, StringComparison.OrdinalIgnoreCase)) - { - return true; - } - } - - return false; - }) - .Select(i => new LocalImageInfo - { - FileInfo = i, - Type = ImageType.Primary - }) - .ToList(); + var list = new List(1); + + foreach (var i in parentPathFiles) + { + if (i.IsDirectory) + { + continue; + } + + if (BaseItem.SupportedImageExtensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase)) + { + var currentNameWithoutExtension = _fileSystem.GetFileNameWithoutExtension(i); + + if (string.Equals(filenameWithoutExtension, currentNameWithoutExtension, StringComparison.OrdinalIgnoreCase)) + { + list.Add(new LocalImageInfo + { + FileInfo = i, + Type = ImageType.Primary + }); + } + + else if (string.Equals(thumbName, currentNameWithoutExtension, StringComparison.OrdinalIgnoreCase)) + { + list.Add(new LocalImageInfo + { + FileInfo = i, + Type = ImageType.Primary + }); + } + } + } + return list; } } } diff --git a/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs b/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs index ddfb703212..56a2c271f9 100644 --- a/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs +++ b/MediaBrowser.LocalMetadata/Images/LocalImageProvider.cs @@ -7,7 +7,6 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; - using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs index 8da20c9f5b..8bad650b53 100644 --- a/MediaBrowser.Model/Dto/BaseItemDto.cs +++ b/MediaBrowser.Model/Dto/BaseItemDto.cs @@ -432,7 +432,7 @@ namespace MediaBrowser.Model.Dto /// Gets or sets the artists. /// /// The artists. - public List Artists { get; set; } + public string[] Artists { get; set; } /// /// Gets or sets the artist items. diff --git a/MediaBrowser.Model/Dto/MediaSourceInfo.cs b/MediaBrowser.Model/Dto/MediaSourceInfo.cs index 8f3f0648d3..27920bdf39 100644 --- a/MediaBrowser.Model/Dto/MediaSourceInfo.cs +++ b/MediaBrowser.Model/Dto/MediaSourceInfo.cs @@ -2,7 +2,6 @@ using MediaBrowser.Model.Extensions; using MediaBrowser.Model.MediaInfo; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Session; @@ -91,19 +90,15 @@ namespace MediaBrowser.Model.Dto return; } - var internalStreams = MediaStreams - .Where(i => !i.IsExternal) - .ToList(); - - if (internalStreams.Count == 0) + var bitrate = 0; + foreach (var stream in MediaStreams) { - return; + if (!stream.IsExternal) + { + bitrate += stream.BitRate ?? 0; + } } - var bitrate = internalStreams - .Select(m => m.BitRate ?? 0) - .Sum(); - if (bitrate > 0) { Bitrate = bitrate; diff --git a/MediaBrowser.Model/Extensions/ListHelper.cs b/MediaBrowser.Model/Extensions/ListHelper.cs index cfcb229c8f..6fe1793dba 100644 --- a/MediaBrowser.Model/Extensions/ListHelper.cs +++ b/MediaBrowser.Model/Extensions/ListHelper.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; namespace MediaBrowser.Model.Extensions { @@ -13,7 +11,14 @@ namespace MediaBrowser.Model.Extensions throw new ArgumentNullException("value"); } - return list.Contains(value, StringComparer.OrdinalIgnoreCase); + foreach (var item in list) + { + if (string.Equals(item, value, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + } + return false; } public static bool ContainsAnyIgnoreCase(string[] list, string[] values) diff --git a/MediaBrowser.Model/Services/QueryParamCollection.cs b/MediaBrowser.Model/Services/QueryParamCollection.cs index a3e00f587c..e13e5fecac 100644 --- a/MediaBrowser.Model/Services/QueryParamCollection.cs +++ b/MediaBrowser.Model/Services/QueryParamCollection.cs @@ -58,9 +58,7 @@ namespace MediaBrowser.Model.Services { if (string.IsNullOrWhiteSpace(value)) { - var stringComparison = GetStringComparison(); - - var parameters = this.Where(p => string.Equals(key, p.Name, stringComparison)).ToArray(); + var parameters = GetItems(key); foreach (var p in parameters) { @@ -84,14 +82,6 @@ namespace MediaBrowser.Model.Services Add(key, value); } - /// - /// True if the collection contains a query parameter with the given name. - /// - public bool ContainsKey(string name) - { - return this.Any(p => p.Name == name); - } - /// /// Removes all parameters of the given name. /// @@ -106,16 +96,49 @@ namespace MediaBrowser.Model.Services { var stringComparison = GetStringComparison(); - return this.Where(p => string.Equals(p.Name, name, stringComparison)) - .Select(p => p.Value) - .FirstOrDefault(); + foreach (var pair in this) + { + if (string.Equals(pair.Name, name, stringComparison)) + { + return pair.Value; + } + } + + return null; + } + + public virtual List GetItems(string name) + { + var stringComparison = GetStringComparison(); + + var list = new List(); + + foreach (var pair in this) + { + if (string.Equals(pair.Name, name, stringComparison)) + { + list.Add(pair); + } + } + + return list; } - public virtual string[] GetValues(string name) + public virtual List GetValues(string name) { var stringComparison = GetStringComparison(); - return this.Where(p => string.Equals(p.Name, name, stringComparison)).Select(p => p.Value).ToArray(); + var list = new List(); + + foreach (var pair in this) + { + if (string.Equals(pair.Name, name, stringComparison)) + { + list.Add(pair.Value); + } + } + + return list; } public Dictionary ToDictionary() @@ -134,7 +157,17 @@ namespace MediaBrowser.Model.Services public IEnumerable Keys { - get { return this.Select(i => i.Name); } + get + { + var keys = new string[this.Count]; + + for (var i = 0; i < keys.Length; i++) + { + keys[i] = this[i].Name; + } + + return keys; + } } /// diff --git a/MediaBrowser.Model/Updates/PackageVersionInfo.cs b/MediaBrowser.Model/Updates/PackageVersionInfo.cs index 5e0631b3b7..3ac5181872 100644 --- a/MediaBrowser.Model/Updates/PackageVersionInfo.cs +++ b/MediaBrowser.Model/Updates/PackageVersionInfo.cs @@ -89,5 +89,7 @@ namespace MediaBrowser.Model.Updates public string targetFilename { get; set; } public string infoUrl { get; set; } + + public string runtimes { get; set; } } } \ No newline at end of file diff --git a/MediaBrowser.Providers/Books/AudioBookMetadataService.cs b/MediaBrowser.Providers/Books/AudioBookMetadataService.cs index b9e265d22e..834ec6cd39 100644 --- a/MediaBrowser.Providers/Books/AudioBookMetadataService.cs +++ b/MediaBrowser.Providers/Books/AudioBookMetadataService.cs @@ -23,9 +23,9 @@ namespace MediaBrowser.Providers.Books var sourceItem = source.Item; var targetItem = target.Item; - if (replaceData || targetItem.Artists.Count == 0) + if (replaceData || targetItem.Artists.Length == 0) { - targetItem.Artists = sourceItem.Artists.ToList(); + targetItem.Artists = sourceItem.Artists; } if (replaceData || string.IsNullOrEmpty(targetItem.Album)) diff --git a/MediaBrowser.Providers/Books/AudioPodcastMetadataService.cs b/MediaBrowser.Providers/Books/AudioPodcastMetadataService.cs index 2ea0a7ee96..09546e4b61 100644 --- a/MediaBrowser.Providers/Books/AudioPodcastMetadataService.cs +++ b/MediaBrowser.Providers/Books/AudioPodcastMetadataService.cs @@ -23,9 +23,9 @@ namespace MediaBrowser.Providers.Books var sourceItem = source.Item; var targetItem = target.Item; - if (replaceData || targetItem.Artists.Count == 0) + if (replaceData || targetItem.Artists.Length == 0) { - targetItem.Artists = sourceItem.Artists.ToList(); + targetItem.Artists = sourceItem.Artists; } if (replaceData || string.IsNullOrEmpty(targetItem.Album)) diff --git a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs index 81cd416050..12748a8a77 100644 --- a/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs +++ b/MediaBrowser.Providers/BoxSets/BoxSetMetadataService.cs @@ -41,11 +41,7 @@ namespace MediaBrowser.Providers.BoxSets if (mergeMetadataSettings) { - // Retain shortcut children - var linkedChildren = sourceItem.LinkedChildren.ToList(); - linkedChildren.AddRange(sourceItem.LinkedChildren.Where(i => i.Type == LinkedChildType.Shortcut)); - - targetItem.LinkedChildren = linkedChildren.ToArray(linkedChildren.Count); + targetItem.LinkedChildren = sourceItem.LinkedChildren; targetItem.Shares = sourceItem.Shares; } } diff --git a/MediaBrowser.Providers/Chapters/ChapterManager.cs b/MediaBrowser.Providers/Chapters/ChapterManager.cs index 3973d3de7b..d3e9efd820 100644 --- a/MediaBrowser.Providers/Chapters/ChapterManager.cs +++ b/MediaBrowser.Providers/Chapters/ChapterManager.cs @@ -13,7 +13,6 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; diff --git a/MediaBrowser.Providers/Manager/GenericPriorityQueue.cs b/MediaBrowser.Providers/Manager/GenericPriorityQueue.cs index 03bb0f68c9..e245476146 100644 --- a/MediaBrowser.Providers/Manager/GenericPriorityQueue.cs +++ b/MediaBrowser.Providers/Manager/GenericPriorityQueue.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/MediaBrowser.Providers/Manager/GenericPriorityQueueNode.cs b/MediaBrowser.Providers/Manager/GenericPriorityQueueNode.cs index e6e93e4433..ec908095f9 100644 --- a/MediaBrowser.Providers/Manager/GenericPriorityQueueNode.cs +++ b/MediaBrowser.Providers/Manager/GenericPriorityQueueNode.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/MediaBrowser.Providers/Manager/IFixedSizePriorityQueue.cs b/MediaBrowser.Providers/Manager/IFixedSizePriorityQueue.cs index 8da88e1c6f..a49d42acaa 100644 --- a/MediaBrowser.Providers/Manager/IFixedSizePriorityQueue.cs +++ b/MediaBrowser.Providers/Manager/IFixedSizePriorityQueue.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/MediaBrowser.Providers/Manager/IPriorityQueue.cs b/MediaBrowser.Providers/Manager/IPriorityQueue.cs index 425992b18b..23f08a13e2 100644 --- a/MediaBrowser.Providers/Manager/IPriorityQueue.cs +++ b/MediaBrowser.Providers/Manager/IPriorityQueue.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs b/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs index f4c261a810..879ae1dca4 100644 --- a/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs +++ b/MediaBrowser.Providers/Manager/SimplePriorityQueue.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs index b8b6032452..a4f2053a9d 100644 --- a/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/AudioImageProvider.cs @@ -93,7 +93,7 @@ namespace MediaBrowser.Providers.MediaInfo private string GetAudioImagePath(Audio item) { var filename = item.Album ?? string.Empty; - filename += string.Join(",", item.Artists.ToArray(item.Artists.Count)); + filename += string.Join(",", item.Artists); if (!string.IsNullOrWhiteSpace(item.Album)) { diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs index fb1fed8b3f..b0785298b8 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.ToList(); + audio.Artists = data.Artists; audio.AlbumArtists = data.AlbumArtists; audio.IndexNumber = data.IndexNumber; audio.ParentIndexNumber = data.ParentIndexNumber; diff --git a/MediaBrowser.Providers/Music/AlbumMetadataService.cs b/MediaBrowser.Providers/Music/AlbumMetadataService.cs index fe39a841e4..4230c517ae 100644 --- a/MediaBrowser.Providers/Music/AlbumMetadataService.cs +++ b/MediaBrowser.Providers/Music/AlbumMetadataService.cs @@ -106,7 +106,7 @@ namespace MediaBrowser.Providers.Music .SelectMany(i => i.Artists) .Distinct(StringComparer.OrdinalIgnoreCase) .OrderBy(i => i) - .ToList(); + .ToArray(); if (!item.Artists.SequenceEqual(artists, StringComparer.OrdinalIgnoreCase)) { @@ -158,7 +158,7 @@ namespace MediaBrowser.Providers.Music var sourceItem = source.Item; var targetItem = target.Item; - if (replaceData || targetItem.Artists.Count == 0) + if (replaceData || targetItem.Artists.Length == 0) { targetItem.Artists = sourceItem.Artists; } diff --git a/MediaBrowser.Providers/Music/ArtistMetadataService.cs b/MediaBrowser.Providers/Music/ArtistMetadataService.cs index c8008ba1ec..0ff161576f 100644 --- a/MediaBrowser.Providers/Music/ArtistMetadataService.cs +++ b/MediaBrowser.Providers/Music/ArtistMetadataService.cs @@ -31,7 +31,7 @@ namespace MediaBrowser.Providers.Music }) : item.GetRecursiveChildren(i => i is IHasArtist && !i.IsFolder); - var currentList = item.Genres.ToList(); + var currentList = item.Genres; item.Genres = taggedItems.SelectMany(i => i.Genres) .DistinctNames() diff --git a/MediaBrowser.Providers/Music/AudioMetadataService.cs b/MediaBrowser.Providers/Music/AudioMetadataService.cs index 68a4fcd7cb..f02eae19fc 100644 --- a/MediaBrowser.Providers/Music/AudioMetadataService.cs +++ b/MediaBrowser.Providers/Music/AudioMetadataService.cs @@ -21,9 +21,9 @@ namespace MediaBrowser.Providers.Music var sourceItem = source.Item; var targetItem = target.Item; - if (replaceData || targetItem.Artists.Count == 0) + if (replaceData || targetItem.Artists.Length == 0) { - targetItem.Artists = sourceItem.Artists.ToList(); + targetItem.Artists = sourceItem.Artists; } if (replaceData || string.IsNullOrEmpty(targetItem.Album)) diff --git a/MediaBrowser.Providers/Music/MusicVideoMetadataService.cs b/MediaBrowser.Providers/Music/MusicVideoMetadataService.cs index 27c6deb740..28504dbd74 100644 --- a/MediaBrowser.Providers/Music/MusicVideoMetadataService.cs +++ b/MediaBrowser.Providers/Music/MusicVideoMetadataService.cs @@ -28,9 +28,9 @@ namespace MediaBrowser.Providers.Music targetItem.Album = sourceItem.Album; } - if (replaceData || targetItem.Artists.Count == 0) + if (replaceData || targetItem.Artists.Length == 0) { - targetItem.Artists = sourceItem.Artists.ToList(); + targetItem.Artists = sourceItem.Artists; } } diff --git a/MediaBrowser.Providers/Playlists/PlaylistMetadataService.cs b/MediaBrowser.Providers/Playlists/PlaylistMetadataService.cs index dccef3a09a..d39d3baf5d 100644 --- a/MediaBrowser.Providers/Playlists/PlaylistMetadataService.cs +++ b/MediaBrowser.Providers/Playlists/PlaylistMetadataService.cs @@ -42,12 +42,9 @@ namespace MediaBrowser.Providers.Playlists { if (!item.IsLocked && !item.LockedFields.Contains(MetadataFields.Genres)) { - var items = item.GetLinkedChildren() - .ToList(); - - var currentList = item.Genres.ToList(); + var currentList = item.Genres; - item.Genres = items.SelectMany(i => i.Genres) + item.Genres = item.GetLinkedChildren().SelectMany(i => i.Genres) .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.cs index 73a568ca97..443699b5a3 100644 --- a/MediaBrowser.Server.Mono/Program.cs +++ b/MediaBrowser.Server.Mono/Program.cs @@ -261,9 +261,10 @@ namespace MediaBrowser.Server.Mono { var args = Environment.GetCommandLineArgs() .Skip(1) - .Select(NormalizeCommandLineArgument); + .Select(NormalizeCommandLineArgument) + .ToArray(); - commandLineArgsString = string.Join(" ", args.ToArray()); + commandLineArgsString = string.Join(" ", args); } _logger.Info("Executable: {0}", module); diff --git a/MediaBrowser.ServerApplication/Native/LoopUtil.cs b/MediaBrowser.ServerApplication/Native/LoopUtil.cs index 7c74712312..0efdba389d 100644 --- a/MediaBrowser.ServerApplication/Native/LoopUtil.cs +++ b/MediaBrowser.ServerApplication/Native/LoopUtil.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; diff --git a/MediaBrowser.XbmcMetadata/EntryPoint.cs b/MediaBrowser.XbmcMetadata/EntryPoint.cs index ac5313a291..b1c687a6e3 100644 --- a/MediaBrowser.XbmcMetadata/EntryPoint.cs +++ b/MediaBrowser.XbmcMetadata/EntryPoint.cs @@ -8,7 +8,6 @@ using MediaBrowser.Model.Logging; using MediaBrowser.XbmcMetadata.Configuration; using MediaBrowser.XbmcMetadata.Savers; using System; -using System.Linq; using MediaBrowser.Controller.Dto; namespace MediaBrowser.XbmcMetadata diff --git a/MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs index f9ca238c7e..85f9f92baa 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Configuration; +using System.Linq; +using MediaBrowser.Common.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Providers; @@ -81,7 +82,9 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(val) && movie != null) { - movie.Artists.Add(val); + var list = movie.Artists.ToList(); + list.Add(val); + movie.Artists = list.ToArray(); } break; diff --git a/MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs index ec53b3bc4c..f9f9c9b98a 100644 --- a/MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/AlbumNfoSaver.cs @@ -57,10 +57,9 @@ namespace MediaBrowser.XbmcMetadata.Savers private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); - private void AddTracks(IEnumerable /// The to validate. - System.Collections.Generic.IEnumerable GetValidationErrors(SsdpRootDevice device); + System.Collections.Generic.List GetValidationErrors(SsdpRootDevice device); /// /// Returns an enumerable set of strings, each one being a description of an invalid property on the specified device. /// /// The to validate. - System.Collections.Generic.IEnumerable GetValidationErrors(SsdpDevice device); + System.Collections.Generic.List GetValidationErrors(SsdpDevice device); /// /// Validates the specified device and throws an if there are any validation errors. diff --git a/RSSDP/RequestReceivedEventArgs.cs b/RSSDP/RequestReceivedEventArgs.cs index 03c059634f..f4e3677605 100644 --- a/RSSDP/RequestReceivedEventArgs.cs +++ b/RSSDP/RequestReceivedEventArgs.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Net; using System.Net.Http; using System.Text; diff --git a/RSSDP/ResponseReceivedEventArgs.cs b/RSSDP/ResponseReceivedEventArgs.cs index c983fa204a..f67d5da90b 100644 --- a/RSSDP/ResponseReceivedEventArgs.cs +++ b/RSSDP/ResponseReceivedEventArgs.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Net; using System.Net.Http; using System.Text; diff --git a/RSSDP/SsdpCommunicationsServer.cs b/RSSDP/SsdpCommunicationsServer.cs index 91004b76fe..a4be24ebfe 100644 --- a/RSSDP/SsdpCommunicationsServer.cs +++ b/RSSDP/SsdpCommunicationsServer.cs @@ -364,7 +364,7 @@ namespace Rssdp.Infrastructure if (_enableMultiSocketBinding) { - foreach (var address in _networkManager.GetLocalIpAddresses().ToList()) + foreach (var address in _networkManager.GetLocalIpAddresses()) { try { diff --git a/RSSDP/SsdpConstants.cs b/RSSDP/SsdpConstants.cs index c839d9e0bf..87f01f9e0c 100644 --- a/RSSDP/SsdpConstants.cs +++ b/RSSDP/SsdpConstants.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/RSSDP/SsdpDevice.cs b/RSSDP/SsdpDevice.cs index a595742d00..cda11f0a46 100644 --- a/RSSDP/SsdpDevice.cs +++ b/RSSDP/SsdpDevice.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; @@ -283,7 +282,7 @@ namespace Rssdp /// /// /// - public IEnumerable Devices + public IList Devices { get; private set; @@ -466,7 +465,7 @@ namespace Rssdp private static void WriteIcons(XmlWriter writer, SsdpDevice device) { - if (device.Icons.Any()) + if (device.Icons.Count > 0) { writer.WriteStartElement("iconList"); @@ -489,7 +488,7 @@ namespace Rssdp private void WriteChildDevices(XmlWriter writer, SsdpDevice parentDevice) { - if (parentDevice.Devices.Any()) + if (parentDevice.Devices.Count > 0) { writer.WriteStartElement("deviceList"); diff --git a/RSSDP/SsdpDeviceExtensions.cs b/RSSDP/SsdpDeviceExtensions.cs index 0ad710a6b0..6e1b456461 100644 --- a/RSSDP/SsdpDeviceExtensions.cs +++ b/RSSDP/SsdpDeviceExtensions.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; namespace Rssdp diff --git a/RSSDP/SsdpDeviceIcon.cs b/RSSDP/SsdpDeviceIcon.cs index 4ffda58ff9..3ed707c80a 100644 --- a/RSSDP/SsdpDeviceIcon.cs +++ b/RSSDP/SsdpDeviceIcon.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/RSSDP/SsdpDeviceLocator.cs b/RSSDP/SsdpDeviceLocator.cs index 3ea17237df..8fe4d4a144 100644 --- a/RSSDP/SsdpDeviceLocator.cs +++ b/RSSDP/SsdpDeviceLocator.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using MediaBrowser.Model.Net; using MediaBrowser.Model.Threading; diff --git a/RSSDP/SsdpDeviceLocatorBase.cs b/RSSDP/SsdpDeviceLocatorBase.cs index 1adb95cdf5..d1eaef88af 100644 --- a/RSSDP/SsdpDeviceLocatorBase.cs +++ b/RSSDP/SsdpDeviceLocatorBase.cs @@ -127,7 +127,7 @@ namespace Rssdp.Infrastructure } catch (Exception ex) { - + } } @@ -543,17 +543,9 @@ namespace Rssdp.Infrastructure } } - private IEnumerable GetUnexpiredDevices() - { - lock (_Devices) - { - return (from device in _Devices where !device.IsExpired() select device).ToArray(); - } - } - private bool DeviceDied(string deviceUsn, bool expired) { - IEnumerable existingDevices = null; + List existingDevices = null; lock (_Devices) { existingDevices = FindExistingDeviceNotifications(_Devices, deviceUsn); @@ -565,7 +557,7 @@ namespace Rssdp.Infrastructure } } - if (existingDevices != null && existingDevices.Any()) + if (existingDevices != null && existingDevices.Count > 0) { foreach (var removedDevice in existingDevices) { @@ -591,12 +583,29 @@ namespace Rssdp.Infrastructure private static DiscoveredSsdpDevice FindExistingDeviceNotification(IEnumerable devices, string notificationType, string usn) { - return (from d in devices where d.NotificationType == notificationType && d.Usn == usn select d).FirstOrDefault(); + foreach (var d in devices) + { + if (d.NotificationType == notificationType && d.Usn == usn) + { + return d; + } + } + return null; } - private static IEnumerable FindExistingDeviceNotifications(IList devices, string usn) + private static List FindExistingDeviceNotifications(IList devices, string usn) { - return (from d in devices where d.Usn == usn select d).ToArray(); + var list = new List(); + + foreach (var d in devices) + { + if (d.Usn == usn) + { + list.Add(d); + } + } + + return list; } #endregion diff --git a/RSSDP/SsdpDeviceProperties.cs b/RSSDP/SsdpDeviceProperties.cs index 850dfb0ba8..ae5309da58 100644 --- a/RSSDP/SsdpDeviceProperties.cs +++ b/RSSDP/SsdpDeviceProperties.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; namespace Rssdp diff --git a/RSSDP/SsdpDeviceProperty.cs b/RSSDP/SsdpDeviceProperty.cs index 3a8dd2ec7f..3abcfb9aa3 100644 --- a/RSSDP/SsdpDeviceProperty.cs +++ b/RSSDP/SsdpDeviceProperty.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/RSSDP/SsdpDevicePublisher.cs b/RSSDP/SsdpDevicePublisher.cs index 1c17c78372..2aa1437750 100644 --- a/RSSDP/SsdpDevicePublisher.cs +++ b/RSSDP/SsdpDevicePublisher.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using MediaBrowser.Model.Net; using MediaBrowser.Model.Threading; diff --git a/RSSDP/SsdpEmbeddedDevice.cs b/RSSDP/SsdpEmbeddedDevice.cs index c03106b2dd..28948f9506 100644 --- a/RSSDP/SsdpEmbeddedDevice.cs +++ b/RSSDP/SsdpEmbeddedDevice.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; namespace Rssdp diff --git a/RSSDP/SsdpRootDevice.cs b/RSSDP/SsdpRootDevice.cs index faf851bcbe..5b7d0f4548 100644 --- a/RSSDP/SsdpRootDevice.cs +++ b/RSSDP/SsdpRootDevice.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Xml; using Rssdp.Infrastructure; diff --git a/RSSDP/UPnP10DeviceValidator.cs b/RSSDP/UPnP10DeviceValidator.cs index f802b7639e..2a8a9ccd28 100644 --- a/RSSDP/UPnP10DeviceValidator.cs +++ b/RSSDP/UPnP10DeviceValidator.cs @@ -26,11 +26,11 @@ namespace Rssdp.Infrastructure /// The to validate. /// Thrown if the argument is null. /// A non-null enumerable set of strings, empty if there are no validation errors, otherwise each string represents a discrete problem. - public IEnumerable GetValidationErrors(SsdpRootDevice device) + public List GetValidationErrors(SsdpRootDevice device) { if (device == null) throw new ArgumentNullException("device"); - var retVal = GetValidationErrors((SsdpDevice)device) as IList; + var retVal = GetValidationErrors((SsdpDevice)device); if (device.Location == null) retVal.Add("Location cannot be null."); @@ -49,7 +49,7 @@ namespace Rssdp.Infrastructure /// The to validate. /// Thrown if the argument is null. /// A non-null enumerable set of strings, empty if there are no validation errors, otherwise each string represents a discrete problem. - public IEnumerable GetValidationErrors(SsdpDevice device) + public List GetValidationErrors(SsdpDevice device) { if (device == null) throw new ArgumentNullException("device"); @@ -110,7 +110,7 @@ namespace Rssdp.Infrastructure if (String.IsNullOrEmpty(device.ModelName)) retVal.Add("ModelName is required."); - if (device.Icons.Any()) + if (device.Icons.Count > 0) ValidateIcons(device, retVal); ValidateChildDevices(device, retVal); @@ -127,7 +127,7 @@ namespace Rssdp.Infrastructure public void ThrowIfDeviceInvalid(SsdpDevice device) { var errors = this.GetValidationErrors(device); - if (errors != null && errors.Any()) throw new InvalidOperationException("Invalid device settings : " + String.Join(Environment.NewLine, errors)); + if (errors != null && errors.Count > 0) throw new InvalidOperationException("Invalid device settings : " + String.Join(Environment.NewLine, errors)); } #endregion diff --git a/SocketHttpListener/Net/BoundaryType.cs b/SocketHttpListener/Net/BoundaryType.cs index c3ac00c0fd..f1e799f63c 100644 --- a/SocketHttpListener/Net/BoundaryType.cs +++ b/SocketHttpListener/Net/BoundaryType.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/CookieHelper.cs b/SocketHttpListener/Net/CookieHelper.cs index 470507d6b7..a32131956f 100644 --- a/SocketHttpListener/Net/CookieHelper.cs +++ b/SocketHttpListener/Net/CookieHelper.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Globalization; -using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/EndPointManager.cs b/SocketHttpListener/Net/EndPointManager.cs index 6a00ed360a..ddb110ec16 100644 --- a/SocketHttpListener/Net/EndPointManager.cs +++ b/SocketHttpListener/Net/EndPointManager.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq; using System.Net; using System.Reflection; using System.Threading.Tasks; @@ -83,7 +82,9 @@ namespace SocketHttpListener.Net { try { - addr = (await networkManager.GetHostAddressesAsync(host).ConfigureAwait(false)).FirstOrDefault() ?? + var all = (await networkManager.GetHostAddressesAsync(host).ConfigureAwait(false)); + + addr = (all.Length == 0 ? null : all[0]) ?? GetIpAnyAddress(listener); } catch diff --git a/SocketHttpListener/Net/EntitySendFormat.cs b/SocketHttpListener/Net/EntitySendFormat.cs index 6e585bdc9b..9caee3e112 100644 --- a/SocketHttpListener/Net/EntitySendFormat.cs +++ b/SocketHttpListener/Net/EntitySendFormat.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/HttpListenerResponse.Managed.cs b/SocketHttpListener/Net/HttpListenerResponse.Managed.cs index 83fcc09cae..34953b569a 100644 --- a/SocketHttpListener/Net/HttpListenerResponse.Managed.cs +++ b/SocketHttpListener/Net/HttpListenerResponse.Managed.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Globalization; using System.IO; -using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/HttpListenerResponse.cs b/SocketHttpListener/Net/HttpListenerResponse.cs index fc57e84857..1cbd6165e7 100644 --- a/SocketHttpListener/Net/HttpListenerResponse.cs +++ b/SocketHttpListener/Net/HttpListenerResponse.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/HttpRequestStream.Managed.cs b/SocketHttpListener/Net/HttpRequestStream.Managed.cs index 92f4bbb02d..c9c148b150 100644 --- a/SocketHttpListener/Net/HttpRequestStream.Managed.cs +++ b/SocketHttpListener/Net/HttpRequestStream.Managed.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Runtime.ExceptionServices; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/HttpRequestStream.cs b/SocketHttpListener/Net/HttpRequestStream.cs index c54da44a17..f10c04a4f1 100644 --- a/SocketHttpListener/Net/HttpRequestStream.cs +++ b/SocketHttpListener/Net/HttpRequestStream.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/HttpResponseStream.Managed.cs b/SocketHttpListener/Net/HttpResponseStream.Managed.cs index 116c3280a7..b700c293d7 100644 --- a/SocketHttpListener/Net/HttpResponseStream.Managed.cs +++ b/SocketHttpListener/Net/HttpResponseStream.Managed.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Net; using System.Net.Sockets; using System.Runtime.ExceptionServices; diff --git a/SocketHttpListener/Net/HttpResponseStream.cs b/SocketHttpListener/Net/HttpResponseStream.cs index f7140be66c..5b7fa417f3 100644 --- a/SocketHttpListener/Net/HttpResponseStream.cs +++ b/SocketHttpListener/Net/HttpResponseStream.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/HttpStatusDescription.cs b/SocketHttpListener/Net/HttpStatusDescription.cs index 8d490c5117..9cc4a8e8ce 100644 --- a/SocketHttpListener/Net/HttpStatusDescription.cs +++ b/SocketHttpListener/Net/HttpStatusDescription.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/UriScheme.cs b/SocketHttpListener/Net/UriScheme.cs index eb13619c9d..35b01e0e55 100644 --- a/SocketHttpListener/Net/UriScheme.cs +++ b/SocketHttpListener/Net/UriScheme.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Net/WebHeaderCollection.cs b/SocketHttpListener/Net/WebHeaderCollection.cs index 66e159ccb7..d82dc68163 100644 --- a/SocketHttpListener/Net/WebHeaderCollection.cs +++ b/SocketHttpListener/Net/WebHeaderCollection.cs @@ -131,13 +131,13 @@ namespace SocketHttpListener.Net base.Add(headerName, headerValue); } - internal string[] GetValues_internal(string header, bool split) + internal List GetValues_internal(string header, bool split) { if (header == null) throw new ArgumentNullException("header"); - string[] values = base.GetValues(header); - if (values == null || values.Length == 0) + var values = base.GetValues(header); + if (values == null || values.Count == 0) return null; if (split && IsMultiValue(header)) @@ -155,7 +155,7 @@ namespace SocketHttpListener.Net if (separated == null) { - separated = new List(values.Length + 1); + separated = new List(values.Count + 1); foreach (var v in values) { if (v == value) @@ -177,13 +177,13 @@ namespace SocketHttpListener.Net } if (separated != null) - return separated.ToArray(separated.Count); + return separated; } return values; } - public override string[] GetValues(string header) + public override List GetValues(string header) { return GetValues_internal(header, true); } diff --git a/SocketHttpListener/Net/WebHeaderEncoding.cs b/SocketHttpListener/Net/WebHeaderEncoding.cs index 64330c1b43..4a080179ea 100644 --- a/SocketHttpListener/Net/WebHeaderEncoding.cs +++ b/SocketHttpListener/Net/WebHeaderEncoding.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Primitives/ICertificate.cs b/SocketHttpListener/Primitives/ICertificate.cs index 1289da13d7..ec21e9445d 100644 --- a/SocketHttpListener/Primitives/ICertificate.cs +++ b/SocketHttpListener/Primitives/ICertificate.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/SocketHttpListener/Primitives/IStreamFactory.cs b/SocketHttpListener/Primitives/IStreamFactory.cs index 57e21e31bc..4b623b940f 100644 --- a/SocketHttpListener/Primitives/IStreamFactory.cs +++ b/SocketHttpListener/Primitives/IStreamFactory.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; using System.Threading.Tasks; using MediaBrowser.Model.Net; diff --git a/SocketHttpListener/Primitives/ITextEncoding.cs b/SocketHttpListener/Primitives/ITextEncoding.cs index b10145687b..2c25a308c6 100644 --- a/SocketHttpListener/Primitives/ITextEncoding.cs +++ b/SocketHttpListener/Primitives/ITextEncoding.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; using System.Threading.Tasks; using MediaBrowser.Model.Text; From 1b690677e9e79c9ee87a8c28638a311be354e2b1 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 24 Aug 2017 15:52:48 -0400 Subject: [PATCH 31/41] fix parsing of guide data --- .../LiveTv/Listings/SchedulesDirect.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs index 6fe3615d38..b7cfdea1b5 100644 --- a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs +++ b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs @@ -358,14 +358,19 @@ namespace Emby.Server.Implementations.LiveTv.Listings if (details.metadata != null) { - var gracenote = details.metadata.Find(x => x.Gracenote != null).Gracenote; - if (gracenote != null) + foreach (var metadataProgram in details.metadata) { - info.SeasonNumber = gracenote.season; - - if (gracenote.episode > 0) + var gracenote = metadataProgram.Gracenote; + if (gracenote != null) { - info.EpisodeNumber = gracenote.episode; + info.SeasonNumber = gracenote.season; + + if (gracenote.episode > 0) + { + info.EpisodeNumber = gracenote.episode; + } + + break; } } } From 165069ce6337919ebc824d8cf0ef1ef945835718 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 24 Aug 2017 15:53:16 -0400 Subject: [PATCH 32/41] 3.2.28.5 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SharedVersion.cs b/SharedVersion.cs index 8a24a887f3..339aca7854 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.28.4")] +[assembly: AssemblyVersion("3.2.28.5")] From edfae37331ff07934b1608effe0f8019c8a2d79b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 26 Aug 2017 02:18:52 -0400 Subject: [PATCH 33/41] fixes #2335 - Raw image not showing in webbrowser --- Emby.Drawing/ImageProcessor.cs | 78 ++++++++++++++++++- .../ApplicationHost.cs | 2 +- .../MediaEncoding/IMediaEncoder.cs | 2 + 3 files changed, 78 insertions(+), 4 deletions(-) diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 63fa5f1f5e..8f3042e2ad 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -18,6 +18,7 @@ using System.Threading.Tasks; using MediaBrowser.Model.IO; using Emby.Drawing.Common; using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Model.Net; using MediaBrowser.Model.Threading; using MediaBrowser.Model.Extensions; @@ -56,22 +57,24 @@ namespace Emby.Drawing private readonly IServerApplicationPaths _appPaths; private IImageEncoder _imageEncoder; private readonly Func _libraryManager; + private readonly Func _mediaEncoder; public ImageProcessor(ILogger logger, IServerApplicationPaths appPaths, IFileSystem fileSystem, IJsonSerializer jsonSerializer, IImageEncoder imageEncoder, - Func libraryManager, ITimerFactory timerFactory) + Func libraryManager, ITimerFactory timerFactory, Func mediaEncoder) { _logger = logger; _fileSystem = fileSystem; _jsonSerializer = jsonSerializer; _imageEncoder = imageEncoder; _libraryManager = libraryManager; + _mediaEncoder = mediaEncoder; _appPaths = appPaths; - ImageEnhancers = new IImageEnhancer[] {}; + ImageEnhancers = new IImageEnhancer[] { }; _saveImageSizeTimer = timerFactory.Create(SaveImageSizeCallback, null, Timeout.Infinite, Timeout.Infinite); ImageHelper.ImageProcessor = this; @@ -120,7 +123,36 @@ namespace Emby.Drawing { get { - return _imageEncoder.SupportedInputFormats; + return new string[] + { + "tiff", + "jpeg", + "jpg", + "png", + "aiff", + "cr2", + "crw", + "dng", + + // Remove until supported + //"nef", + "orf", + "pef", + "arw", + "webp", + "gif", + "bmp", + "erf", + "raf", + "rw2", + "nrw", + "dng", + "ico", + "astc", + "ktx", + "pkm", + "wbmp" + }; } } @@ -203,6 +235,10 @@ namespace Emby.Drawing return new Tuple(originalImagePath, MimeTypes.GetMimeType(originalImagePath), dateModified); } + var supportedImageInfo = await GetSupportedImage(originalImagePath, dateModified).ConfigureAwait(false); + originalImagePath = supportedImageInfo.Item1; + dateModified = supportedImageInfo.Item2; + if (options.Enhancers.Count > 0) { if (item == null) @@ -663,6 +699,42 @@ namespace Emby.Drawing return string.Join("|", cacheKeys.ToArray(cacheKeys.Count)).GetMD5().ToString("N"); } + private async Task> GetSupportedImage(string originalImagePath, DateTime dateModified) + { + var inputFormat = (Path.GetExtension(originalImagePath) ?? string.Empty) + .TrimStart('.') + .Replace("jpeg", "jpg", StringComparison.OrdinalIgnoreCase); + + if (!_imageEncoder.SupportedInputFormats.Contains(inputFormat, StringComparer.OrdinalIgnoreCase)) + { + try + { + var filename = (originalImagePath + dateModified.Ticks.ToString(UsCulture)).GetMD5().ToString("N"); + + var outputPath = Path.Combine(_appPaths.ImageCachePath, "converted-images", filename + ".webp"); + + var file = _fileSystem.GetFileInfo(outputPath); + if (!file.Exists) + { + await _mediaEncoder().ConvertImage(originalImagePath, outputPath).ConfigureAwait(false); + dateModified = _fileSystem.GetLastWriteTimeUtc(outputPath); + } + else + { + dateModified = file.LastWriteTimeUtc; + } + + originalImagePath = outputPath; + } + catch (Exception ex) + { + _logger.ErrorException("Image conversion failed for {0}", ex, originalImagePath); + } + } + + return new Tuple(originalImagePath, dateModified); + } + /// /// Gets the enhanced image. /// diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 6441fe4f2d..aaca22fe9b 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -1202,7 +1202,7 @@ namespace Emby.Server.Implementations private IImageProcessor GetImageProcessor() { - return new ImageProcessor(LogManager.GetLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, ImageEncoder, () => LibraryManager, TimerFactory); + return new ImageProcessor(LogManager.GetLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, ImageEncoder, () => LibraryManager, TimerFactory, () => MediaEncoder); } protected virtual FFMpegInstallInfo GetFfmpegInstallInfo() diff --git a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs index 05bb35771e..803b189d4c 100644 --- a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs +++ b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs @@ -102,6 +102,8 @@ namespace MediaBrowser.Controller.MediaEncoding IProgress progress, CancellationToken cancellationToken); + Task ConvertImage(string inputPath, string outputPath); + /// /// Escapes the subtitle filter path. /// From 6bc2a79792ec4ca91cc1104c3d9a8d1b6b4bdd53 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 26 Aug 2017 03:03:19 -0400 Subject: [PATCH 34/41] fix folder rip probe --- Emby.Dlna/Profiles/PanasonicVieraProfile.cs | 177 ++++++++++++++---- .../ApplicationHost.cs | 8 +- .../Data/SqliteItemRepository.cs | 2 +- .../Data/SqliteUserDataRepository.cs | 2 +- .../Emby.Server.Implementations.csproj | 5 +- Emby.Server.Implementations/packages.config | 2 +- .../Entities/Audio/Audio.cs | 2 +- .../Entities/Audio/MusicAlbum.cs | 2 +- MediaBrowser.Controller/Entities/BaseItem.cs | 2 + MediaBrowser.Controller/Entities/Video.cs | 52 ++--- .../MediaEncoding/IMediaEncoder.cs | 5 + MediaBrowser.Model/Sync/SyncDataRequest.cs | 5 +- .../MediaInfo/FFProbeVideoInfo.cs | 86 +-------- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 15 files changed, 178 insertions(+), 178 deletions(-) diff --git a/Emby.Dlna/Profiles/PanasonicVieraProfile.cs b/Emby.Dlna/Profiles/PanasonicVieraProfile.cs index 095788485b..eb9cf95287 100644 --- a/Emby.Dlna/Profiles/PanasonicVieraProfile.cs +++ b/Emby.Dlna/Profiles/PanasonicVieraProfile.cs @@ -16,20 +16,121 @@ namespace Emby.Dlna.Profiles Manufacturer = "Panasonic", Headers = new[] - { - new HttpHeaderInfo - { - Name = "User-Agent", - Value = "Panasonic MIL DLNA", - Match = HeaderMatchType.Substring - } - } + { + new HttpHeaderInfo + { + Name = "User-Agent", + Value = "Panasonic MIL DLNA", + Match = HeaderMatchType.Substring + } + } }; AddXmlRootAttribute("xmlns:pv", "http://www.pv.com/pvns/"); TimelineOffsetSeconds = 10; + TranscodingProfiles = new[] + { + new TranscodingProfile + { + Container = "mp3", + AudioCodec = "mp3", + Type = DlnaProfileType.Audio + }, + new TranscodingProfile + { + Container = "ts", + AudioCodec = "ac3", + VideoCodec = "h264", + Type = DlnaProfileType.Video + }, + new TranscodingProfile + { + Container = "jpeg", + Type = DlnaProfileType.Photo + } + }; + + DirectPlayProfiles = new[] + { + new DirectPlayProfile + { + Container = "mpeg,mpg", + VideoCodec = "mpeg2video,mpeg4", + AudioCodec = "ac3,mp3,pcm_dvd", + Type = DlnaProfileType.Video + }, + + new DirectPlayProfile + { + Container = "mkv", + VideoCodec = "h264,mpeg2video", + AudioCodec = "aac,ac3,dca,mp3,mp2,pcm,dts", + Type = DlnaProfileType.Video + }, + + new DirectPlayProfile + { + Container = "ts", + VideoCodec = "h264,mpeg2video", + AudioCodec = "aac,mp3,mp2", + Type = DlnaProfileType.Video + }, + + new DirectPlayProfile + { + Container = "mp4,m4v", + VideoCodec = "h264", + AudioCodec = "aac,ac3,mp3,pcm", + Type = DlnaProfileType.Video + }, + + new DirectPlayProfile + { + Container = "mov", + VideoCodec = "h264", + AudioCodec = "aac,pcm", + Type = DlnaProfileType.Video + }, + + new DirectPlayProfile + { + Container = "avi", + VideoCodec = "mpeg4", + AudioCodec = "pcm", + Type = DlnaProfileType.Video + }, + + new DirectPlayProfile + { + Container = "flv", + VideoCodec = "h264", + AudioCodec = "aac", + Type = DlnaProfileType.Video + }, + + new DirectPlayProfile + { + Container = "mp3", + AudioCodec = "mp3", + Type = DlnaProfileType.Audio + }, + + new DirectPlayProfile + { + Container = "mp4", + AudioCodec = "aac", + Type = DlnaProfileType.Audio + }, + + new DirectPlayProfile + { + Container = "jpeg", + Type = DlnaProfileType.Photo + } + }; + ContainerProfiles = new[] { new ContainerProfile @@ -55,35 +156,35 @@ namespace Emby.Dlna.Profiles }; CodecProfiles = new[] - { - new CodecProfile - { - Type = CodecType.Video, - - Conditions = new[] - { - new ProfileCondition - { - Condition = ProfileConditionType.LessThanEqual, - Property = ProfileConditionValue.Width, - Value = "1920" - }, - new ProfileCondition - { - Condition = ProfileConditionType.LessThanEqual, - Property = ProfileConditionValue.Height, - Value = "1080" - }, - new ProfileCondition - { - Condition = ProfileConditionType.LessThanEqual, - Property = ProfileConditionValue.VideoBitDepth, - Value = "8", - IsRequired = false - } - } - } - }; + { + new CodecProfile + { + Type = CodecType.Video, + + Conditions = new[] + { + new ProfileCondition + { + Condition = ProfileConditionType.LessThanEqual, + Property = ProfileConditionValue.Width, + Value = "1920" + }, + new ProfileCondition + { + Condition = ProfileConditionType.LessThanEqual, + Property = ProfileConditionValue.Height, + Value = "1080" + }, + new ProfileCondition + { + Condition = ProfileConditionType.LessThanEqual, + Property = ProfileConditionValue.VideoBitDepth, + Value = "8", + IsRequired = false + } + } + } + }; SubtitleProfiles = new[] { @@ -117,4 +218,4 @@ namespace Emby.Dlna.Profiles }; } } -} +} \ No newline at end of file diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index aaca22fe9b..88dd47538a 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -227,6 +227,8 @@ namespace Emby.Server.Implementations protected IEnvironmentInfo EnvironmentInfo { get; set; } + private IBlurayExaminer BlurayExaminer { get; set; } + public PackageVersionClass SystemUpdateLevel { get @@ -884,7 +886,8 @@ namespace Emby.Server.Implementations ITextEncoding textEncoding = new TextEncoding.TextEncoding(FileSystemManager, LogManager.GetLogger("TextEncoding"), JsonSerializer); RegisterSingleInstance(textEncoding); Utilities.EncodingHelper = textEncoding; - RegisterSingleInstance(() => new BdInfoExaminer(FileSystemManager, textEncoding)); + BlurayExaminer = new BdInfoExaminer(FileSystemManager, textEncoding); + RegisterSingleInstance(BlurayExaminer); RegisterSingleInstance(new XmlReaderSettingsFactory()); @@ -1335,7 +1338,8 @@ namespace Emby.Server.Implementations ProcessFactory, (Environment.ProcessorCount > 2 ? 14000 : 40000), EnvironmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows, - EnvironmentInfo); + EnvironmentInfo, + BlurayExaminer); MediaEncoder = mediaEncoder; RegisterSingleInstance(MediaEncoder); diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 423ad2782b..ff1d217e55 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -114,7 +114,7 @@ namespace Emby.Server.Implementations.Data { get { - return false; + return true; } } diff --git a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs index b76555bde5..bf6388f5d8 100644 --- a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs @@ -95,7 +95,7 @@ namespace Emby.Server.Implementations.Data { get { - return false; + return true; } } diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 1dbb10b488..84ec214c9b 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -661,8 +661,9 @@ ..\packages\Emby.XmlTv.1.0.10\lib\portable-net45+netstandard2.0+win8\Emby.XmlTv.dll - - ..\packages\MediaBrowser.Naming.1.0.6\lib\portable-net45+netstandard2.0+win8\MediaBrowser.Naming.dll + + ..\packages\MediaBrowser.Naming.1.0.7\lib\portable-net45+netstandard2.0+win8\MediaBrowser.Naming.dll + True ..\packages\ServiceStack.Text.4.5.8\lib\net45\ServiceStack.Text.dll diff --git a/Emby.Server.Implementations/packages.config b/Emby.Server.Implementations/packages.config index 8d4d249950..5b869221ae 100644 --- a/Emby.Server.Implementations/packages.config +++ b/Emby.Server.Implementations/packages.config @@ -1,7 +1,7 @@  - + diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index e029a447eb..3ebf4da009 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -110,7 +110,7 @@ namespace MediaBrowser.Controller.Entities.Audio list[index] = artist; index++; } - foreach (var artist in AlbumArtists) + foreach (var artist in Artists) { list[index] = artist; index++; diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index 82f880b3f5..7af8161cab 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs @@ -96,7 +96,7 @@ namespace MediaBrowser.Controller.Entities.Audio list[index] = artist; index++; } - foreach (var artist in AlbumArtists) + foreach (var artist in Artists) { list[index] = artist; index++; diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 24fa80ef6e..51dc59c19e 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -25,6 +25,7 @@ using System.Threading.Tasks; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Extensions; using MediaBrowser.Controller.IO; +using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Extensions; using MediaBrowser.Model.Globalization; @@ -536,6 +537,7 @@ namespace MediaBrowser.Controller.Entities public static ICollectionManager CollectionManager { get; set; } public static IImageProcessor ImageProcessor { get; set; } public static IMediaSourceManager MediaSourceManager { get; set; } + public static IMediaEncoder MediaEncoder { get; set; } /// /// Returns a that represents this instance. diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 3918ac8fc1..887da46ccf 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -149,18 +149,20 @@ namespace MediaBrowser.Controller.Entities /// The video3 D format. public Video3DFormat? Video3DFormat { get; set; } - /// - /// Gets the playable stream files. - /// - /// List{System.String}. - public string[] GetPlayableStreamFiles() - { - return GetPlayableStreamFiles(Path); - } - public string[] GetPlayableStreamFileNames() { - return GetPlayableStreamFiles().Select(System.IO.Path.GetFileName).ToArray(); + var videoType = VideoType; + + if (videoType == VideoType.Iso && IsoType == Model.Entities.IsoType.BluRay) + { + videoType = VideoType.BluRay; + } + else if (videoType == VideoType.Iso && IsoType == Model.Entities.IsoType.Dvd) + { + videoType = VideoType.Dvd; + } + + return MediaEncoder.GetPlayableStreamFileNames(Path, videoType); } /// @@ -413,36 +415,6 @@ namespace MediaBrowser.Controller.Entities return base.IsValidFromResolver(newItem); } - /// - /// Gets the playable stream files. - /// - /// The root path. - /// List{System.String}. - public string[] GetPlayableStreamFiles(string rootPath) - { - if (VideoType == VideoType.VideoFile) - { - return new string[] { }; - } - - var allFiles = FileSystem.GetFilePaths(rootPath, true).ToList(); - - var videoType = VideoType; - - if (videoType == VideoType.Iso && IsoType == Model.Entities.IsoType.BluRay) - { - videoType = VideoType.BluRay; - } - else if (videoType == VideoType.Iso && IsoType == Model.Entities.IsoType.Dvd) - { - videoType = VideoType.Dvd; - } - - return QueryPlayableStreamFiles(rootPath, videoType).Select(name => allFiles.FirstOrDefault(f => string.Equals(System.IO.Path.GetFileName(f), name, StringComparison.OrdinalIgnoreCase))) - .Where(f => !string.IsNullOrEmpty(f)) - .ToArray(); - } - public static string[] QueryPlayableStreamFiles(string rootPath, VideoType videoType) { if (videoType == VideoType.Dvd) diff --git a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs index 803b189d4c..31cd96c9a6 100644 --- a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs +++ b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs @@ -1,9 +1,11 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.MediaInfo; using System; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.Dlna; +using MediaBrowser.Model.IO; namespace MediaBrowser.Controller.MediaEncoding { @@ -118,5 +120,8 @@ namespace MediaBrowser.Controller.MediaEncoding void SetLogFilename(string name); void ClearLogFilename(); + + string[] GetPlayableStreamFileNames(string path, VideoType videoType); + IEnumerable GetPrimaryPlaylistVobFiles(string path, IIsoMount isoMount, uint? titleNumber); } } diff --git a/MediaBrowser.Model/Sync/SyncDataRequest.cs b/MediaBrowser.Model/Sync/SyncDataRequest.cs index c0941caee5..79d1842e19 100644 --- a/MediaBrowser.Model/Sync/SyncDataRequest.cs +++ b/MediaBrowser.Model/Sync/SyncDataRequest.cs @@ -1,11 +1,9 @@ -using System.Collections.Generic; - + namespace MediaBrowser.Model.Sync { public class SyncDataRequest { public string[] LocalItemIds { get; set; } - public string[] OfflineUserIds { get; set; } public string[] SyncJobItemIds { get; set; } public string TargetId { get; set; } @@ -13,7 +11,6 @@ namespace MediaBrowser.Model.Sync public SyncDataRequest() { LocalItemIds = new string[] { }; - OfflineUserIds = new string[] { }; } } } diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index ea8d7bdb0b..76cd02cef7 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs @@ -25,9 +25,6 @@ using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; - -using MediaBrowser.Controller.IO; -using MediaBrowser.Model.IO; using MediaBrowser.Model.Globalization; namespace MediaBrowser.Providers.MediaInfo @@ -49,8 +46,6 @@ namespace MediaBrowser.Providers.MediaInfo private readonly IChapterManager _chapterManager; private readonly ILibraryManager _libraryManager; - private readonly CultureInfo _usCulture = new CultureInfo("en-US"); - public FFProbeVideoInfo(ILogger logger, IIsoManager isoManager, IMediaEncoder mediaEncoder, IItemRepository itemRepo, IBlurayExaminer blurayExaminer, ILocalizationManager localization, IApplicationPaths appPaths, IJsonSerializer json, IEncodingManager encodingManager, IFileSystem fileSystem, IServerConfigurationManager config, ISubtitleManager subtitleManager, IChapterManager chapterManager, ILibraryManager libraryManager) { _logger = logger; @@ -565,8 +560,8 @@ namespace MediaBrowser.Providers.MediaInfo titleNumber = primaryTitle.VideoTitleSetNumber; item.RunTimeTicks = GetRuntime(primaryTitle); } - - return GetPrimaryPlaylistVobFiles(item, mount, titleNumber) + + return _mediaEncoder.GetPrimaryPlaylistVobFiles(item.Path, mount, titleNumber) .Select(Path.GetFileName) .ToArray(); } @@ -616,82 +611,5 @@ namespace MediaBrowser.Providers.MediaInfo return null; } - - private IEnumerable GetPrimaryPlaylistVobFiles(Video video, IIsoMount isoMount, uint? titleNumber) - { - // min size 300 mb - const long minPlayableSize = 314572800; - - var root = isoMount != null ? isoMount.MountedPath : video.Path; - - // Try to eliminate menus and intros by skipping all files at the front of the list that are less than the minimum size - // Once we reach a file that is at least the minimum, return all subsequent ones - var allVobs = _fileSystem.GetFiles(root, new[] { ".vob" }, false, true) - .OrderBy(i => i.FullName) - .ToList(); - - // If we didn't find any satisfying the min length, just take them all - if (allVobs.Count == 0) - { - _logger.Error("No vobs found in dvd structure."); - return new List(); - } - - if (titleNumber.HasValue) - { - var prefix = string.Format("VTS_0{0}_", titleNumber.Value.ToString(_usCulture)); - var vobs = allVobs.Where(i => i.Name.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)).ToList(); - - if (vobs.Count > 0) - { - var minSizeVobs = vobs - .SkipWhile(f => f.Length < minPlayableSize) - .ToList(); - - return minSizeVobs.Count == 0 ? vobs.Select(i => i.FullName) : minSizeVobs.Select(i => i.FullName); - } - - _logger.Info("Could not determine vob file list for {0} using DvdLib. Will scan using file sizes.", video.Path); - } - - var files = allVobs - .SkipWhile(f => f.Length < minPlayableSize) - .ToList(); - - // If we didn't find any satisfying the min length, just take them all - if (files.Count == 0) - { - _logger.Warn("Vob size filter resulted in zero matches. Taking all vobs."); - files = allVobs; - } - - // Assuming they're named "vts_05_01", take all files whose second part matches that of the first file - if (files.Count > 0) - { - var parts = _fileSystem.GetFileNameWithoutExtension(files[0]).Split('_'); - - if (parts.Length == 3) - { - var title = parts[1]; - - files = files.TakeWhile(f => - { - var fileParts = _fileSystem.GetFileNameWithoutExtension(f).Split('_'); - - return fileParts.Length == 3 && string.Equals(title, fileParts[1], StringComparison.OrdinalIgnoreCase); - - }).ToList(); - - // If this resulted in not getting any vobs, just take them all - if (files.Count == 0) - { - _logger.Warn("Vob filename filter resulted in zero matches. Taking all vobs."); - files = allVobs; - } - } - } - - return files.Select(i => i.FullName); - } } } \ No newline at end of file diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 4044eaea1e..3aa3d54036 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.741 + 3.0.744 Emby.Common Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 6f43586cdb..ea30175e63 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.741 + 3.0.744 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 a272625566892e7a733b3e35b6f9705198051157 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 26 Aug 2017 03:03:33 -0400 Subject: [PATCH 35/41] update tvdb cache length --- MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs index d447aff99c..af18f5f0be 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs @@ -438,25 +438,25 @@ namespace MediaBrowser.Providers.TV var seriesXmlFilename = preferredMetadataLanguage + ".xml"; - const int cacheDays = 1; + const int cacheHours = 12; var seriesFile = files.FirstOrDefault(i => string.Equals(seriesXmlFilename, i.Name, StringComparison.OrdinalIgnoreCase)); // No need to check age if automatic updates are enabled - if (seriesFile == null || !seriesFile.Exists || (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(seriesFile)).TotalDays > cacheDays) + if (seriesFile == null || !seriesFile.Exists || (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(seriesFile)).TotalHours > cacheHours) { return false; } var actorsXml = files.FirstOrDefault(i => string.Equals("actors.xml", i.Name, StringComparison.OrdinalIgnoreCase)); // No need to check age if automatic updates are enabled - if (actorsXml == null || !actorsXml.Exists || (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(actorsXml)).TotalDays > cacheDays) + if (actorsXml == null || !actorsXml.Exists || (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(actorsXml)).TotalHours > cacheHours) { return false; } var bannersXml = files.FirstOrDefault(i => string.Equals("banners.xml", i.Name, StringComparison.OrdinalIgnoreCase)); // No need to check age if automatic updates are enabled - if (bannersXml == null || !bannersXml.Exists || (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(bannersXml)).TotalDays > cacheDays) + if (bannersXml == null || !bannersXml.Exists || (DateTime.UtcNow - _fileSystem.GetLastWriteTimeUtc(bannersXml)).TotalHours > cacheHours) { return false; } From 6147491a8a8f8b1e5c546d17d3f4875ac8d5b42e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 26 Aug 2017 03:04:04 -0400 Subject: [PATCH 36/41] 3.2.28.6 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SharedVersion.cs b/SharedVersion.cs index 339aca7854..7df5c83f0b 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.28.5")] +[assembly: AssemblyVersion("3.2.28.6")] From 749a181fac6d4ebc77047d8b9dd262abe3bd40d5 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 26 Aug 2017 15:50:02 -0400 Subject: [PATCH 37/41] fix video images not being created --- .../MediaEncoder/EncodingManager.cs | 5 +++++ MediaBrowser.Controller/Entities/Video.cs | 11 ++++++++++- .../MediaInfo/SubtitleDownloader.cs | 5 +++++ SharedVersion.cs | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs index 770b881d5c..d8bf363f26 100644 --- a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs +++ b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs @@ -75,6 +75,11 @@ namespace Emby.Server.Implementations.MediaEncoder return false; } + if (!video.IsCompleteMedia) + { + return false; + } + // Can't extract images if there are no video streams return video.DefaultVideoStreamIndex.HasValue; } diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 887da46ccf..ffb601dc46 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -161,7 +161,10 @@ namespace MediaBrowser.Controller.Entities { videoType = VideoType.Dvd; } - + else + { + return new string[] { }; + } return MediaEncoder.GetPlayableStreamFileNames(Path, videoType); } @@ -265,6 +268,12 @@ namespace MediaBrowser.Controller.Entities return base.CanDelete(); } + [IgnoreDataMember] + public bool IsCompleteMedia + { + get { return !IsActiveRecording(); } + } + [IgnoreDataMember] protected virtual bool EnableDefaultVideoUserDataKeys { diff --git a/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs b/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs index 483d8827ed..79e89a1104 100644 --- a/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs +++ b/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs @@ -39,6 +39,11 @@ namespace MediaBrowser.Providers.MediaInfo return new List(); } + if (!video.IsCompleteMedia) + { + return new List(); + } + VideoContentType mediaType; if (video is Episode) diff --git a/SharedVersion.cs b/SharedVersion.cs index 7df5c83f0b..a113282588 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.28.6")] +[assembly: AssemblyVersion("3.2.28.7")] From e287e3a50d0f83a43905c17434e928fd6d754d9f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 26 Aug 2017 20:32:33 -0400 Subject: [PATCH 38/41] remove async when there's nothing to await --- .../Activity/ActivityLogEntryPoint.cs | 12 ++-- .../Activity/ActivityManager.cs | 6 +- .../Activity/ActivityRepository.cs | 7 +- .../ApplicationHost.cs | 2 +- .../Channels/ChannelManager.cs | 6 +- .../Collections/CollectionManager.cs | 2 +- .../SqliteDisplayPreferencesRepository.cs | 9 ++- .../Data/SqliteItemRepository.cs | 31 ++++----- .../Data/SqliteUserDataRepository.cs | 15 ++-- .../Data/SqliteUserRepository.cs | 5 +- .../Library/LibraryManager.cs | 39 ++++++----- .../Library/UserDataManager.cs | 12 ++-- .../Library/UserManager.cs | 68 +++++++++---------- .../Library/UserViewManager.cs | 16 ++--- .../LiveTv/LiveTvManager.cs | 6 +- .../MediaEncoder/EncodingManager.cs | 2 +- .../Playlists/PlaylistManager.cs | 2 +- .../Security/AuthenticationRepository.cs | 7 +- .../Session/SessionManager.cs | 42 ++++++------ .../Social/SharingManager.cs | 8 +-- .../Social/SharingRepository.cs | 6 +- MediaBrowser.Api/DisplayPreferencesService.cs | 4 +- MediaBrowser.Api/ItemUpdateService.cs | 2 +- MediaBrowser.Api/Library/LibraryService.cs | 8 +-- MediaBrowser.Api/Session/SessionsService.cs | 7 +- MediaBrowser.Api/Social/SharingService.cs | 5 +- MediaBrowser.Api/StartupWizardService.cs | 2 +- .../UserLibrary/UserLibraryService.cs | 24 +++---- MediaBrowser.Api/UserService.cs | 57 ++++++---------- .../Chapters/IChapterManager.cs | 4 +- MediaBrowser.Controller/Entities/BaseItem.cs | 8 +-- MediaBrowser.Controller/Entities/Folder.cs | 24 ++++--- MediaBrowser.Controller/Entities/User.cs | 15 ++-- .../Library/ILibraryManager.cs | 15 ++-- .../Library/IUserDataManager.cs | 7 +- .../Library/IUserManager.cs | 16 ++--- .../IDisplayPreferencesRepository.cs | 7 +- .../Persistence/IItemRepository.cs | 24 +++---- .../Persistence/IUserDataRepository.cs | 7 +- .../Persistence/IUserRepository.cs | 5 +- .../Security/IAuthenticationRepository.cs | 5 +- .../Session/ISessionManager.cs | 6 +- .../Activity/IActivityManager.cs | 3 +- .../Activity/IActivityRepository.cs | 3 +- MediaBrowser.Model/Social/ISharingManager.cs | 2 +- .../Social/ISharingRepository.cs | 7 +- .../Chapters/ChapterManager.cs | 6 +- .../Manager/MetadataService.cs | 15 ++-- .../MediaInfo/FFProbeAudioInfo.cs | 14 ++-- .../MediaInfo/FFProbeVideoInfo.cs | 12 ++-- .../TV/DummySeasonProvider.cs | 6 +- .../TV/MissingEpisodeProvider.cs | 6 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 54 files changed, 287 insertions(+), 348 deletions(-) diff --git a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs index 702917832b..1b6daca73b 100644 --- a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs +++ b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs @@ -128,7 +128,7 @@ namespace Emby.Server.Implementations.Activity { // Don't report theme song or local trailer playback return; - } + } if (e.Users.Count == 0) { @@ -160,8 +160,8 @@ namespace Emby.Server.Implementations.Activity { // Don't report theme song or local trailer playback return; - } - + } + if (e.Users.Count == 0) { return; @@ -416,7 +416,7 @@ namespace Emby.Server.Implementations.Activity { return; } - + var time = result.EndTimeUtc - result.StartTimeUtc; var runningTime = string.Format(_localization.GetLocalizedString("LabelRunningTimeValue"), ToUserFriendlyString(time)); @@ -444,11 +444,11 @@ namespace Emby.Server.Implementations.Activity } } - private async void CreateLogEntry(ActivityLogEntry entry) + private void CreateLogEntry(ActivityLogEntry entry) { try { - await _activityManager.Create(entry).ConfigureAwait(false); + _activityManager.Create(entry); } catch { diff --git a/Emby.Server.Implementations/Activity/ActivityManager.cs b/Emby.Server.Implementations/Activity/ActivityManager.cs index b6095f0820..9a3f1ae472 100644 --- a/Emby.Server.Implementations/Activity/ActivityManager.cs +++ b/Emby.Server.Implementations/Activity/ActivityManager.cs @@ -13,7 +13,7 @@ namespace Emby.Server.Implementations.Activity public class ActivityManager : IActivityManager { public event EventHandler> EntryCreated; - + private readonly IActivityRepository _repo; private readonly ILogger _logger; private readonly IUserManager _userManager; @@ -25,12 +25,12 @@ namespace Emby.Server.Implementations.Activity _userManager = userManager; } - public async Task Create(ActivityLogEntry entry) + public void Create(ActivityLogEntry entry) { entry.Id = Guid.NewGuid().ToString("N"); entry.Date = DateTime.UtcNow; - await _repo.Create(entry).ConfigureAwait(false); + _repo.Create(entry); EventHelper.FireEventIfNotNull(EntryCreated, this, new GenericEventArgs(entry), _logger); } diff --git a/Emby.Server.Implementations/Activity/ActivityRepository.cs b/Emby.Server.Implementations/Activity/ActivityRepository.cs index 7720f8f2fd..3dcc50ba38 100644 --- a/Emby.Server.Implementations/Activity/ActivityRepository.cs +++ b/Emby.Server.Implementations/Activity/ActivityRepository.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; -using System.Threading.Tasks; using Emby.Server.Implementations.Data; using MediaBrowser.Controller; using MediaBrowser.Model.Activity; @@ -41,12 +40,12 @@ namespace Emby.Server.Implementations.Activity private const string BaseActivitySelectText = "select Id, Name, Overview, ShortOverview, Type, ItemId, UserId, DateCreated, LogSeverity from ActivityLogEntries"; - public Task Create(ActivityLogEntry entry) + public void Create(ActivityLogEntry entry) { - return Update(entry); + Update(entry); } - public async Task Update(ActivityLogEntry entry) + public void Update(ActivityLogEntry entry) { if (entry == null) { diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 88dd47538a..70ec37a3bc 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -1048,7 +1048,7 @@ namespace Emby.Server.Implementations SetStaticProperties(); - await ((UserManager)UserManager).Initialize().ConfigureAwait(false); + ((UserManager)UserManager).Initialize(); } protected virtual string PackageRuntime diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index d8d69a62ed..fcc637b254 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -429,7 +429,7 @@ namespace Emby.Server.Implementations.Channels if (isNew) { - await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false); + _libraryManager.CreateItem(item, cancellationToken); } else if (forceUpdate) { @@ -1388,11 +1388,11 @@ namespace Emby.Server.Implementations.Channels if (isNew) { - await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false); + _libraryManager.CreateItem(item, cancellationToken); if (info.People != null && info.People.Count > 0) { - await _libraryManager.UpdatePeople(item, info.People ?? new List()).ConfigureAwait(false); + _libraryManager.UpdatePeople(item, info.People ?? new List()); } } else if (forceUpdate) diff --git a/Emby.Server.Implementations/Collections/CollectionManager.cs b/Emby.Server.Implementations/Collections/CollectionManager.cs index 0fc8fdc48c..2e884e729c 100644 --- a/Emby.Server.Implementations/Collections/CollectionManager.cs +++ b/Emby.Server.Implementations/Collections/CollectionManager.cs @@ -90,7 +90,7 @@ namespace Emby.Server.Implementations.Collections }).ToList() }; - await parentFolder.AddChild(collection, CancellationToken.None).ConfigureAwait(false); + parentFolder.AddChild(collection, CancellationToken.None); if (options.ItemIdList.Length > 0) { diff --git a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs index 4118bd1b21..89664d158e 100644 --- a/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteDisplayPreferencesRepository.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Threading; -using System.Threading.Tasks; using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Persistence; @@ -75,7 +74,7 @@ namespace Emby.Server.Implementations.Data /// The cancellation token. /// Task. /// item - public async Task SaveDisplayPreferences(DisplayPreferences displayPreferences, Guid userId, string client, CancellationToken cancellationToken) + public void SaveDisplayPreferences(DisplayPreferences displayPreferences, Guid userId, string client, CancellationToken cancellationToken) { if (displayPreferences == null) { @@ -123,7 +122,7 @@ namespace Emby.Server.Implementations.Data /// The cancellation token. /// Task. /// item - public async Task SaveAllDisplayPreferences(IEnumerable displayPreferences, Guid userId, CancellationToken cancellationToken) + public void SaveAllDisplayPreferences(IEnumerable displayPreferences, Guid userId, CancellationToken cancellationToken) { if (displayPreferences == null) { @@ -226,9 +225,9 @@ namespace Emby.Server.Implementations.Data } } - public Task SaveDisplayPreferences(DisplayPreferences displayPreferences, string userId, string client, CancellationToken cancellationToken) + public void SaveDisplayPreferences(DisplayPreferences displayPreferences, string userId, string client, CancellationToken cancellationToken) { - return SaveDisplayPreferences(displayPreferences, new Guid(userId), client, cancellationToken); + SaveDisplayPreferences(displayPreferences, new Guid(userId), client, cancellationToken); } public DisplayPreferences GetDisplayPreferences(string displayPreferencesId, string userId, string client) diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index ff1d217e55..74e009bd99 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -132,8 +132,7 @@ namespace Emby.Server.Implementations.Data /// /// Opens the connection to the database /// - /// Task. - public async Task Initialize(SqliteUserDataRepository userDataRepo) + public void Initialize(SqliteUserDataRepository userDataRepo) { using (var connection = CreateConnection()) { @@ -600,16 +599,15 @@ namespace Emby.Server.Implementations.Data /// /// The item. /// The cancellation token. - /// Task. /// item - public Task SaveItem(BaseItem item, CancellationToken cancellationToken) + public void SaveItem(BaseItem item, CancellationToken cancellationToken) { if (item == null) { throw new ArgumentNullException("item"); } - return SaveItems(new List { item }, cancellationToken); + SaveItems(new List { item }, cancellationToken); } /// @@ -617,13 +615,12 @@ namespace Emby.Server.Implementations.Data /// /// The items. /// The cancellation token. - /// Task. /// /// items /// or /// cancellationToken /// - public async Task SaveItems(List items, CancellationToken cancellationToken) + public void SaveItems(List items, CancellationToken cancellationToken) { if (items == null) { @@ -1959,22 +1956,18 @@ namespace Emby.Server.Implementations.Data /// Gets the critic reviews. /// /// The item id. - /// Task{IEnumerable{ItemReview}}. public List GetCriticReviews(Guid itemId) { return new List(); } - private readonly Task _cachedTask = Task.FromResult(true); /// /// Saves the critic reviews. /// /// The item id. /// The critic reviews. - /// Task. - public Task SaveCriticReviews(Guid itemId, IEnumerable criticReviews) + public void SaveCriticReviews(Guid itemId, IEnumerable criticReviews) { - return _cachedTask; } /// @@ -2079,7 +2072,7 @@ namespace Emby.Server.Implementations.Data /// /// Saves the chapters. /// - public async Task SaveChapters(Guid id, List chapters) + public void SaveChapters(Guid id, List chapters) { CheckDisposed(); @@ -4654,12 +4647,12 @@ namespace Emby.Server.Implementations.Data typeof(AggregateFolder) }; - public async Task UpdateInheritedValues(CancellationToken cancellationToken) + public void UpdateInheritedValues(CancellationToken cancellationToken) { - await UpdateInheritedTags(cancellationToken).ConfigureAwait(false); + UpdateInheritedTags(cancellationToken); } - private async Task UpdateInheritedTags(CancellationToken cancellationToken) + private void UpdateInheritedTags(CancellationToken cancellationToken) { var newValues = new List>(); @@ -4754,7 +4747,7 @@ limit 100"; return new[] { value }.Where(IsValidType); } - public async Task DeleteItem(Guid id, CancellationToken cancellationToken) + public void DeleteItem(Guid id, CancellationToken cancellationToken) { if (id == Guid.Empty) { @@ -5485,7 +5478,7 @@ limit 100"; } } - public async Task UpdatePeople(Guid itemId, List people) + public void UpdatePeople(Guid itemId, List people) { if (itemId == Guid.Empty) { @@ -5615,7 +5608,7 @@ limit 100"; } } - public async Task SaveMediaStreams(Guid id, List streams, CancellationToken cancellationToken) + public void SaveMediaStreams(Guid id, List streams, CancellationToken cancellationToken) { CheckDisposed(); diff --git a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs index bf6388f5d8..ef1d7ba445 100644 --- a/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteUserDataRepository.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading; -using System.Threading.Tasks; using MediaBrowser.Common.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Persistence; @@ -153,7 +152,7 @@ namespace Emby.Server.Implementations.Data /// userId /// or /// userDataId - public Task SaveUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken) + public void SaveUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken) { if (userData == null) { @@ -168,10 +167,10 @@ namespace Emby.Server.Implementations.Data throw new ArgumentNullException("key"); } - return PersistUserData(userId, key, userData, cancellationToken); + PersistUserData(userId, key, userData, cancellationToken); } - public Task SaveAllUserData(Guid userId, IEnumerable userData, CancellationToken cancellationToken) + public void SaveAllUserData(Guid userId, UserItemData[] userData, CancellationToken cancellationToken) { if (userData == null) { @@ -182,7 +181,7 @@ namespace Emby.Server.Implementations.Data throw new ArgumentNullException("userId"); } - return PersistAllUserData(userId, userData.ToList(), cancellationToken); + PersistAllUserData(userId, userData, cancellationToken); } /// @@ -193,7 +192,7 @@ namespace Emby.Server.Implementations.Data /// The user data. /// The cancellation token. /// Task. - public async Task PersistUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken) + public void PersistUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); @@ -264,7 +263,7 @@ namespace Emby.Server.Implementations.Data /// /// Persist all user data for the specified user /// - private async Task PersistAllUserData(Guid userId, List userDataList, CancellationToken cancellationToken) + private void PersistAllUserData(Guid userId, UserItemData[] userDataList, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); @@ -349,7 +348,7 @@ namespace Emby.Server.Implementations.Data /// /// /// - public IEnumerable GetAllUserData(Guid userId) + public List GetAllUserData(Guid userId) { if (userId == Guid.Empty) { diff --git a/Emby.Server.Implementations/Data/SqliteUserRepository.cs b/Emby.Server.Implementations/Data/SqliteUserRepository.cs index 29959bcabe..b65996e405 100644 --- a/Emby.Server.Implementations/Data/SqliteUserRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteUserRepository.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Threading; -using System.Threading.Tasks; using MediaBrowser.Controller; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Persistence; @@ -72,7 +71,7 @@ namespace Emby.Server.Implementations.Data /// The cancellation token. /// Task. /// user - public async Task SaveUser(User user, CancellationToken cancellationToken) + public void SaveUser(User user, CancellationToken cancellationToken) { if (user == null) { @@ -139,7 +138,7 @@ namespace Emby.Server.Implementations.Data /// The cancellation token. /// Task. /// user - public async Task DeleteUser(User user, CancellationToken cancellationToken) + public void DeleteUser(User user, CancellationToken cancellationToken) { if (user == null) { diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 1bfc93e79a..57e42985d3 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -461,10 +461,10 @@ namespace Emby.Server.Implementations.Library parent.RemoveChild(item); } - await ItemRepository.DeleteItem(item.Id, CancellationToken.None).ConfigureAwait(false); + ItemRepository.DeleteItem(item.Id, CancellationToken.None); foreach (var child in children) { - await ItemRepository.DeleteItem(child.Id, CancellationToken.None).ConfigureAwait(false); + ItemRepository.DeleteItem(child.Id, CancellationToken.None); } BaseItem removed; @@ -997,8 +997,7 @@ namespace Emby.Server.Implementations.Library Path = path }; - var task = CreateItem(item, CancellationToken.None); - Task.WaitAll(task); + CreateItem(item, CancellationToken.None); } return item; @@ -1170,7 +1169,7 @@ namespace Emby.Server.Implementations.Library progress.Report(percent * 100); } - await ItemRepository.UpdateInheritedValues(cancellationToken).ConfigureAwait(false); + ItemRepository.UpdateInheritedValues(cancellationToken); progress.Report(100); } @@ -1812,9 +1811,9 @@ namespace Emby.Server.Implementations.Library /// The item. /// The cancellation token. /// Task. - public Task CreateItem(BaseItem item, CancellationToken cancellationToken) + public void CreateItem(BaseItem item, CancellationToken cancellationToken) { - return CreateItems(new[] { item }, cancellationToken); + CreateItems(new[] { item }, cancellationToken); } /// @@ -1823,11 +1822,11 @@ namespace Emby.Server.Implementations.Library /// The items. /// The cancellation token. /// Task. - public async Task CreateItems(IEnumerable items, CancellationToken cancellationToken) + public void CreateItems(IEnumerable items, CancellationToken cancellationToken) { var list = items.ToList(); - await ItemRepository.SaveItems(list, cancellationToken).ConfigureAwait(false); + ItemRepository.SaveItems(list, cancellationToken); foreach (var item in list) { @@ -1870,7 +1869,7 @@ namespace Emby.Server.Implementations.Library var logName = item.LocationType == LocationType.Remote ? item.Name ?? item.Path : item.Path ?? item.Name; _logger.Debug("Saving {0} to database.", logName); - await ItemRepository.SaveItem(item, cancellationToken).ConfigureAwait(false); + ItemRepository.SaveItem(item, cancellationToken); RegisterItem(item); @@ -2067,7 +2066,7 @@ namespace Emby.Server.Implementations.Library private readonly TimeSpan _viewRefreshInterval = TimeSpan.FromHours(24); //private readonly TimeSpan _viewRefreshInterval = TimeSpan.FromMinutes(1); - public Task GetNamedView(User user, + public UserView GetNamedView(User user, string name, string viewType, string sortName, @@ -2105,7 +2104,7 @@ namespace Emby.Server.Implementations.Library ForcedSortName = sortName }; - await CreateItem(item, cancellationToken).ConfigureAwait(false); + CreateItem(item, cancellationToken); refresh = true; } @@ -2136,7 +2135,7 @@ namespace Emby.Server.Implementations.Library return item; } - public async Task GetNamedView(User user, + public UserView GetNamedView(User user, string name, string parentId, string viewType, @@ -2173,7 +2172,7 @@ namespace Emby.Server.Implementations.Library item.DisplayParentId = new Guid(parentId); } - await CreateItem(item, cancellationToken).ConfigureAwait(false); + CreateItem(item, cancellationToken); isNew = true; } @@ -2199,7 +2198,7 @@ namespace Emby.Server.Implementations.Library return item; } - public async Task GetShadowView(BaseItem parent, + public UserView GetShadowView(BaseItem parent, string viewType, string sortName, CancellationToken cancellationToken) @@ -2238,7 +2237,7 @@ namespace Emby.Server.Implementations.Library item.DisplayParentId = parentId; - await CreateItem(item, cancellationToken).ConfigureAwait(false); + CreateItem(item, cancellationToken); isNew = true; } @@ -2309,7 +2308,7 @@ namespace Emby.Server.Implementations.Library item.DisplayParentId = new Guid(parentId); } - await CreateItem(item, cancellationToken).ConfigureAwait(false); + CreateItem(item, cancellationToken); isNew = true; } @@ -2823,14 +2822,14 @@ namespace Emby.Server.Implementations.Library return ItemRepository.GetPeopleNames(query); } - public Task UpdatePeople(BaseItem item, List people) + public void UpdatePeople(BaseItem item, List people) { if (!item.SupportsPeople) { - return Task.FromResult(true); + return; } - return ItemRepository.UpdatePeople(item.Id, people); + ItemRepository.UpdatePeople(item.Id, people); } public async Task ConvertImageToLocal(IHasMetadata item, ItemImageInfo image, int imageIndex) diff --git a/Emby.Server.Implementations/Library/UserDataManager.cs b/Emby.Server.Implementations/Library/UserDataManager.cs index 1f2bf97a39..7ef5ca35e1 100644 --- a/Emby.Server.Implementations/Library/UserDataManager.cs +++ b/Emby.Server.Implementations/Library/UserDataManager.cs @@ -41,7 +41,7 @@ namespace Emby.Server.Implementations.Library /// The repository. public IUserDataRepository Repository { get; set; } - public async Task SaveUserData(Guid userId, IHasUserData item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken) + public void SaveUserData(Guid userId, IHasUserData item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken) { if (userData == null) { @@ -62,7 +62,7 @@ namespace Emby.Server.Implementations.Library foreach (var key in keys) { - await Repository.SaveUserData(userId, key, userData, cancellationToken).ConfigureAwait(false); + Repository.SaveUserData(userId, key, userData, cancellationToken); } var cacheKey = GetCacheKey(userId, item.Id); @@ -86,7 +86,7 @@ namespace Emby.Server.Implementations.Library /// /// /// - public async Task SaveAllUserData(Guid userId, IEnumerable userData, CancellationToken cancellationToken) + public void SaveAllUserData(Guid userId, UserItemData[] userData, CancellationToken cancellationToken) { if (userData == null) { @@ -99,7 +99,7 @@ namespace Emby.Server.Implementations.Library cancellationToken.ThrowIfCancellationRequested(); - await Repository.SaveAllUserData(userId, userData, cancellationToken).ConfigureAwait(false); + Repository.SaveAllUserData(userId, userData, cancellationToken); } /// @@ -107,7 +107,7 @@ namespace Emby.Server.Implementations.Library /// /// /// - public IEnumerable GetAllUserData(Guid userId) + public List GetAllUserData(Guid userId) { if (userId == Guid.Empty) { @@ -187,7 +187,7 @@ namespace Emby.Server.Implementations.Library var userData = GetUserData(user.Id, item); var dto = GetUserItemDataDto(userData); - item.FillUserDataDtoValues(dto, userData, null, user, new ItemFields[]{}); + item.FillUserDataDtoValues(dto, userData, null, user, new ItemFields[] { }); return dto; } diff --git a/Emby.Server.Implementations/Library/UserManager.cs b/Emby.Server.Implementations/Library/UserManager.cs index 211c54ceea..e5fe2969f0 100644 --- a/Emby.Server.Implementations/Library/UserManager.cs +++ b/Emby.Server.Implementations/Library/UserManager.cs @@ -160,9 +160,9 @@ namespace Emby.Server.Implementations.Library return Users.FirstOrDefault(u => string.Equals(u.Name, name, StringComparison.OrdinalIgnoreCase)); } - public async Task Initialize() + public void Initialize() { - Users = await LoadUsers().ConfigureAwait(false); + Users = LoadUsers(); var users = Users.ToList(); @@ -174,7 +174,7 @@ namespace Emby.Server.Implementations.Library if (!user.ConnectLinkType.HasValue || user.ConnectLinkType.Value == UserLinkType.LinkedUser) { user.Policy.IsAdministrator = true; - await UpdateUserPolicy(user, user.Policy, false).ConfigureAwait(false); + UpdateUserPolicy(user, user.Policy, false); } } } @@ -294,12 +294,12 @@ namespace Emby.Server.Implementations.Library if (success) { user.LastActivityDate = user.LastLoginDate = DateTime.UtcNow; - await UpdateUser(user).ConfigureAwait(false); - await UpdateInvalidLoginAttemptCount(user, 0).ConfigureAwait(false); + UpdateUser(user); + UpdateInvalidLoginAttemptCount(user, 0); } else { - await UpdateInvalidLoginAttemptCount(user, user.Policy.InvalidLoginAttemptCount + 1).ConfigureAwait(false); + UpdateInvalidLoginAttemptCount(user, user.Policy.InvalidLoginAttemptCount + 1); } _logger.Info("Authentication request for {0} {1}.", user.Name, success ? "has succeeded" : "has been denied"); @@ -307,7 +307,7 @@ namespace Emby.Server.Implementations.Library return success ? user : null; } - private async Task UpdateInvalidLoginAttemptCount(User user, int newValue) + private void UpdateInvalidLoginAttemptCount(User user, int newValue) { if (user.Policy.InvalidLoginAttemptCount != newValue || newValue > 0) { @@ -327,7 +327,7 @@ namespace Emby.Server.Implementations.Library //fireLockout = true; } - await UpdateUserPolicy(user, user.Policy, false).ConfigureAwait(false); + UpdateUserPolicy(user, user.Policy, false); if (fireLockout) { @@ -372,7 +372,7 @@ namespace Emby.Server.Implementations.Library /// Loads the users from the repository /// /// IEnumerable{User}. - private async Task> LoadUsers() + private List LoadUsers() { var users = UserRepository.RetrieveAllUsers().ToList(); @@ -385,14 +385,14 @@ namespace Emby.Server.Implementations.Library user.DateLastSaved = DateTime.UtcNow; - await UserRepository.SaveUser(user, CancellationToken.None).ConfigureAwait(false); + UserRepository.SaveUser(user, CancellationToken.None); users.Add(user); user.Policy.IsAdministrator = true; user.Policy.EnableContentDeletion = true; user.Policy.EnableRemoteControlOfOtherUsers = true; - await UpdateUserPolicy(user, user.Policy, false).ConfigureAwait(false); + UpdateUserPolicy(user, user.Policy, false); } return users; @@ -539,7 +539,7 @@ namespace Emby.Server.Implementations.Library /// The user. /// user /// - public async Task UpdateUser(User user) + public void UpdateUser(User user) { if (user == null) { @@ -554,7 +554,7 @@ namespace Emby.Server.Implementations.Library user.DateModified = DateTime.UtcNow; user.DateLastSaved = DateTime.UtcNow; - await UserRepository.SaveUser(user, CancellationToken.None).ConfigureAwait(false); + UserRepository.SaveUser(user, CancellationToken.None); OnUserUpdated(user); } @@ -599,7 +599,7 @@ namespace Emby.Server.Implementations.Library user.DateLastSaved = DateTime.UtcNow; - await UserRepository.SaveUser(user, CancellationToken.None).ConfigureAwait(false); + UserRepository.SaveUser(user, CancellationToken.None); EventHelper.QueueEventIfNotNull(UserCreated, this, new GenericEventArgs { Argument = user }, _logger); @@ -653,7 +653,7 @@ namespace Emby.Server.Implementations.Library { var configPath = GetConfigurationFilePath(user); - await UserRepository.DeleteUser(user, CancellationToken.None).ConfigureAwait(false); + UserRepository.DeleteUser(user, CancellationToken.None); try { @@ -667,7 +667,7 @@ namespace Emby.Server.Implementations.Library DeleteUserPolicy(user); // Force this to be lazy loaded again - Users = await LoadUsers().ConfigureAwait(false); + Users = LoadUsers(); OnUserDeleted(user); } @@ -681,17 +681,17 @@ namespace Emby.Server.Implementations.Library /// Resets the password by clearing it. /// /// Task. - public Task ResetPassword(User user) + public void ResetPassword(User user) { - return ChangePassword(user, GetSha1String(string.Empty)); + ChangePassword(user, GetSha1String(string.Empty)); } - public Task ResetEasyPassword(User user) + public void ResetEasyPassword(User user) { - return ChangeEasyPassword(user, GetSha1String(string.Empty)); + ChangeEasyPassword(user, GetSha1String(string.Empty)); } - public async Task ChangePassword(User user, string newPasswordSha1) + public void ChangePassword(User user, string newPasswordSha1) { if (user == null) { @@ -709,12 +709,12 @@ namespace Emby.Server.Implementations.Library user.Password = newPasswordSha1; - await UpdateUser(user).ConfigureAwait(false); + UpdateUser(user); EventHelper.FireEventIfNotNull(UserPasswordChanged, this, new GenericEventArgs(user), _logger); } - public async Task ChangeEasyPassword(User user, string newPasswordSha1) + public void ChangeEasyPassword(User user, string newPasswordSha1) { if (user == null) { @@ -727,7 +727,7 @@ namespace Emby.Server.Implementations.Library user.EasyPassword = newPasswordSha1; - await UpdateUser(user).ConfigureAwait(false); + UpdateUser(user); EventHelper.FireEventIfNotNull(UserPasswordChanged, this, new GenericEventArgs(user), _logger); } @@ -842,7 +842,7 @@ namespace Emby.Server.Implementations.Library }; } - public async Task RedeemPasswordResetPin(string pin) + public PinRedeemResult RedeemPasswordResetPin(string pin) { DeletePinFile(); @@ -863,12 +863,12 @@ namespace Emby.Server.Implementations.Library foreach (var user in users) { - await ResetPassword(user).ConfigureAwait(false); + ResetPassword(user); if (user.Policy.IsDisabled) { user.Policy.IsDisabled = false; - await UpdateUserPolicy(user, user.Policy, true).ConfigureAwait(false); + UpdateUserPolicy(user, user.Policy, true); } usersReset.Add(user.Name); } @@ -945,13 +945,13 @@ namespace Emby.Server.Implementations.Library } private readonly object _policySyncLock = new object(); - public Task UpdateUserPolicy(string userId, UserPolicy userPolicy) + public void UpdateUserPolicy(string userId, UserPolicy userPolicy) { var user = GetUserById(userId); - return UpdateUserPolicy(user, userPolicy, true); + UpdateUserPolicy(user, userPolicy, true); } - private async Task UpdateUserPolicy(User user, UserPolicy userPolicy, bool fireEvent) + private void UpdateUserPolicy(User user, UserPolicy userPolicy, bool fireEvent) { // The xml serializer will output differently if the type is not exact if (userPolicy.GetType() != typeof(UserPolicy)) @@ -970,7 +970,7 @@ namespace Emby.Server.Implementations.Library user.Policy = userPolicy; } - await UpdateConfiguration(user, user.Configuration, true).ConfigureAwait(false); + UpdateConfiguration(user, user.Configuration, true); } private void DeleteUserPolicy(User user) @@ -1032,13 +1032,13 @@ namespace Emby.Server.Implementations.Library } private readonly object _configSyncLock = new object(); - public Task UpdateConfiguration(string userId, UserConfiguration config) + public void UpdateConfiguration(string userId, UserConfiguration config) { var user = GetUserById(userId); - return UpdateConfiguration(user, config, true); + UpdateConfiguration(user, config, true); } - private async Task UpdateConfiguration(User user, UserConfiguration config, bool fireEvent) + private void UpdateConfiguration(User user, UserConfiguration config, bool fireEvent) { var path = GetConfigurationFilePath(user); diff --git a/Emby.Server.Implementations/Library/UserViewManager.cs b/Emby.Server.Implementations/Library/UserViewManager.cs index 25c3e10e89..b02c114bb6 100644 --- a/Emby.Server.Implementations/Library/UserViewManager.cs +++ b/Emby.Server.Implementations/Library/UserViewManager.cs @@ -68,7 +68,7 @@ namespace Emby.Server.Implementations.Library if (UserView.IsUserSpecific(folder)) { - list.Add(await _libraryManager.GetNamedView(user, folder.Name, folder.Id.ToString("N"), folderViewType, null, cancellationToken).ConfigureAwait(false)); + list.Add(_libraryManager.GetNamedView(user, folder.Name, folder.Id.ToString("N"), folderViewType, null, cancellationToken)); continue; } @@ -80,7 +80,7 @@ namespace Emby.Server.Implementations.Library if (query.PresetViews.Contains(folderViewType ?? string.Empty, StringComparer.OrdinalIgnoreCase)) { - list.Add(await GetUserView(folder, folderViewType, string.Empty, cancellationToken).ConfigureAwait(false)); + list.Add(GetUserView(folder, folderViewType, string.Empty, cancellationToken)); } else { @@ -95,7 +95,7 @@ namespace Emby.Server.Implementations.Library if (parents.Count > 0) { - list.Add(await GetUserView(parents, viewType, string.Empty, user, query.PresetViews, cancellationToken).ConfigureAwait(false)); + list.Add(GetUserView(parents, viewType, string.Empty, user, query.PresetViews, cancellationToken)); } } @@ -114,7 +114,7 @@ namespace Emby.Server.Implementations.Library }, cancellationToken).ConfigureAwait(false); var channels = channelResult.Items; - + if (_config.Configuration.EnableChannelView && channels.Length > 0) { list.Add(await _channelManager.GetInternalChannelFolder(cancellationToken).ConfigureAwait(false)); @@ -172,7 +172,7 @@ namespace Emby.Server.Implementations.Library return GetUserSubView(name, parentId, type, sortName, cancellationToken); } - private async Task GetUserView(List parents, string viewType, string sortName, User user, string[] presetViews, CancellationToken cancellationToken) + private Folder GetUserView(List parents, string viewType, string sortName, User user, string[] presetViews, CancellationToken cancellationToken) { if (parents.Count == 1 && parents.All(i => string.Equals(i.CollectionType, viewType, StringComparison.OrdinalIgnoreCase))) { @@ -181,14 +181,14 @@ namespace Emby.Server.Implementations.Library return (Folder)parents[0]; } - return await GetUserView((Folder)parents[0], viewType, string.Empty, cancellationToken).ConfigureAwait(false); + return GetUserView((Folder)parents[0], viewType, string.Empty, cancellationToken); } var name = _localizationManager.GetLocalizedString("ViewType" + viewType); - return await _libraryManager.GetNamedView(user, name, viewType, sortName, cancellationToken).ConfigureAwait(false); + return _libraryManager.GetNamedView(user, name, viewType, sortName, cancellationToken); } - public Task GetUserView(Folder parent, string viewType, string sortName, CancellationToken cancellationToken) + public UserView GetUserView(Folder parent, string viewType, string sortName, CancellationToken cancellationToken) { return _libraryManager.GetShadowView(parent, viewType, sortName, cancellationToken); } diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index bf30546aba..ac98d1043a 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -558,7 +558,7 @@ namespace Emby.Server.Implementations.LiveTv if (isNew) { - await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false); + _libraryManager.CreateItem(item, cancellationToken); } else if (forceUpdate) { @@ -875,7 +875,7 @@ namespace Emby.Server.Implementations.LiveTv if (isNew) { - await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false); + _libraryManager.CreateItem(item, cancellationToken); } else if (dataChanged || info.DateLastUpdated > recording.DateLastSaved || statusChanged) { @@ -1410,7 +1410,7 @@ namespace Emby.Server.Implementations.LiveTv if (newPrograms.Count > 0) { - await _libraryManager.CreateItems(newPrograms, cancellationToken).ConfigureAwait(false); + _libraryManager.CreateItems(newPrograms, cancellationToken); } // TODO: Do this in bulk diff --git a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs index d8bf363f26..9a9e619a62 100644 --- a/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs +++ b/Emby.Server.Implementations/MediaEncoder/EncodingManager.cs @@ -179,7 +179,7 @@ namespace Emby.Server.Implementations.MediaEncoder if (saveChapters && changesMade) { - await _chapterManager.SaveChapters(video.Id.ToString(), chapters).ConfigureAwait(false); + _chapterManager.SaveChapters(video.Id.ToString(), chapters); } DeleteDeadImages(currentImages, chapters); diff --git a/Emby.Server.Implementations/Playlists/PlaylistManager.cs b/Emby.Server.Implementations/Playlists/PlaylistManager.cs index 9b9596934a..87832e7dda 100644 --- a/Emby.Server.Implementations/Playlists/PlaylistManager.cs +++ b/Emby.Server.Implementations/Playlists/PlaylistManager.cs @@ -128,7 +128,7 @@ namespace Emby.Server.Implementations.Playlists playlist.SetMediaType(options.MediaType); - await parentFolder.AddChild(playlist, CancellationToken.None).ConfigureAwait(false); + parentFolder.AddChild(playlist, CancellationToken.None); await playlist.RefreshMetadata(new MetadataRefreshOptions(_fileSystem) { ForceSave = true }, CancellationToken.None) .ConfigureAwait(false); diff --git a/Emby.Server.Implementations/Security/AuthenticationRepository.cs b/Emby.Server.Implementations/Security/AuthenticationRepository.cs index d512ff4fb9..f5b847ccf9 100644 --- a/Emby.Server.Implementations/Security/AuthenticationRepository.cs +++ b/Emby.Server.Implementations/Security/AuthenticationRepository.cs @@ -4,7 +4,6 @@ using System.Globalization; using System.IO; using System.Linq; using System.Threading; -using System.Threading.Tasks; using Emby.Server.Implementations.Data; using MediaBrowser.Controller; using MediaBrowser.Controller.Security; @@ -51,14 +50,14 @@ namespace Emby.Server.Implementations.Security } } - public Task Create(AuthenticationInfo info, CancellationToken cancellationToken) + public void Create(AuthenticationInfo info, CancellationToken cancellationToken) { info.Id = Guid.NewGuid().ToString("N"); - return Update(info, cancellationToken); + Update(info, cancellationToken); } - public async Task Update(AuthenticationInfo info, CancellationToken cancellationToken) + public void Update(AuthenticationInfo info, CancellationToken cancellationToken) { if (info == null) { diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index ee373139f4..0692a0ba58 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -6,11 +6,8 @@ using MediaBrowser.Controller.Devices; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; -using MediaBrowser.Controller.LiveTv; -using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Security; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Devices; @@ -253,7 +250,7 @@ namespace Emby.Server.Implementations.Session { try { - await _userManager.UpdateUser(user).ConfigureAwait(false); + _userManager.UpdateUser(user); } catch (Exception ex) { @@ -622,7 +619,7 @@ namespace Emby.Server.Implementations.Session { foreach (var user in users) { - await OnPlaybackStart(user.Id, libraryItem).ConfigureAwait(false); + OnPlaybackStart(user.Id, libraryItem); } } @@ -650,8 +647,7 @@ namespace Emby.Server.Implementations.Session /// /// The user identifier. /// The item. - /// Task. - private async Task OnPlaybackStart(Guid userId, IHasUserData item) + private void OnPlaybackStart(Guid userId, IHasUserData item) { var data = _userDataManager.GetUserData(userId, item); @@ -670,7 +666,7 @@ namespace Emby.Server.Implementations.Session data.Played = false; } - await _userDataManager.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackStart, CancellationToken.None).ConfigureAwait(false); + _userDataManager.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackStart, CancellationToken.None); } public Task OnPlaybackProgress(PlaybackProgressInfo info) @@ -702,7 +698,7 @@ namespace Emby.Server.Implementations.Session { foreach (var user in users) { - await OnPlaybackProgress(user, libraryItem, info).ConfigureAwait(false); + OnPlaybackProgress(user, libraryItem, info); } } @@ -730,7 +726,7 @@ namespace Emby.Server.Implementations.Session StartIdleCheckTimer(); } - private async Task OnPlaybackProgress(User user, BaseItem item, PlaybackProgressInfo info) + private void OnPlaybackProgress(User user, BaseItem item, PlaybackProgressInfo info) { var data = _userDataManager.GetUserData(user.Id, item); @@ -742,7 +738,7 @@ namespace Emby.Server.Implementations.Session UpdatePlaybackSettings(user, info, data); - await _userDataManager.SaveUserData(user.Id, item, data, UserDataSaveReason.PlaybackProgress, CancellationToken.None).ConfigureAwait(false); + _userDataManager.SaveUserData(user.Id, item, data, UserDataSaveReason.PlaybackProgress, CancellationToken.None); } } @@ -842,7 +838,7 @@ namespace Emby.Server.Implementations.Session { foreach (var user in users) { - playedToCompletion = await OnPlaybackStopped(user.Id, libraryItem, info.PositionTicks, info.Failed).ConfigureAwait(false); + playedToCompletion = OnPlaybackStopped(user.Id, libraryItem, info.PositionTicks, info.Failed); } } @@ -875,7 +871,7 @@ namespace Emby.Server.Implementations.Session await SendPlaybackStoppedNotification(session, CancellationToken.None).ConfigureAwait(false); } - private async Task OnPlaybackStopped(Guid userId, BaseItem item, long? positionTicks, bool playbackFailed) + private bool OnPlaybackStopped(Guid userId, BaseItem item, long? positionTicks, bool playbackFailed) { bool playedToCompletion = false; @@ -896,7 +892,7 @@ namespace Emby.Server.Implementations.Session playedToCompletion = true; } - await _userDataManager.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackFinished, CancellationToken.None).ConfigureAwait(false); + _userDataManager.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackFinished, CancellationToken.None); } return playedToCompletion; @@ -1432,7 +1428,7 @@ namespace Emby.Server.Implementations.Session user = result; } - var token = await GetAuthorizationToken(user.Id.ToString("N"), request.DeviceId, request.App, request.AppVersion, request.DeviceName).ConfigureAwait(false); + var token = GetAuthorizationToken(user.Id.ToString("N"), request.DeviceId, request.App, request.AppVersion, request.DeviceName); EventHelper.FireEventIfNotNull(AuthenticationSucceeded, this, new GenericEventArgs(request), _logger); @@ -1454,7 +1450,7 @@ namespace Emby.Server.Implementations.Session } - private async Task GetAuthorizationToken(string userId, string deviceId, string app, string appVersion, string deviceName) + private string GetAuthorizationToken(string userId, string deviceId, string app, string appVersion, string deviceName) { var existing = _authRepo.Get(new AuthenticationInfoQuery { @@ -1484,12 +1480,12 @@ namespace Emby.Server.Implementations.Session }; _logger.Info("Creating new access token for user {0}", userId); - await _authRepo.Create(newToken, CancellationToken.None).ConfigureAwait(false); + _authRepo.Create(newToken, CancellationToken.None); return newToken.AccessToken; } - public async Task Logout(string accessToken) + public void Logout(string accessToken) { if (string.IsNullOrWhiteSpace(accessToken)) { @@ -1509,7 +1505,7 @@ namespace Emby.Server.Implementations.Session { existing.IsActive = false; - await _authRepo.Update(existing, CancellationToken.None).ConfigureAwait(false); + _authRepo.Update(existing, CancellationToken.None); var sessions = Sessions .Where(i => string.Equals(i.DeviceId, existing.DeviceId, StringComparison.OrdinalIgnoreCase)) @@ -1529,7 +1525,7 @@ namespace Emby.Server.Implementations.Session } } - public async Task RevokeUserTokens(string userId, string currentAccessToken) + public void RevokeUserTokens(string userId, string currentAccessToken) { var existing = _authRepo.Get(new AuthenticationInfoQuery { @@ -1541,14 +1537,14 @@ namespace Emby.Server.Implementations.Session { if (!string.Equals(currentAccessToken, info.AccessToken, StringComparison.OrdinalIgnoreCase)) { - await Logout(info.AccessToken).ConfigureAwait(false); + Logout(info.AccessToken); } } } - public Task RevokeToken(string token) + public void RevokeToken(string token) { - return Logout(token); + Logout(token); } /// diff --git a/Emby.Server.Implementations/Social/SharingManager.cs b/Emby.Server.Implementations/Social/SharingManager.cs index 54614c8797..57cf93948d 100644 --- a/Emby.Server.Implementations/Social/SharingManager.cs +++ b/Emby.Server.Implementations/Social/SharingManager.cs @@ -58,8 +58,8 @@ namespace Emby.Server.Implementations.Social }; AddShareInfo(info, externalUrl); - - await _repository.CreateShare(info).ConfigureAwait(false); + + _repository.CreateShare(info); return info; } @@ -92,9 +92,9 @@ namespace Emby.Server.Implementations.Social } } - public Task DeleteShare(string id) + public void DeleteShare(string id) { - return _repository.DeleteShare(id); + _repository.DeleteShare(id); } } } diff --git a/Emby.Server.Implementations/Social/SharingRepository.cs b/Emby.Server.Implementations/Social/SharingRepository.cs index a2a1f879a2..f306e76c49 100644 --- a/Emby.Server.Implementations/Social/SharingRepository.cs +++ b/Emby.Server.Implementations/Social/SharingRepository.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Threading; -using System.Threading.Tasks; using Emby.Server.Implementations.Data; using MediaBrowser.Common.Configuration; using MediaBrowser.Model.Logging; @@ -42,7 +40,7 @@ namespace Emby.Server.Implementations.Social } } - public async Task CreateShare(SocialShareInfo info) + public void CreateShare(SocialShareInfo info) { if (info == null) { @@ -109,7 +107,7 @@ namespace Emby.Server.Implementations.Social return info; } - public async Task DeleteShare(string id) + public void DeleteShare(string id) { } diff --git a/MediaBrowser.Api/DisplayPreferencesService.cs b/MediaBrowser.Api/DisplayPreferencesService.cs index 5a21fc9f46..4f8cc52558 100644 --- a/MediaBrowser.Api/DisplayPreferencesService.cs +++ b/MediaBrowser.Api/DisplayPreferencesService.cs @@ -88,9 +88,7 @@ namespace MediaBrowser.Api // Serialize to json and then back so that the core doesn't see the request dto type var displayPreferences = _jsonSerializer.DeserializeFromString(_jsonSerializer.SerializeToString(request)); - var task = _displayPreferencesManager.SaveDisplayPreferences(displayPreferences, request.UserId, request.Client, CancellationToken.None); - - Task.WaitAll(task); + _displayPreferencesManager.SaveDisplayPreferences(displayPreferences, request.UserId, request.Client, CancellationToken.None); } } } diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index 47bd46ea5d..9e83cf680f 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -209,7 +209,7 @@ namespace MediaBrowser.Api // Do this first so that metadata savers can pull the updates from the database. if (request.People != null) { - await _libraryManager.UpdatePeople(item, request.People.Select(x => new PersonInfo { Name = x.Name, Role = x.Role, Type = x.Type }).ToList()); + _libraryManager.UpdatePeople(item, request.People.Select(x => new PersonInfo { Name = x.Name, Role = x.Role, Type = x.Type }).ToList()); } UpdateItem(request, item); diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index 6c9f5d32bb..44cc60b504 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -525,18 +525,18 @@ namespace MediaBrowser.Api.Library }); } - private async void LogDownload(BaseItem item, User user, AuthorizationInfo auth) + private void LogDownload(BaseItem item, User user, AuthorizationInfo auth) { try { - await _activityManager.Create(new ActivityLogEntry + _activityManager.Create(new ActivityLogEntry { Name = string.Format(_localization.GetLocalizedString("UserDownloadingItemWithValues"), user.Name, item.Name), Type = "UserDownloadingContent", ShortOverview = string.Format(_localization.GetLocalizedString("AppDeviceValues"), auth.Client, auth.Device), UserId = auth.UserId - }).ConfigureAwait(false); + }); } catch { @@ -915,7 +915,7 @@ namespace MediaBrowser.Api.Library : request.IncludeItemTypes.Split(','); var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(request.UserId) : null; - + var query = new InternalItemsQuery(user) { IncludeItemTypes = includeTypes, diff --git a/MediaBrowser.Api/Session/SessionsService.cs b/MediaBrowser.Api/Session/SessionsService.cs index 18d2611952..8f54b591e7 100644 --- a/MediaBrowser.Api/Session/SessionsService.cs +++ b/MediaBrowser.Api/Session/SessionsService.cs @@ -313,14 +313,13 @@ namespace MediaBrowser.Api.Session public void Delete(RevokeKey request) { - var task = _sessionManager.RevokeToken(request.Key); + _sessionManager.RevokeToken(request.Key); - Task.WaitAll(task); } public void Post(CreateKey request) { - var task = _authRepo.Create(new AuthenticationInfo + _authRepo.Create(new AuthenticationInfo { AppName = request.App, IsActive = true, @@ -328,8 +327,6 @@ namespace MediaBrowser.Api.Session DateCreated = DateTime.UtcNow }, CancellationToken.None); - - Task.WaitAll(task); } public void Post(ReportSessionEnded request) diff --git a/MediaBrowser.Api/Social/SharingService.cs b/MediaBrowser.Api/Social/SharingService.cs index 37941bd4a3..4f10667b72 100644 --- a/MediaBrowser.Api/Social/SharingService.cs +++ b/MediaBrowser.Api/Social/SharingService.cs @@ -121,8 +121,7 @@ namespace MediaBrowser.Api.Social public void Delete(DeleteShare request) { - var task = _sharingManager.DeleteShare(request.Id); - Task.WaitAll(task); + _sharingManager.DeleteShare(request.Id); } public async Task Get(GetShareImage request) @@ -157,7 +156,7 @@ namespace MediaBrowser.Api.Social } catch { - + } } diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.cs index 7d612a796c..7a75aeb4be 100644 --- a/MediaBrowser.Api/StartupWizardService.cs +++ b/MediaBrowser.Api/StartupWizardService.cs @@ -125,7 +125,7 @@ namespace MediaBrowser.Api var user = _userManager.Users.First(); user.Name = request.Name; - await _userManager.UpdateUser(user).ConfigureAwait(false); + _userManager.UpdateUser(user); var result = new UpdateStartupUserResult(); diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs index 87a06e4d59..1bbc740c01 100644 --- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs +++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs @@ -12,11 +12,9 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Controller.Entities.Audio; -using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Services; -using MediaBrowser.Model.Extensions; namespace MediaBrowser.Api.UserLibrary { @@ -507,9 +505,9 @@ namespace MediaBrowser.Api.UserLibrary /// Posts the specified request. /// /// The request. - public async Task Post(MarkFavoriteItem request) + public object Post(MarkFavoriteItem request) { - var dto = await MarkFavorite(request.UserId, request.Id, true).ConfigureAwait(false); + var dto = MarkFavorite(request.UserId, request.Id, true); return ToOptimizedResult(dto); } @@ -520,7 +518,7 @@ namespace MediaBrowser.Api.UserLibrary /// The request. public object Delete(UnmarkFavoriteItem request) { - var dto = MarkFavorite(request.UserId, request.Id, false).Result; + var dto = MarkFavorite(request.UserId, request.Id, false); return ToOptimizedResult(dto); } @@ -531,8 +529,7 @@ namespace MediaBrowser.Api.UserLibrary /// The user id. /// The item id. /// if set to true [is favorite]. - /// Task{UserItemDataDto}. - private async Task MarkFavorite(string userId, string itemId, bool isFavorite) + private UserItemDataDto MarkFavorite(string userId, string itemId, bool isFavorite) { var user = _userManager.GetUserById(userId); @@ -544,7 +541,7 @@ namespace MediaBrowser.Api.UserLibrary // Set favorite status data.IsFavorite = isFavorite; - await _userDataRepository.SaveUserData(user.Id, item, data, UserDataSaveReason.UpdateUserRating, CancellationToken.None).ConfigureAwait(false); + _userDataRepository.SaveUserData(user.Id, item, data, UserDataSaveReason.UpdateUserRating, CancellationToken.None); return _userDataRepository.GetUserDataDto(item, user); } @@ -555,7 +552,7 @@ namespace MediaBrowser.Api.UserLibrary /// The request. public object Delete(DeleteUserItemRating request) { - var dto = UpdateUserItemRating(request.UserId, request.Id, null).Result; + var dto = UpdateUserItemRating(request.UserId, request.Id, null); return ToOptimizedResult(dto); } @@ -564,9 +561,9 @@ namespace MediaBrowser.Api.UserLibrary /// Posts the specified request. /// /// The request. - public async Task Post(UpdateUserItemRating request) + public object Post(UpdateUserItemRating request) { - var dto = await UpdateUserItemRating(request.UserId, request.Id, request.Likes).ConfigureAwait(false); + var dto = UpdateUserItemRating(request.UserId, request.Id, request.Likes); return ToOptimizedResult(dto); } @@ -577,8 +574,7 @@ namespace MediaBrowser.Api.UserLibrary /// The user id. /// The item id. /// if set to true [likes]. - /// Task{UserItemDataDto}. - private async Task UpdateUserItemRating(string userId, string itemId, bool? likes) + private UserItemDataDto UpdateUserItemRating(string userId, string itemId, bool? likes) { var user = _userManager.GetUserById(userId); @@ -589,7 +585,7 @@ namespace MediaBrowser.Api.UserLibrary data.Likes = likes; - await _userDataRepository.SaveUserData(user.Id, item, data, UserDataSaveReason.UpdateUserRating, CancellationToken.None).ConfigureAwait(false); + _userDataRepository.SaveUserData(user.Id, item, data, UserDataSaveReason.UpdateUserRating, CancellationToken.None); return _userDataRepository.GetUserDataDto(item, user); } diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs index acdbf96f42..512356b43a 100644 --- a/MediaBrowser.Api/UserService.cs +++ b/MediaBrowser.Api/UserService.cs @@ -387,7 +387,7 @@ namespace MediaBrowser.Api throw new ResourceNotFoundException("User not found"); } - await _sessionMananger.RevokeUserTokens(user.Id.ToString("N"), null).ConfigureAwait(false); + _sessionMananger.RevokeUserTokens(user.Id.ToString("N"), null); await _userManager.DeleteUser(user).ConfigureAwait(false); } @@ -455,7 +455,7 @@ namespace MediaBrowser.Api if (request.ResetPassword) { - await _userManager.ResetPassword(user).ConfigureAwait(false); + _userManager.ResetPassword(user); } else { @@ -466,24 +466,18 @@ namespace MediaBrowser.Api throw new ArgumentException("Invalid user or password entered."); } - await _userManager.ChangePassword(user, request.NewPassword).ConfigureAwait(false); + _userManager.ChangePassword(user, request.NewPassword); var currentToken = _authContext.GetAuthorizationInfo(Request).Token; - await _sessionMananger.RevokeUserTokens(user.Id.ToString("N"), currentToken).ConfigureAwait(false); + _sessionMananger.RevokeUserTokens(user.Id.ToString("N"), currentToken); } } public void Post(UpdateUserEasyPassword request) - { - var task = PostAsync(request); - Task.WaitAll(task); - } - - public async Task PostAsync(UpdateUserEasyPassword request) { AssertCanUpdateUser(_authContext, _userManager, request.Id, true); - + var user = _userManager.GetUserById(request.Id); if (user == null) @@ -493,11 +487,11 @@ namespace MediaBrowser.Api if (request.ResetPassword) { - await _userManager.ResetEasyPassword(user).ConfigureAwait(false); + _userManager.ResetEasyPassword(user); } else { - await _userManager.ChangeEasyPassword(user, request.NewPassword).ConfigureAwait(false); + _userManager.ChangeEasyPassword(user, request.NewPassword); } } @@ -506,13 +500,6 @@ namespace MediaBrowser.Api /// /// The request. public void Post(UpdateUser request) - { - var task = PostAsync(request); - - Task.WaitAll(task); - } - - public async Task PostAsync(UpdateUser request) { // We need to parse this manually because we told service stack not to with IRequiresRequestStream // https://code.google.com/p/servicestack/source/browse/trunk/Common/ServiceStack.Text/ServiceStack.Text/Controller/PathInfo.cs @@ -524,13 +511,18 @@ namespace MediaBrowser.Api var user = _userManager.GetUserById(id); - var task = string.Equals(user.Name, dtoUser.Name, StringComparison.Ordinal) ? - _userManager.UpdateUser(user) : - _userManager.RenameUser(user, dtoUser.Name); + if (string.Equals(user.Name, dtoUser.Name, StringComparison.Ordinal)) + { + _userManager.UpdateUser(user); + } + else + { + var task = _userManager.RenameUser(user, dtoUser.Name); - await task.ConfigureAwait(false); + Task.WaitAll(task); + } - await _userManager.UpdateConfiguration(dtoUser.Id, dtoUser.Configuration); + _userManager.UpdateConfiguration(dtoUser.Id, dtoUser.Configuration); } /// @@ -570,21 +562,14 @@ namespace MediaBrowser.Api { AssertCanUpdateUser(_authContext, _userManager, request.Id, false); - var task = _userManager.UpdateConfiguration(request.Id, request); + _userManager.UpdateConfiguration(request.Id, request); - Task.WaitAll(task); } public void Post(UpdateUserPolicy request) - { - var task = UpdateUserPolicy(request); - Task.WaitAll(task); - } - - private async Task UpdateUserPolicy(UpdateUserPolicy request) { var user = _userManager.GetUserById(request.Id); - + // If removing admin access if (!request.IsAdministrator && user.Policy.IsAdministrator) { @@ -609,10 +594,10 @@ namespace MediaBrowser.Api } var currentToken = _authContext.GetAuthorizationInfo(Request).Token; - await _sessionMananger.RevokeUserTokens(user.Id.ToString("N"), currentToken).ConfigureAwait(false); + _sessionMananger.RevokeUserTokens(user.Id.ToString("N"), currentToken); } - await _userManager.UpdateUserPolicy(request.Id, request).ConfigureAwait(false); + _userManager.UpdateUserPolicy(request.Id, request); } } } diff --git a/MediaBrowser.Controller/Chapters/IChapterManager.cs b/MediaBrowser.Controller/Chapters/IChapterManager.cs index 85feec40b7..d1c190ab54 100644 --- a/MediaBrowser.Controller/Chapters/IChapterManager.cs +++ b/MediaBrowser.Controller/Chapters/IChapterManager.cs @@ -14,11 +14,11 @@ namespace MediaBrowser.Controller.Chapters /// /// The item identifier. /// List{ChapterInfo}. - IEnumerable GetChapters(string itemId); + List GetChapters(string itemId); /// /// Saves the chapters. /// - Task SaveChapters(string itemId, List chapters); + void SaveChapters(string itemId, List chapters); } } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 51dc59c19e..513b85d8b1 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1771,7 +1771,7 @@ namespace MediaBrowser.Controller.Entities /// if set to true [reset position]. /// Task. /// - public virtual async Task MarkPlayed(User user, + public virtual void MarkPlayed(User user, DateTime? datePlayed, bool resetPosition) { @@ -1799,7 +1799,7 @@ namespace MediaBrowser.Controller.Entities data.LastPlayedDate = datePlayed ?? data.LastPlayedDate ?? DateTime.UtcNow; data.Played = true; - await UserDataManager.SaveUserData(user.Id, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None).ConfigureAwait(false); + UserDataManager.SaveUserData(user.Id, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None); } /// @@ -1808,7 +1808,7 @@ namespace MediaBrowser.Controller.Entities /// The user. /// Task. /// - public virtual async Task MarkUnplayed(User user) + public virtual void MarkUnplayed(User user) { if (user == null) { @@ -1825,7 +1825,7 @@ namespace MediaBrowser.Controller.Entities data.LastPlayedDate = null; data.Played = false; - await UserDataManager.SaveUserData(user.Id, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None).ConfigureAwait(false); + UserDataManager.SaveUserData(user.Id, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None); } /// diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 11c0a57473..8a87f3c6a5 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -186,7 +186,7 @@ namespace MediaBrowser.Controller.Entities /// The cancellation token. /// Task. /// Unable to add + item.Name - public async Task AddChild(BaseItem item, CancellationToken cancellationToken) + public void AddChild(BaseItem item, CancellationToken cancellationToken) { item.SetParent(this); @@ -209,7 +209,7 @@ namespace MediaBrowser.Controller.Entities item.DateModified = DateTime.UtcNow; } - await LibraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false); + LibraryManager.CreateItem(item, cancellationToken); } /// @@ -469,7 +469,7 @@ namespace MediaBrowser.Controller.Entities } } - await LibraryManager.CreateItems(newItems, cancellationToken).ConfigureAwait(false); + LibraryManager.CreateItems(newItems, cancellationToken); } } else @@ -1370,7 +1370,7 @@ namespace MediaBrowser.Controller.Entities /// The date played. /// if set to true [reset position]. /// Task. - public override async Task MarkPlayed(User user, + public override void MarkPlayed(User user, DateTime? datePlayed, bool resetPosition) { @@ -1390,9 +1390,10 @@ namespace MediaBrowser.Controller.Entities var itemsResult = GetItemList(query); // Sweep through recursively and update status - var tasks = itemsResult.Select(c => c.MarkPlayed(user, datePlayed, resetPosition)); - - await Task.WhenAll(tasks).ConfigureAwait(false); + foreach (var item in itemsResult) + { + item.MarkPlayed(user, datePlayed, resetPosition); + } } /// @@ -1400,7 +1401,7 @@ namespace MediaBrowser.Controller.Entities /// /// The user. /// Task. - public override async Task MarkUnplayed(User user) + public override void MarkUnplayed(User user) { var itemsResult = GetItemList(new InternalItemsQuery { @@ -1412,9 +1413,10 @@ namespace MediaBrowser.Controller.Entities }); // Sweep through recursively and update status - var tasks = itemsResult.Select(c => c.MarkUnplayed(user)); - - await Task.WhenAll(tasks).ConfigureAwait(false); + foreach (var item in itemsResult) + { + item.MarkUnplayed(user); + } } public override bool IsPlayed(User user) diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index 851686ea8e..3c89037cca 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -165,7 +165,7 @@ namespace MediaBrowser.Controller.Entities } } } - + return _policy; } set { _policy = value; } @@ -194,24 +194,24 @@ namespace MediaBrowser.Controller.Entities var oldConfigurationDirectory = ConfigurationDirectoryPath; // Exceptions will be thrown if these paths already exist - if (FileSystem.DirectoryExists(newConfigDirectory)) + if (FileSystem.DirectoryExists(newConfigDirectory)) { FileSystem.DeleteDirectory(newConfigDirectory, true); } - if (FileSystem.DirectoryExists(oldConfigurationDirectory)) + if (FileSystem.DirectoryExists(oldConfigurationDirectory)) { - FileSystem.MoveDirectory(oldConfigurationDirectory, newConfigDirectory); + FileSystem.MoveDirectory(oldConfigurationDirectory, newConfigDirectory); } else { - FileSystem.CreateDirectory(newConfigDirectory); + FileSystem.CreateDirectory(newConfigDirectory); } } Name = newName; - return RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(Logger, FileSystem)) + return RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(Logger, FileSystem)) { ReplaceAllMetadata = true, ImageRefreshMode = ImageRefreshMode.FullRefresh, @@ -223,7 +223,8 @@ namespace MediaBrowser.Controller.Entities public override Task UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken) { - return UserManager.UpdateUser(this); + UserManager.UpdateUser(this); + return Task.FromResult(true); } /// diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index cd1781220e..265d4d7865 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -195,16 +195,14 @@ namespace MediaBrowser.Controller.Library /// /// The item. /// The cancellation token. - /// Task. - Task CreateItem(BaseItem item, CancellationToken cancellationToken); + void CreateItem(BaseItem item, CancellationToken cancellationToken); /// /// Creates the items. /// /// The items. /// The cancellation token. - /// Task. - Task CreateItems(IEnumerable items, CancellationToken cancellationToken); + void CreateItems(IEnumerable items, CancellationToken cancellationToken); /// /// Updates the item. @@ -303,7 +301,7 @@ namespace MediaBrowser.Controller.Library /// Name of the sort. /// The cancellation token. /// Task<UserView>. - Task GetNamedView(User user, + UserView GetNamedView(User user, string name, string parentId, string viewType, @@ -319,7 +317,7 @@ namespace MediaBrowser.Controller.Library /// Name of the sort. /// The cancellation token. /// Task<UserView>. - Task GetNamedView(User user, + UserView GetNamedView(User user, string name, string viewType, string sortName, @@ -363,7 +361,7 @@ namespace MediaBrowser.Controller.Library /// Name of the sort. /// The cancellation token. /// Task<UserView>. - Task GetShadowView(BaseItem parent, + UserView GetShadowView(BaseItem parent, string viewType, string sortName, CancellationToken cancellationToken); @@ -471,8 +469,7 @@ namespace MediaBrowser.Controller.Library /// /// The item. /// The people. - /// Task. - Task UpdatePeople(BaseItem item, List people); + void UpdatePeople(BaseItem item, List people); /// /// Gets the item ids. diff --git a/MediaBrowser.Controller/Library/IUserDataManager.cs b/MediaBrowser.Controller/Library/IUserDataManager.cs index b364ab9909..cd4bd2e34e 100644 --- a/MediaBrowser.Controller/Library/IUserDataManager.cs +++ b/MediaBrowser.Controller/Library/IUserDataManager.cs @@ -4,7 +4,6 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using System; using System.Threading; -using System.Threading.Tasks; using MediaBrowser.Model.Querying; namespace MediaBrowser.Controller.Library @@ -28,7 +27,7 @@ namespace MediaBrowser.Controller.Library /// The reason. /// The cancellation token. /// Task. - Task SaveUserData(Guid userId, IHasUserData item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken); + void SaveUserData(Guid userId, IHasUserData item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken); UserItemData GetUserData(IHasUserData user, IHasUserData item); @@ -47,7 +46,7 @@ namespace MediaBrowser.Controller.Library /// /// /// - IEnumerable GetAllUserData(Guid userId); + List GetAllUserData(Guid userId); /// /// Save the all provided user data for the given user @@ -56,7 +55,7 @@ namespace MediaBrowser.Controller.Library /// /// /// - Task SaveAllUserData(Guid userId, IEnumerable userData, CancellationToken cancellationToken); + void SaveAllUserData(Guid userId, UserItemData[] userData, CancellationToken cancellationToken); /// /// Updates playstate for an item and returns true or false indicating if it was played to completion diff --git a/MediaBrowser.Controller/Library/IUserManager.cs b/MediaBrowser.Controller/Library/IUserManager.cs index ef68d2560c..6da3e53aab 100644 --- a/MediaBrowser.Controller/Library/IUserManager.cs +++ b/MediaBrowser.Controller/Library/IUserManager.cs @@ -91,7 +91,7 @@ namespace MediaBrowser.Controller.Library /// The user. /// user /// - Task UpdateUser(User user); + void UpdateUser(User user); /// /// Creates the user. @@ -116,7 +116,7 @@ namespace MediaBrowser.Controller.Library /// /// The user. /// Task. - Task ResetPassword(User user); + void ResetPassword(User user); /// /// Gets the offline user dto. @@ -130,7 +130,7 @@ namespace MediaBrowser.Controller.Library /// /// The user. /// Task. - Task ResetEasyPassword(User user); + void ResetEasyPassword(User user); /// /// Changes the password. @@ -138,7 +138,7 @@ namespace MediaBrowser.Controller.Library /// The user. /// The new password sha1. /// Task. - Task ChangePassword(User user, string newPasswordSha1); + void ChangePassword(User user, string newPasswordSha1); /// /// Changes the easy password. @@ -146,7 +146,7 @@ namespace MediaBrowser.Controller.Library /// The user. /// The new password sha1. /// Task. - Task ChangeEasyPassword(User user, string newPasswordSha1); + void ChangeEasyPassword(User user, string newPasswordSha1); /// /// Gets the user dto. @@ -179,7 +179,7 @@ namespace MediaBrowser.Controller.Library /// /// The pin. /// true if XXXX, false otherwise. - Task RedeemPasswordResetPin(string pin); + PinRedeemResult RedeemPasswordResetPin(string pin); /// /// Gets the user policy. @@ -201,14 +201,14 @@ namespace MediaBrowser.Controller.Library /// The user identifier. /// The new configuration. /// Task. - Task UpdateConfiguration(string userId, UserConfiguration newConfiguration); + void UpdateConfiguration(string userId, UserConfiguration newConfiguration); /// /// Updates the user policy. /// /// The user identifier. /// The user policy. - Task UpdateUserPolicy(string userId, UserPolicy userPolicy); + void UpdateUserPolicy(string userId, UserPolicy userPolicy); /// /// Makes the valid username. diff --git a/MediaBrowser.Controller/Persistence/IDisplayPreferencesRepository.cs b/MediaBrowser.Controller/Persistence/IDisplayPreferencesRepository.cs index abf96994f1..25aba6bd9e 100644 --- a/MediaBrowser.Controller/Persistence/IDisplayPreferencesRepository.cs +++ b/MediaBrowser.Controller/Persistence/IDisplayPreferencesRepository.cs @@ -2,7 +2,6 @@ using MediaBrowser.Model.Entities; using System; using System.Threading; -using System.Threading.Tasks; namespace MediaBrowser.Controller.Persistence { @@ -19,9 +18,9 @@ namespace MediaBrowser.Controller.Persistence /// The client. /// The cancellation token. /// Task. - Task SaveDisplayPreferences(DisplayPreferences displayPreferences, string userId, string client, + void SaveDisplayPreferences(DisplayPreferences displayPreferences, string userId, string client, CancellationToken cancellationToken); - + /// /// Saves all display preferences for a user /// @@ -29,7 +28,7 @@ namespace MediaBrowser.Controller.Persistence /// The user id. /// The cancellation token. /// Task. - Task SaveAllDisplayPreferences(IEnumerable displayPreferences, Guid userId, + void SaveAllDisplayPreferences(IEnumerable displayPreferences, Guid userId, CancellationToken cancellationToken); /// /// Gets the display preferences. diff --git a/MediaBrowser.Controller/Persistence/IItemRepository.cs b/MediaBrowser.Controller/Persistence/IItemRepository.cs index bf54914b1d..3d05d2fcab 100644 --- a/MediaBrowser.Controller/Persistence/IItemRepository.cs +++ b/MediaBrowser.Controller/Persistence/IItemRepository.cs @@ -3,7 +3,6 @@ using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; using System.Threading; -using System.Threading.Tasks; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Querying; @@ -19,16 +18,14 @@ namespace MediaBrowser.Controller.Persistence /// /// The item. /// The cancellation token. - /// Task. - Task SaveItem(BaseItem item, CancellationToken cancellationToken); + void SaveItem(BaseItem item, CancellationToken cancellationToken); /// /// Deletes the item. /// /// The identifier. /// The cancellation token. - /// Task. - Task DeleteItem(Guid id, CancellationToken cancellationToken); + void DeleteItem(Guid id, CancellationToken cancellationToken); /// /// Gets the critic reviews. @@ -42,16 +39,14 @@ namespace MediaBrowser.Controller.Persistence /// /// The item id. /// The critic reviews. - /// Task. - Task SaveCriticReviews(Guid itemId, IEnumerable criticReviews); + void SaveCriticReviews(Guid itemId, IEnumerable criticReviews); /// /// Saves the items. /// /// The items. /// The cancellation token. - /// Task. - Task SaveItems(List items, CancellationToken cancellationToken); + void SaveItems(List items, CancellationToken cancellationToken); /// /// Retrieves the item. @@ -78,7 +73,7 @@ namespace MediaBrowser.Controller.Persistence /// /// Saves the chapters. /// - Task SaveChapters(Guid id, List chapters); + void SaveChapters(Guid id, List chapters); /// /// Gets the media streams. @@ -93,8 +88,7 @@ namespace MediaBrowser.Controller.Persistence /// The identifier. /// The streams. /// The cancellation token. - /// Task. - Task SaveMediaStreams(Guid id, List streams, CancellationToken cancellationToken); + void SaveMediaStreams(Guid id, List streams, CancellationToken cancellationToken); /// /// Gets the item ids. @@ -128,8 +122,7 @@ namespace MediaBrowser.Controller.Persistence /// /// The item identifier. /// The people. - /// Task. - Task UpdatePeople(Guid itemId, List people); + void UpdatePeople(Guid itemId, List people); /// /// Gets the people names. @@ -156,8 +149,7 @@ namespace MediaBrowser.Controller.Persistence /// Updates the inherited values. /// /// The cancellation token. - /// Task. - Task UpdateInheritedValues(CancellationToken cancellationToken); + void UpdateInheritedValues(CancellationToken cancellationToken); int GetCount(InternalItemsQuery query); diff --git a/MediaBrowser.Controller/Persistence/IUserDataRepository.cs b/MediaBrowser.Controller/Persistence/IUserDataRepository.cs index ca4dc97513..f79a3a9fc7 100644 --- a/MediaBrowser.Controller/Persistence/IUserDataRepository.cs +++ b/MediaBrowser.Controller/Persistence/IUserDataRepository.cs @@ -2,7 +2,6 @@ using MediaBrowser.Controller.Entities; using System; using System.Threading; -using System.Threading.Tasks; namespace MediaBrowser.Controller.Persistence { @@ -19,7 +18,7 @@ namespace MediaBrowser.Controller.Persistence /// The user data. /// The cancellation token. /// Task. - Task SaveUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken); + void SaveUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken); /// /// Gets the user data. @@ -36,7 +35,7 @@ namespace MediaBrowser.Controller.Persistence /// /// /// - IEnumerable GetAllUserData(Guid userId); + List GetAllUserData(Guid userId); /// /// Save all user data associated with the given user @@ -45,7 +44,7 @@ namespace MediaBrowser.Controller.Persistence /// /// /// - Task SaveAllUserData(Guid userId, IEnumerable userData, CancellationToken cancellationToken); + void SaveAllUserData(Guid userId, UserItemData[] userData, CancellationToken cancellationToken); } } diff --git a/MediaBrowser.Controller/Persistence/IUserRepository.cs b/MediaBrowser.Controller/Persistence/IUserRepository.cs index 80961a369a..721ddb7e36 100644 --- a/MediaBrowser.Controller/Persistence/IUserRepository.cs +++ b/MediaBrowser.Controller/Persistence/IUserRepository.cs @@ -1,7 +1,6 @@ using MediaBrowser.Controller.Entities; using System.Collections.Generic; using System.Threading; -using System.Threading.Tasks; namespace MediaBrowser.Controller.Persistence { @@ -16,7 +15,7 @@ namespace MediaBrowser.Controller.Persistence /// The user. /// The cancellation token. /// Task. - Task DeleteUser(User user, CancellationToken cancellationToken); + void DeleteUser(User user, CancellationToken cancellationToken); /// /// Saves the user. @@ -24,7 +23,7 @@ namespace MediaBrowser.Controller.Persistence /// The user. /// The cancellation token. /// Task. - Task SaveUser(User user, CancellationToken cancellationToken); + void SaveUser(User user, CancellationToken cancellationToken); /// /// Retrieves all users. diff --git a/MediaBrowser.Controller/Security/IAuthenticationRepository.cs b/MediaBrowser.Controller/Security/IAuthenticationRepository.cs index 219b07028d..f80ee6e7fb 100644 --- a/MediaBrowser.Controller/Security/IAuthenticationRepository.cs +++ b/MediaBrowser.Controller/Security/IAuthenticationRepository.cs @@ -1,6 +1,5 @@ using MediaBrowser.Model.Querying; using System.Threading; -using System.Threading.Tasks; namespace MediaBrowser.Controller.Security { @@ -12,7 +11,7 @@ namespace MediaBrowser.Controller.Security /// The information. /// The cancellation token. /// Task. - Task Create(AuthenticationInfo info, CancellationToken cancellationToken); + void Create(AuthenticationInfo info, CancellationToken cancellationToken); /// /// Updates the specified information. @@ -20,7 +19,7 @@ namespace MediaBrowser.Controller.Security /// The information. /// The cancellation token. /// Task. - Task Update(AuthenticationInfo info, CancellationToken cancellationToken); + void Update(AuthenticationInfo info, CancellationToken cancellationToken); /// /// Gets the specified query. diff --git a/MediaBrowser.Controller/Session/ISessionManager.cs b/MediaBrowser.Controller/Session/ISessionManager.cs index 8d77e07479..603e5ef762 100644 --- a/MediaBrowser.Controller/Session/ISessionManager.cs +++ b/MediaBrowser.Controller/Session/ISessionManager.cs @@ -318,19 +318,19 @@ namespace MediaBrowser.Controller.Session /// /// The access token. /// Task. - Task Logout(string accessToken); + void Logout(string accessToken); /// /// Revokes the user tokens. /// /// Task. - Task RevokeUserTokens(string userId, string currentAccessToken); + void RevokeUserTokens(string userId, string currentAccessToken); /// /// Revokes the token. /// /// The identifier. /// Task. - Task RevokeToken(string id); + void RevokeToken(string id); } } \ No newline at end of file diff --git a/MediaBrowser.Model/Activity/IActivityManager.cs b/MediaBrowser.Model/Activity/IActivityManager.cs index 7032dff143..396be95737 100644 --- a/MediaBrowser.Model/Activity/IActivityManager.cs +++ b/MediaBrowser.Model/Activity/IActivityManager.cs @@ -1,5 +1,4 @@ using System; -using System.Threading.Tasks; using MediaBrowser.Model.Events; using MediaBrowser.Model.Querying; @@ -9,7 +8,7 @@ namespace MediaBrowser.Model.Activity { event EventHandler> EntryCreated; - Task Create(ActivityLogEntry entry); + void Create(ActivityLogEntry entry); QueryResult GetActivityLogEntries(DateTime? minDate, int? startIndex, int? limit); } diff --git a/MediaBrowser.Model/Activity/IActivityRepository.cs b/MediaBrowser.Model/Activity/IActivityRepository.cs index c1952d436b..8ee87ee2ea 100644 --- a/MediaBrowser.Model/Activity/IActivityRepository.cs +++ b/MediaBrowser.Model/Activity/IActivityRepository.cs @@ -1,12 +1,11 @@ using System; -using System.Threading.Tasks; using MediaBrowser.Model.Querying; namespace MediaBrowser.Model.Activity { public interface IActivityRepository { - Task Create(ActivityLogEntry entry); + void Create(ActivityLogEntry entry); QueryResult GetActivityLogEntries(DateTime? minDate, int? startIndex, int? limit); } diff --git a/MediaBrowser.Model/Social/ISharingManager.cs b/MediaBrowser.Model/Social/ISharingManager.cs index 94c22baba5..28c8c7db22 100644 --- a/MediaBrowser.Model/Social/ISharingManager.cs +++ b/MediaBrowser.Model/Social/ISharingManager.cs @@ -22,6 +22,6 @@ namespace MediaBrowser.Model.Social /// /// The identifier. /// Task. - Task DeleteShare(string id); + void DeleteShare(string id); } } diff --git a/MediaBrowser.Model/Social/ISharingRepository.cs b/MediaBrowser.Model/Social/ISharingRepository.cs index 1dadd7f71a..dd88ddd042 100644 --- a/MediaBrowser.Model/Social/ISharingRepository.cs +++ b/MediaBrowser.Model/Social/ISharingRepository.cs @@ -1,11 +1,10 @@ -using System.Threading.Tasks; - + namespace MediaBrowser.Model.Social { public interface ISharingRepository { - Task CreateShare(SocialShareInfo info); - Task DeleteShare(string id); + void CreateShare(SocialShareInfo info); + void DeleteShare(string id); SocialShareInfo GetShareInfo(string id); } } diff --git a/MediaBrowser.Providers/Chapters/ChapterManager.cs b/MediaBrowser.Providers/Chapters/ChapterManager.cs index d3e9efd820..1bbc6fa4ea 100644 --- a/MediaBrowser.Providers/Chapters/ChapterManager.cs +++ b/MediaBrowser.Providers/Chapters/ChapterManager.cs @@ -33,14 +33,14 @@ namespace MediaBrowser.Providers.Chapters _itemRepo = itemRepo; } - public IEnumerable GetChapters(string itemId) + public List GetChapters(string itemId) { return _itemRepo.GetChapters(new Guid(itemId)); } - public Task SaveChapters(string itemId, List chapters) + public void SaveChapters(string itemId, List chapters) { - return _itemRepo.SaveChapters(new Guid(itemId), chapters); + _itemRepo.SaveChapters(new Guid(itemId), chapters); } } } diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index 5d531c95c6..9a7ced0a5c 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -201,7 +201,7 @@ namespace MediaBrowser.Providers.Manager { var baseItem = result.Item as BaseItem; - await LibraryManager.UpdatePeople(baseItem, result.People); + LibraryManager.UpdatePeople(baseItem, result.People); await SavePeopleMetadata(result.People, libraryOptions, cancellationToken).ConfigureAwait(false); } await result.Item.UpdateToRepository(reason, cancellationToken).ConfigureAwait(false); @@ -519,7 +519,7 @@ namespace MediaBrowser.Providers.Manager userDataList.AddRange(localItem.UserDataList); } - MergeData(localItem, temp, new MetadataFields[]{}, !options.ReplaceAllMetadata, true); + MergeData(localItem, temp, new MetadataFields[] { }, !options.ReplaceAllMetadata, true); refreshResult.UpdateType = refreshResult.UpdateType | ItemUpdateType.MetadataImport; // Only one local provider allowed per item @@ -567,7 +567,7 @@ namespace MediaBrowser.Providers.Manager else { // TODO: If the new metadata from above has some blank data, this can cause old data to get filled into those empty fields - MergeData(metadata, temp, new MetadataFields[]{}, false, false); + MergeData(metadata, temp, new MetadataFields[] { }, false, false); MergeData(temp, metadata, item.LockedFields, true, false); } } @@ -580,7 +580,7 @@ namespace MediaBrowser.Providers.Manager await RunCustomProvider(provider, item, logName, options, refreshResult, cancellationToken).ConfigureAwait(false); } - await ImportUserData(item, userDataList, cancellationToken).ConfigureAwait(false); + ImportUserData(item, userDataList, cancellationToken); return refreshResult; } @@ -595,7 +595,7 @@ namespace MediaBrowser.Providers.Manager return true; } - private async Task ImportUserData(TItemType item, List userDataList, CancellationToken cancellationToken) + private void ImportUserData(TItemType item, List userDataList, CancellationToken cancellationToken) { var hasUserData = item as IHasUserData; @@ -603,8 +603,7 @@ namespace MediaBrowser.Providers.Manager { foreach (var userData in userDataList) { - await UserDataManager.SaveUserData(userData.UserId, hasUserData, userData, UserDataSaveReason.Import, cancellationToken) - .ConfigureAwait(false); + UserDataManager.SaveUserData(userData.UserId, hasUserData, userData, UserDataSaveReason.Import, cancellationToken); } } } @@ -704,7 +703,7 @@ namespace MediaBrowser.Providers.Manager foreach (var result in results) { - MergeData(result, temp, new MetadataFields[]{}, false, false); + MergeData(result, temp, new MetadataFields[] { }, false, false); } return refreshResult; diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs index b0785298b8..aa6e5ad316 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs @@ -43,7 +43,7 @@ namespace MediaBrowser.Providers.MediaInfo cancellationToken.ThrowIfCancellationRequested(); - await Fetch(item, cancellationToken, result).ConfigureAwait(false); + Fetch(item, cancellationToken, result); return ItemUpdateType.MetadataImport; } @@ -92,7 +92,7 @@ namespace MediaBrowser.Providers.MediaInfo /// The cancellation token. /// The media information. /// Task. - protected async Task Fetch(Audio audio, CancellationToken cancellationToken, Model.MediaInfo.MediaInfo mediaInfo) + protected void Fetch(Audio audio, CancellationToken cancellationToken, Model.MediaInfo.MediaInfo mediaInfo) { var mediaStreams = mediaInfo.MediaStreams; @@ -102,12 +102,12 @@ namespace MediaBrowser.Providers.MediaInfo audio.RunTimeTicks = mediaInfo.RunTimeTicks; audio.Size = mediaInfo.Size; - var extension = (Path.GetExtension(audio.Path) ?? string.Empty).TrimStart('.'); + //var extension = (Path.GetExtension(audio.Path) ?? string.Empty).TrimStart('.'); //audio.Container = extension; - await FetchDataFromTags(audio, mediaInfo).ConfigureAwait(false); + FetchDataFromTags(audio, mediaInfo); - await _itemRepo.SaveMediaStreams(audio.Id, mediaStreams, cancellationToken).ConfigureAwait(false); + _itemRepo.SaveMediaStreams(audio.Id, mediaStreams, cancellationToken); } /// @@ -115,7 +115,7 @@ namespace MediaBrowser.Providers.MediaInfo /// /// The audio. /// The data. - private async Task FetchDataFromTags(Audio audio, Model.MediaInfo.MediaInfo data) + private void FetchDataFromTags(Audio audio, Model.MediaInfo.MediaInfo data) { // Only set Name if title was found in the dictionary if (!string.IsNullOrEmpty(data.Name)) @@ -137,7 +137,7 @@ namespace MediaBrowser.Providers.MediaInfo }); } - await _libraryManager.UpdatePeople(audio, people).ConfigureAwait(false); + _libraryManager.UpdatePeople(audio, people); } audio.Album = data.Album; diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs index 76cd02cef7..64a485bc20 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfo.cs @@ -198,7 +198,7 @@ namespace MediaBrowser.Providers.MediaInfo var libraryOptions = _libraryManager.GetLibraryOptions(video); FetchEmbeddedInfo(video, mediaInfo, options, libraryOptions); - await FetchPeople(video, mediaInfo, options).ConfigureAwait(false); + FetchPeople(video, mediaInfo, options); video.IsHD = mediaStreams.Any(i => i.Type == MediaStreamType.Video && i.Width.HasValue && i.Width.Value >= 1260); @@ -211,7 +211,7 @@ namespace MediaBrowser.Providers.MediaInfo video.Video3DFormat = video.Video3DFormat ?? mediaInfo.Video3DFormat; - await _itemRepo.SaveMediaStreams(video.Id, mediaStreams, cancellationToken).ConfigureAwait(false); + _itemRepo.SaveMediaStreams(video.Id, mediaStreams, cancellationToken); if (options.MetadataRefreshMode == MetadataRefreshMode.FullRefresh || options.MetadataRefreshMode == MetadataRefreshMode.Default) @@ -231,7 +231,7 @@ namespace MediaBrowser.Providers.MediaInfo await _encodingManager.RefreshChapterImages(video, chapters, extractDuringScan, false, cancellationToken).ConfigureAwait(false); - await _chapterManager.SaveChapters(video.Id.ToString(), chapters).ConfigureAwait(false); + _chapterManager.SaveChapters(video.Id.ToString(), chapters); } } @@ -426,7 +426,7 @@ namespace MediaBrowser.Providers.MediaInfo } } - private async Task FetchPeople(Video video, Model.MediaInfo.MediaInfo data, MetadataRefreshOptions options) + private void FetchPeople(Video video, Model.MediaInfo.MediaInfo data, MetadataRefreshOptions options) { var isFullRefresh = options.MetadataRefreshMode == MetadataRefreshMode.FullRefresh; @@ -446,7 +446,7 @@ namespace MediaBrowser.Providers.MediaInfo }); } - await _libraryManager.UpdatePeople(video, people); + _libraryManager.UpdatePeople(video, people); } } } @@ -560,7 +560,7 @@ namespace MediaBrowser.Providers.MediaInfo titleNumber = primaryTitle.VideoTitleSetNumber; item.RunTimeTicks = GetRuntime(primaryTitle); } - + return _mediaEncoder.GetPrimaryPlaylistVobFiles(item.Path, mount, titleNumber) .Select(Path.GetFileName) .ToArray(); diff --git a/MediaBrowser.Providers/TV/DummySeasonProvider.cs b/MediaBrowser.Providers/TV/DummySeasonProvider.cs index aef29abbea..791d14b60c 100644 --- a/MediaBrowser.Providers/TV/DummySeasonProvider.cs +++ b/MediaBrowser.Providers/TV/DummySeasonProvider.cs @@ -37,7 +37,7 @@ namespace MediaBrowser.Providers.TV public async Task Run(Series series, CancellationToken cancellationToken) { await RemoveObsoleteSeasons(series).ConfigureAwait(false); - + var hasNewSeasons = await AddDummySeasonFolders(series, cancellationToken).ConfigureAwait(false); if (hasNewSeasons) @@ -129,8 +129,8 @@ namespace MediaBrowser.Providers.TV }; season.SetParent(series); - - await series.AddChild(season, cancellationToken).ConfigureAwait(false); + + series.AddChild(season, cancellationToken); await season.RefreshMetadata(new MetadataRefreshOptions(_fileSystem), cancellationToken).ConfigureAwait(false); diff --git a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs index cfe20c741f..44e3cff6a1 100644 --- a/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/MissingEpisodeProvider.cs @@ -206,7 +206,7 @@ namespace MediaBrowser.Providers.TV { var existingEpisodes = (from s in series from c in s.GetRecursiveChildren(i => i is Episode).Cast() - select new Tuple((c.ParentIndexNumber ?? 0) , c)) + select new Tuple((c.ParentIndexNumber ?? 0), c)) .ToList(); var lookup = episodeLookup as IList> ?? episodeLookup.ToList(); @@ -466,7 +466,7 @@ namespace MediaBrowser.Providers.TV episode.SetParent(season); - await season.AddChild(episode, cancellationToken).ConfigureAwait(false); + season.AddChild(episode, cancellationToken); await episode.RefreshMetadata(new MetadataRefreshOptions(_fileSystem), cancellationToken).ConfigureAwait(false); } @@ -534,7 +534,7 @@ namespace MediaBrowser.Providers.TV settings.CheckCharacters = false; settings.IgnoreProcessingInstructions = true; settings.IgnoreComments = true; - + // Use XmlReader for best performance using (var reader = XmlReader.Create(streamReader, settings)) { diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 3aa3d54036..87c8a70ae3 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.744 + 3.0.747 Emby.Common Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index ea30175e63..20c0430070 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.744 + 3.0.747 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 28297ee620897ef10daedb6acce2957de83d6238 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 26 Aug 2017 20:33:23 -0400 Subject: [PATCH 39/41] 3.2.28.8 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SharedVersion.cs b/SharedVersion.cs index a113282588..e8903fbb5c 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.28.7")] +[assembly: AssemblyVersion("3.2.28.8")] From cc85dcc9d14b0cb3679c640f56296b219e29a4c4 Mon Sep 17 00:00:00 2001 From: Luke Date: Sun, 27 Aug 2017 13:11:53 -0400 Subject: [PATCH 40/41] update mac project --- MediaBrowser.Server.Mac/Emby.Server.Mac.csproj | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MediaBrowser.Server.Mac/Emby.Server.Mac.csproj b/MediaBrowser.Server.Mac/Emby.Server.Mac.csproj index fe9ab13fad..bdc8fa7a8c 100644 --- a/MediaBrowser.Server.Mac/Emby.Server.Mac.csproj +++ b/MediaBrowser.Server.Mac/Emby.Server.Mac.csproj @@ -729,6 +729,9 @@ Resources\dashboard-ui\bower_components\emby-webcomponents\layoutmanager.js + + Resources\dashboard-ui\bower_components\emby-webcomponents\maintabsmanager.js + Resources\dashboard-ui\bower_components\emby-webcomponents\multidownload.js @@ -933,6 +936,9 @@ Resources\dashboard-ui\bower_components\emby-webcomponents\emby-textarea\emby-textarea.js + + Resources\dashboard-ui\bower_components\emby-webcomponents\flvjs\flv.min.js + Resources\dashboard-ui\bower_components\emby-webcomponents\fonts\fonts.css @@ -1155,6 +1161,9 @@ Resources\dashboard-ui\bower_components\emby-webcomponents\playback\brightnessosd.js + + Resources\dashboard-ui\bower_components\emby-webcomponents\playback\expirementalwarnings.js + Resources\dashboard-ui\bower_components\emby-webcomponents\playback\iconosd.css From 3c90600c85660ada52665f153ae6160b6c2be61a Mon Sep 17 00:00:00 2001 From: Luke Date: Sun, 27 Aug 2017 13:25:46 -0400 Subject: [PATCH 41/41] update mac project --- MediaBrowser.Server.Mac/Emby.Server.Mac.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Server.Mac/Emby.Server.Mac.csproj b/MediaBrowser.Server.Mac/Emby.Server.Mac.csproj index bdc8fa7a8c..3ec880a77e 100644 --- a/MediaBrowser.Server.Mac/Emby.Server.Mac.csproj +++ b/MediaBrowser.Server.Mac/Emby.Server.Mac.csproj @@ -1161,8 +1161,8 @@ Resources\dashboard-ui\bower_components\emby-webcomponents\playback\brightnessosd.js - - Resources\dashboard-ui\bower_components\emby-webcomponents\playback\expirementalwarnings.js + + Resources\dashboard-ui\bower_components\emby-webcomponents\playback\experimentalwarnings.js Resources\dashboard-ui\bower_components\emby-webcomponents\playback\iconosd.css