From e7a7c7bee81a0f642ed7e0314fde866968f490f3 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 1 Apr 2018 21:25:26 -0400 Subject: [PATCH 1/4] rework dynamic folder generation --- Emby.Dlna/ContentDirectory/ControlHandler.cs | 18 +- Emby.Dlna/Didl/DidlBuilder.cs | 12 +- Emby.Dlna/DlnaManager.cs | 1 - Emby.Dlna/Main/DlnaEntryPoint.cs | 1 - Emby.Dlna/PlayTo/Device.cs | 1 - Emby.Dlna/PlayTo/PlayToController.cs | 5 +- Emby.Dlna/PlayTo/PlayToManager.cs | 1 - .../ImageMagickEncoder.cs | 1 - Emby.Drawing.Skia/StripCollageBuilder.cs | 8 +- Emby.Drawing/ImageProcessor.cs | 2 - .../Activity/ActivityLogEntryPoint.cs | 1 - .../ApplicationHost.cs | 5 +- .../ChannelDynamicMediaSourceProvider.cs | 8 +- .../Channels/ChannelManager.cs | 15 +- .../Channels/ChannelPostScanTask.cs | 2 +- .../Collections/CollectionManager.cs | 173 +++++++--- .../Collections/CollectionsDynamicFolder.cs | 34 -- .../ServerConfigurationManager.cs | 12 + .../Data/BaseSqliteRepository.cs | 1 - .../Data/ManagedConnection.cs | 1 - .../Data/SqliteItemRepository.cs | 31 +- .../Devices/CameraUploadsDynamicFolder.cs | 40 --- .../Devices/CameraUploadsFolder.cs | 71 ---- .../Devices/DeviceManager.cs | 144 +++++++- .../Diagnostics/CommonProcess.cs | 1 - Emby.Server.Implementations/Dto/DtoService.cs | 14 +- .../Emby.Server.Implementations.csproj | 4 - .../EntryPoints/AutomaticRestartEntryPoint.cs | 1 - .../EntryPoints/ExternalPortForwarding.cs | 1 - .../EntryPoints/KeepServerAwake.cs | 1 - .../EntryPoints/LibraryChangedNotifier.cs | 1 - .../EntryPoints/RecordingNotifier.cs | 1 - .../EntryPoints/ServerEventNotifier.cs | 1 - .../EntryPoints/StartupWizard.cs | 1 - .../EntryPoints/SystemEvents.cs | 1 - .../EntryPoints/UdpServerEntryPoint.cs | 1 - .../EntryPoints/UsageEntryPoint.cs | 1 - .../EntryPoints/UserDataChangeNotifier.cs | 1 - .../HttpServer/HttpListenerHost.cs | 1 - .../HttpServer/SocketSharp/SharpWebSocket.cs | 1 - .../Library/LibraryManager.cs | 103 +++--- .../Library/MediaSourceManager.cs | 42 +-- .../Library/MusicManager.cs | 10 +- .../Library/SearchEngine.cs | 2 +- .../Library/UserViewManager.cs | 16 +- .../LiveTv/EmbyTV/EmbyTV.cs | 120 ++++--- .../LiveTv/EmbyTV/EntryPoint.cs | 1 - .../LiveTv/EmbyTV/RecordingHelper.cs | 11 +- .../LiveTv/Listings/XmlTvProvider.cs | 320 ------------------ .../LiveTv/LiveTvDtoService.cs | 10 +- .../LiveTv/LiveTvManager.cs | 67 ++-- .../LiveTv/LiveTvMediaSourceProvider.cs | 8 +- .../TunerHosts/HdHomerun/HdHomerunManager.cs | 2 - .../Localization/Core/ar.json | 1 + .../Localization/Core/bg-BG.json | 1 + .../Localization/Core/ca.json | 1 + .../Localization/Core/cs.json | 1 + .../Localization/Core/da.json | 1 + .../Localization/Core/de.json | 1 + .../Localization/Core/el.json | 1 + .../Localization/Core/en-GB.json | 1 + .../Localization/Core/en-US.json | 3 +- .../Localization/Core/es-AR.json | 1 + .../Localization/Core/es-MX.json | 1 + .../Localization/Core/es.json | 1 + .../Localization/Core/fr-CA.json | 1 + .../Localization/Core/fr.json | 1 + .../Localization/Core/gsw.json | 1 + .../Localization/Core/he.json | 1 + .../Localization/Core/hr.json | 1 + .../Localization/Core/hu.json | 1 + .../Localization/Core/it.json | 1 + .../Localization/Core/kk.json | 1 + .../Localization/Core/ko.json | 1 + .../Localization/Core/lt-LT.json | 1 + .../Localization/Core/ms.json | 1 + .../Localization/Core/nb.json | 1 + .../Localization/Core/nl.json | 1 + .../Localization/Core/pl.json | 1 + .../Localization/Core/pt-BR.json | 1 + .../Localization/Core/pt-PT.json | 1 + .../Localization/Core/ru.json | 1 + .../Localization/Core/sk.json | 1 + .../Localization/Core/sl-SI.json | 1 + .../Localization/Core/sv.json | 1 + .../Localization/Core/tr.json | 1 + .../Localization/Core/zh-CN.json | 1 + .../Localization/Core/zh-HK.json | 1 + .../Logging/SimpleLogManager.cs | 3 - .../Net/DisposableManagedObjectBase.cs | 11 +- .../News/NewsEntryPoint.cs | 1 - .../Notifications/Notifications.cs | 1 - .../Notifications/WebSocketNotifier.cs | 1 - .../ScheduledTasks/ScheduledTaskWorker.cs | 1 - .../ScheduledTasks/TaskManager.cs | 1 - .../ServerManager/ServerManager.cs | 1 - .../ServerManager/WebSocketConnection.cs | 1 - .../Services/ServiceExec.cs | 2 - .../Session/SessionManager.cs | 6 +- .../Session/SessionWebSocketListener.cs | 1 - .../Session/WebSocketController.cs | 1 - .../TV/TVSeriesManager.cs | 2 - .../Threading/CommonTimer.cs | 1 - Emby.Server.Implementations/Udp/UdpServer.cs | 1 - .../Updates/InstallationManager.cs | 1 - .../CollectionFolderImageProvider.cs | 55 +-- MediaBrowser.Api/ApiEntryPoint.cs | 1 - MediaBrowser.Api/BrandingService.cs | 8 +- MediaBrowser.Api/ChannelService.cs | 4 +- MediaBrowser.Api/Dlna/DlnaService.cs | 12 +- MediaBrowser.Api/FilterService.cs | 2 +- MediaBrowser.Api/Images/ImageService.cs | 51 +-- MediaBrowser.Api/Library/LibraryService.cs | 2 +- .../Library/LibraryStructureService.cs | 8 +- MediaBrowser.Api/LiveTv/LiveTvService.cs | 16 +- MediaBrowser.Api/Movies/CollectionService.cs | 4 +- MediaBrowser.Api/Movies/MoviesService.cs | 2 +- MediaBrowser.Api/Music/InstantMixService.cs | 2 +- MediaBrowser.Api/NotificationsService.cs | 12 +- MediaBrowser.Api/Session/SessionsService.cs | 4 +- MediaBrowser.Api/SimilarItemsHelper.cs | 7 +- MediaBrowser.Api/StartupWizardService.cs | 1 - MediaBrowser.Api/Subtitles/SubtitleService.cs | 14 +- MediaBrowser.Api/SuggestionsService.cs | 4 +- .../UserLibrary/ArtistsService.cs | 10 +- .../UserLibrary/BaseItemsByNameService.cs | 6 +- .../UserLibrary/BaseItemsRequest.cs | 29 +- MediaBrowser.Api/UserLibrary/ItemsService.cs | 14 +- .../UserLibrary/UserViewsService.cs | 2 + MediaBrowser.Common/Net/HttpResponseInfo.cs | 1 - .../Progress/ActionableProgress.cs | 1 - MediaBrowser.Controller/Channels/Channel.cs | 2 +- .../Collections/ICollectionManager.cs | 14 - .../Collections/ManualCollectionsFolder.cs | 46 --- .../Drawing/ImageProcessingOptions.cs | 1 - .../Drawing/ImageStream.cs | 1 - .../Entities/Audio/MusicArtist.cs | 2 +- .../Entities/Audio/MusicGenre.cs | 2 +- MediaBrowser.Controller/Entities/Folder.cs | 6 +- MediaBrowser.Controller/Entities/GameGenre.cs | 2 +- MediaBrowser.Controller/Entities/Genre.cs | 2 +- .../Entities/IHiddenFromDisplay.cs | 12 - .../Entities/InternalItemsQuery.cs | 44 +-- .../Entities/Movies/BoxSet.cs | 13 +- MediaBrowser.Controller/Entities/Person.cs | 2 +- MediaBrowser.Controller/Entities/Studio.cs | 2 +- .../Entities/UserViewBuilder.cs | 6 +- .../Library/ILibraryManager.cs | 4 +- .../Library/IMediaSourceManager.cs | 17 +- .../Library/IMediaSourceProvider.cs | 2 +- MediaBrowser.Controller/Library/Profiler.cs | 1 - .../LiveTv/ILiveTvManager.cs | 9 +- .../MediaBrowser.Controller.csproj | 2 - .../MediaEncoding/ISubtitleEncoder.cs | 3 +- .../Net/BasePeriodicWebSocketListener.cs | 1 - MediaBrowser.Controller/Playlists/Playlist.cs | 4 +- .../Session/SessionInfo.cs | 1 - .../Subtitles/ISubtitleManager.cs | 9 +- .../Configuration/ServerConfiguration.cs | 3 +- .../Configuration/UserConfiguration.cs | 3 +- MediaBrowser.Model/LiveTv/ProgramQuery.cs | 8 +- .../LiveTv/RecommendedProgramQuery.cs | 5 +- MediaBrowser.Model/Net/HttpResponse.cs | 1 - MediaBrowser.Model/Sync/SyncJob.cs | 4 +- MediaBrowser.Model/Sync/SyncJobRequest.cs | 5 +- .../BoxSets/BoxSetMetadataService.cs | 1 - .../CollectionFolderMetadataService.cs | 13 - .../Manager/ProviderManager.cs | 3 +- .../MediaInfo/SubtitleScheduledTask.cs | 2 +- .../Music/MusicExternalIds.cs | 24 ++ .../People/TvdbPersonImageProvider.cs | 2 +- .../Subtitles/SubtitleManager.cs | 9 +- .../Api/DashboardService.cs | 2 +- MediaBrowser.WebDashboard/ServerEntryPoint.cs | 1 - .../emby-webcomponents/alphapicker/style.css | 2 +- .../browserdeviceprofile.js | 2 +- .../emby-button/emby-button.css | 2 +- .../emby-checkbox/emby-checkbox.css | 2 +- .../emby-select/emby-select.js | 2 +- .../homescreensettings/homescreensettings.js | 2 +- .../homescreensettings.template.html | 22 +- .../htmlvideoplayer/plugin.js | 2 +- .../playback/playbackmanager.js | 4 +- .../emby-webcomponents/strings/ar.json | 6 + .../emby-webcomponents/strings/be-by.json | 6 + .../emby-webcomponents/strings/bg-bg.json | 6 + .../emby-webcomponents/strings/ca.json | 6 + .../emby-webcomponents/strings/cs.json | 6 + .../emby-webcomponents/strings/da.json | 6 + .../emby-webcomponents/strings/de.json | 30 +- .../emby-webcomponents/strings/el.json | 6 + .../emby-webcomponents/strings/en-gb.json | 18 +- .../emby-webcomponents/strings/en-us.json | 8 +- .../emby-webcomponents/strings/es-ar.json | 6 + .../emby-webcomponents/strings/es-mx.json | 14 +- .../emby-webcomponents/strings/es.json | 6 + .../emby-webcomponents/strings/fi.json | 6 + .../emby-webcomponents/strings/fr-ca.json | 6 + .../emby-webcomponents/strings/fr.json | 6 + .../emby-webcomponents/strings/gsw.json | 6 + .../emby-webcomponents/strings/he.json | 6 + .../emby-webcomponents/strings/hr.json | 6 + .../emby-webcomponents/strings/hu.json | 6 + .../emby-webcomponents/strings/id.json | 6 + .../emby-webcomponents/strings/it.json | 6 + .../emby-webcomponents/strings/kk.json | 18 +- .../emby-webcomponents/strings/ko.json | 6 + .../emby-webcomponents/strings/lt-lt.json | 6 + .../emby-webcomponents/strings/ms.json | 6 + .../emby-webcomponents/strings/nb.json | 6 + .../emby-webcomponents/strings/nl.json | 6 + .../emby-webcomponents/strings/pl.json | 6 + .../emby-webcomponents/strings/pt-br.json | 6 + .../emby-webcomponents/strings/pt-pt.json | 6 + .../emby-webcomponents/strings/ro.json | 6 + .../emby-webcomponents/strings/ru.json | 6 + .../emby-webcomponents/strings/sk.json | 8 +- .../emby-webcomponents/strings/sl-si.json | 6 + .../emby-webcomponents/strings/sv.json | 6 + .../emby-webcomponents/strings/tr.json | 6 + .../emby-webcomponents/strings/uk.json | 6 + .../emby-webcomponents/strings/vi.json | 6 + .../emby-webcomponents/strings/zh-cn.json | 6 + .../emby-webcomponents/strings/zh-hk.json | 6 + .../emby-webcomponents/strings/zh-tw.json | 6 + .../medialibrarycreator.template.html | 3 +- .../medialibraryeditor.template.html | 3 +- .../dashboard-ui/dashboard/librarydisplay.js | 2 +- .../dashboard-ui/librarydisplay.html | 12 - .../dashboard-ui/scripts/livetvsuggested.js | 2 +- .../dashboard-ui/serversecurity.html | 4 +- .../dashboard-ui/strings/en-US.json | 2 +- .../dashboard-ui/strings/es-MX.json | 6 +- .../dashboard-ui/strings/sk.json | 2 +- .../dashboard-ui/userparentalcontrol.html | 8 +- MediaBrowser.XbmcMetadata/EntryPoint.cs | 1 - RSSDP/DisposableManagedObjectBase.cs | 19 +- ThirdParty/emby/Emby.Server.CinemaMode.dll | Bin 27648 -> 27648 bytes ThirdParty/emby/Emby.Server.Connect.dll | Bin 64512 -> 64000 bytes ThirdParty/emby/Emby.Server.MediaEncoding.dll | Bin 273920 -> 275456 bytes ThirdParty/emby/Emby.Server.Sync.dll | Bin 184832 -> 184320 bytes 241 files changed, 1084 insertions(+), 1305 deletions(-) delete mode 100644 Emby.Server.Implementations/Collections/CollectionsDynamicFolder.cs delete mode 100644 Emby.Server.Implementations/Devices/CameraUploadsDynamicFolder.cs delete mode 100644 Emby.Server.Implementations/Devices/CameraUploadsFolder.cs delete mode 100644 Emby.Server.Implementations/LiveTv/Listings/XmlTvProvider.cs delete mode 100644 MediaBrowser.Controller/Collections/ManualCollectionsFolder.cs delete mode 100644 MediaBrowser.Controller/Entities/IHiddenFromDisplay.cs diff --git a/Emby.Dlna/ContentDirectory/ControlHandler.cs b/Emby.Dlna/ContentDirectory/ControlHandler.cs index eb70f6013a..d2d2d227fc 100644 --- a/Emby.Dlna/ContentDirectory/ControlHandler.cs +++ b/Emby.Dlna/ContentDirectory/ControlHandler.cs @@ -1024,7 +1024,7 @@ private QueryResult GetGenres(BaseItem parent, User user, InternalIt { var genresResult = _libraryManager.GetGenres(new InternalItemsQuery(user) { - AncestorIds = new[] { parent.Id.ToString("N") }, + AncestorIds = new[] { parent.Id }, StartIndex = query.StartIndex, Limit = query.Limit }); @@ -1042,7 +1042,7 @@ private QueryResult GetMusicGenres(BaseItem parent, User user, Inter { var genresResult = _libraryManager.GetMusicGenres(new InternalItemsQuery(user) { - AncestorIds = new[] { parent.Id.ToString("N") }, + AncestorIds = new[] { parent.Id }, StartIndex = query.StartIndex, Limit = query.Limit }); @@ -1060,7 +1060,7 @@ private QueryResult GetMusicAlbumArtists(BaseItem parent, User user, { var artists = _libraryManager.GetAlbumArtists(new InternalItemsQuery(user) { - AncestorIds = new[] { parent.Id.ToString("N") }, + AncestorIds = new[] { parent.Id }, StartIndex = query.StartIndex, Limit = query.Limit }); @@ -1078,7 +1078,7 @@ private QueryResult GetMusicArtists(BaseItem parent, User user, Inte { var artists = _libraryManager.GetArtists(new InternalItemsQuery(user) { - AncestorIds = new[] { parent.Id.ToString("N") }, + AncestorIds = new[] { parent.Id }, StartIndex = query.StartIndex, Limit = query.Limit }); @@ -1096,7 +1096,7 @@ private QueryResult GetFavoriteArtists(BaseItem parent, User user, I { var artists = _libraryManager.GetArtists(new InternalItemsQuery(user) { - AncestorIds = new[] { parent.Id.ToString("N") }, + AncestorIds = new[] { parent.Id }, StartIndex = query.StartIndex, Limit = query.Limit, IsFavorite = true @@ -1195,7 +1195,7 @@ private QueryResult GetMusicArtistItems(BaseItem item, Guid? parentI { Recursive = true, ParentId = parentId, - ArtistIds = new[] { item.Id.ToString("N") }, + ArtistIds = new[] { item.Id }, IncludeItemTypes = new[] { typeof(MusicAlbum).Name }, Limit = limit, StartIndex = startIndex, @@ -1215,7 +1215,7 @@ private QueryResult GetGenreItems(BaseItem item, Guid? parentId, Use { Recursive = true, ParentId = parentId, - GenreIds = new[] { item.Id.ToString("N") }, + GenreIds = new[] { item.Id }, IncludeItemTypes = new[] { typeof(Movie).Name, typeof(Series).Name }, Limit = limit, StartIndex = startIndex, @@ -1235,7 +1235,7 @@ private QueryResult GetMusicGenreItems(BaseItem item, Guid? parentId { Recursive = true, ParentId = parentId, - GenreIds = new[] { item.Id.ToString("N") }, + GenreIds = new[] { item.Id }, IncludeItemTypes = new[] { typeof(MusicAlbum).Name }, Limit = limit, StartIndex = startIndex, @@ -1291,7 +1291,7 @@ private QueryResult GetItemsFromPerson(Person person, User user, int { var itemsResult = _libraryManager.GetItemsResult(new InternalItemsQuery(user) { - PersonIds = new[] { person.Id.ToString("N") }, + PersonIds = new[] { person.Id }, IncludeItemTypes = new[] { typeof(Movie).Name, typeof(Series).Name, typeof(Trailer).Name }, OrderBy = new[] { ItemSortBy.SortName }.Select(i => new Tuple(i, SortOrder.Ascending)).ToArray(), Limit = limit, diff --git a/Emby.Dlna/Didl/DidlBuilder.cs b/Emby.Dlna/Didl/DidlBuilder.cs index 405a005afd..26ceeac4be 100644 --- a/Emby.Dlna/Didl/DidlBuilder.cs +++ b/Emby.Dlna/Didl/DidlBuilder.cs @@ -161,11 +161,11 @@ public void WriteItemElement(DlnaOptions options, { if (string.Equals(item.MediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase)) { - AddAudioResource(options, writer, hasMediaSources, deviceId, filter, streamInfo); + AddAudioResource(options, writer, item, deviceId, filter, streamInfo); } else if (string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase)) { - AddVideoResource(options, writer, hasMediaSources, deviceId, filter, streamInfo); + AddVideoResource(options, writer, item, deviceId, filter, streamInfo); } } @@ -196,7 +196,7 @@ private string GetMimeType(string input) return mime; } - private void AddVideoResource(DlnaOptions options, XmlWriter writer, IHasMediaSources video, string deviceId, Filter filter, StreamInfo streamInfo = null) + private void AddVideoResource(DlnaOptions options, XmlWriter writer, BaseItem video, string deviceId, Filter filter, StreamInfo streamInfo = null) { if (streamInfo == null) { @@ -303,7 +303,7 @@ private bool AddSubtitleElement(XmlWriter writer, SubtitleStreamInfo info) return true; } - private void AddVideoResource(XmlWriter writer, IHasMediaSources video, string deviceId, Filter filter, string contentFeatures, StreamInfo streamInfo) + private void AddVideoResource(XmlWriter writer, BaseItem video, string deviceId, Filter filter, string contentFeatures, StreamInfo streamInfo) { writer.WriteStartElement(string.Empty, "res", NS_DIDL); @@ -501,7 +501,7 @@ private string GetDisplayName(BaseItem item, StubType? itemStubType, BaseItem co return item.Name; } - private void AddAudioResource(DlnaOptions options, XmlWriter writer, IHasMediaSources audio, string deviceId, Filter filter, StreamInfo streamInfo = null) + private void AddAudioResource(DlnaOptions options, XmlWriter writer, BaseItem audio, string deviceId, Filter filter, StreamInfo streamInfo = null) { writer.WriteStartElement(string.Empty, "res", NS_DIDL); @@ -1183,7 +1183,7 @@ public static string GetClientId(Guid idValue, StubType? stubType) return id; } - public static string GetClientId(IHasMediaSources item) + public static string GetClientId(BaseItem item) { var id = item.Id.ToString("N"); diff --git a/Emby.Dlna/DlnaManager.cs b/Emby.Dlna/DlnaManager.cs index fc0f8b92d5..9c08fedcb0 100644 --- a/Emby.Dlna/DlnaManager.cs +++ b/Emby.Dlna/DlnaManager.cs @@ -595,7 +595,6 @@ private void DumpProfiles() public void Dispose() { - GC.SuppressFinalize(this); } } } \ No newline at end of file diff --git a/Emby.Dlna/Main/DlnaEntryPoint.cs b/Emby.Dlna/Main/DlnaEntryPoint.cs index 6f3f05996b..a68e8697dd 100644 --- a/Emby.Dlna/Main/DlnaEntryPoint.cs +++ b/Emby.Dlna/Main/DlnaEntryPoint.cs @@ -364,7 +364,6 @@ public void Dispose() _communicationsServer.Dispose(); _communicationsServer = null; } - GC.SuppressFinalize(this); } public void DisposeDevicePublisher() diff --git a/Emby.Dlna/PlayTo/Device.cs b/Emby.Dlna/PlayTo/Device.cs index edcd5d55e5..cd828e090a 100644 --- a/Emby.Dlna/PlayTo/Device.cs +++ b/Emby.Dlna/PlayTo/Device.cs @@ -1147,7 +1147,6 @@ public void Dispose() _disposed = true; DisposeTimer(); - GC.SuppressFinalize(this); } } diff --git a/Emby.Dlna/PlayTo/PlayToController.cs b/Emby.Dlna/PlayTo/PlayToController.cs index dbc0d63d1a..cd085705f1 100644 --- a/Emby.Dlna/PlayTo/PlayToController.cs +++ b/Emby.Dlna/PlayTo/PlayToController.cs @@ -465,7 +465,7 @@ private PlaylistItem CreatePlaylistItem(BaseItem item, User user, long startPost var hasMediaSources = item as IHasMediaSources; var mediaSources = hasMediaSources != null - ? (_mediaSourceManager.GetStaticMediaSources(hasMediaSources, true, user)) + ? (_mediaSourceManager.GetStaticMediaSources(item, true, user)) : new List(); var playlistItem = GetPlaylistItem(item, mediaSources, profile, _session.DeviceId, mediaSourceId, audioStreamIndex, subtitleStreamIndex); @@ -644,7 +644,6 @@ public void Dispose() _device.OnDeviceUnavailable = null; _device.Dispose(); - GC.SuppressFinalize(this); } } @@ -831,7 +830,7 @@ public async Task GetMediaSource(CancellationToken cancellation return null; } - MediaSource = await _mediaSourceManager.GetMediaSource(hasMediaSources, MediaSourceId, LiveStreamId, false, cancellationToken).ConfigureAwait(false); + MediaSource = await _mediaSourceManager.GetMediaSource(Item, MediaSourceId, LiveStreamId, false, cancellationToken).ConfigureAwait(false); return MediaSource; } diff --git a/Emby.Dlna/PlayTo/PlayToManager.cs b/Emby.Dlna/PlayTo/PlayToManager.cs index 1bfc086ac1..817a32ba47 100644 --- a/Emby.Dlna/PlayTo/PlayToManager.cs +++ b/Emby.Dlna/PlayTo/PlayToManager.cs @@ -258,7 +258,6 @@ public void Dispose() } _disposed = true; - GC.SuppressFinalize(this); } } } diff --git a/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs b/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs index 004e38facc..9a313d9d3f 100644 --- a/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs +++ b/Emby.Drawing.ImageMagick/ImageMagickEncoder.cs @@ -328,7 +328,6 @@ public void Dispose() { _disposed = true; Wand.CloseEnvironment(); - GC.SuppressFinalize(this); } private void CheckDisposed() diff --git a/Emby.Drawing.Skia/StripCollageBuilder.cs b/Emby.Drawing.Skia/StripCollageBuilder.cs index 10a4f24462..85eeaa9f59 100644 --- a/Emby.Drawing.Skia/StripCollageBuilder.cs +++ b/Emby.Drawing.Skia/StripCollageBuilder.cs @@ -83,7 +83,6 @@ private SKBitmap BuildThumbCollageBitmap(string[] paths, int width, int height) for (int i = 0; i < 4; i++) { - SKCodecOrigin origin; int newIndex; using (var currentBitmap = GetNextValidImage(paths, imageIndex, out newIndex)) @@ -108,7 +107,12 @@ private SKBitmap BuildThumbCollageBitmap(string[] paths, int width, int height) using (var subset = image.Subset(SKRectI.Create(ix, 0, iSlice, iHeight))) { // draw image onto canvas - canvas.DrawImage(subset, (horizontalImagePadding * (i + 1)) + (iSlice * i), verticalSpacing); + canvas.DrawImage(subset ?? image, (horizontalImagePadding * (i + 1)) + (iSlice * i), verticalSpacing); + + if (subset == null) + { + continue; + } using (var croppedBitmap = SKBitmap.FromImage(subset)) { diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 6b0d4fccc8..a5f55c91cc 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -912,8 +912,6 @@ public void Dispose() { disposable.Dispose(); } - - GC.SuppressFinalize(this); } private void CheckDisposed() diff --git a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs index 5405401fbc..c01f6670cc 100644 --- a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs +++ b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs @@ -491,7 +491,6 @@ public void Dispose() //_logManager.LoggerLoaded -= _logManager_LoggerLoaded; _appHost.ApplicationUpdated -= _appHost_ApplicationUpdated; - GC.SuppressFinalize(this); } /// diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 0686268964..8ca004e466 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -974,7 +974,7 @@ protected void RegisterResources() var deviceRepo = new SqliteDeviceRepository(LogManager.GetLogger("DeviceManager"), ServerConfigurationManager, FileSystemManager, JsonSerializer); deviceRepo.Initialize(); - DeviceManager = new DeviceManager(deviceRepo, UserManager, FileSystemManager, LibraryMonitor, ServerConfigurationManager, LogManager.GetLogger("DeviceManager"), NetworkManager); + DeviceManager = new DeviceManager(deviceRepo, LibraryManager, LocalizationManager, UserManager, FileSystemManager, LibraryMonitor, ServerConfigurationManager, LogManager.GetLogger("DeviceManager"), NetworkManager); RegisterSingleInstance(deviceRepo); RegisterSingleInstance(DeviceManager); @@ -996,7 +996,7 @@ protected void RegisterResources() var connectionManager = new ConnectionManager(dlnaManager, ServerConfigurationManager, LogManager.GetLogger("UpnpConnectionManager"), HttpClient, new XmlReaderSettingsFactory()); RegisterSingleInstance(connectionManager); - CollectionManager = new CollectionManager(LibraryManager, FileSystemManager, LibraryMonitor, LogManager.GetLogger("CollectionManager"), ProviderManager); + CollectionManager = new CollectionManager(LibraryManager, ApplicationPaths, LocalizationManager, FileSystemManager, LibraryMonitor, LogManager.GetLogger("CollectionManager"), ProviderManager); RegisterSingleInstance(CollectionManager); PlaylistManager = new PlaylistManager(LibraryManager, FileSystemManager, LibraryMonitor, LogManager.GetLogger("PlaylistManager"), UserManager, ProviderManager); @@ -2379,7 +2379,6 @@ public void Dispose() _disposed = true; Dispose(true); - GC.SuppressFinalize(this); } } diff --git a/Emby.Server.Implementations/Channels/ChannelDynamicMediaSourceProvider.cs b/Emby.Server.Implementations/Channels/ChannelDynamicMediaSourceProvider.cs index 67932558f1..dd206ac88f 100644 --- a/Emby.Server.Implementations/Channels/ChannelDynamicMediaSourceProvider.cs +++ b/Emby.Server.Implementations/Channels/ChannelDynamicMediaSourceProvider.cs @@ -18,13 +18,11 @@ public ChannelDynamicMediaSourceProvider(IChannelManager channelManager) _channelManager = (ChannelManager)channelManager; } - public Task> GetMediaSources(IHasMediaSources item, CancellationToken cancellationToken) + public Task> GetMediaSources(BaseItem item, CancellationToken cancellationToken) { - var baseItem = (BaseItem)item; - - if (baseItem.SourceType == SourceType.Channel) + if (item.SourceType == SourceType.Channel) { - return _channelManager.GetDynamicMediaSources(baseItem, cancellationToken); + return _channelManager.GetDynamicMediaSources(item, cancellationToken); } return Task.FromResult>(new List()); diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index f2e5a0d41a..4bf37ec019 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -313,7 +313,7 @@ public async Task RefreshChannels(IProgress progress, CancellationToken private Channel GetChannelEntity(IChannel channel) { - var item = GetChannel(GetInternalChannelId(channel.Name).ToString("N")); + var item = GetChannel(GetInternalChannelId(channel.Name)); if (item == null) { @@ -510,6 +510,11 @@ private string GetOfficialRating(ChannelParentalRating rating) } } + public Channel GetChannel(Guid id) + { + return _libraryManager.GetItemById(id) as Channel; + } + public Channel GetChannel(string id) { return _libraryManager.GetItemById(id) as Channel; @@ -610,7 +615,7 @@ public async Task> GetLatestChannelItemsInternal(InternalI // Avoid implicitly captured closure var ids = query.ChannelIds; channels = channels - .Where(i => ids.Contains(GetInternalChannelId(i.Name).ToString("N"))) + .Where(i => ids.Contains(GetInternalChannelId(i.Name))) .ToArray(); } @@ -656,7 +661,7 @@ private async Task RefreshLatestChannelItems(IChannel channel, CancellationToken var query = new InternalItemsQuery(); query.Parent = internalChannel; query.EnableTotalRecordCount = false; - query.ChannelIds = new string[] { internalChannel.Id.ToString("N") }; + query.ChannelIds = new Guid[] { internalChannel.Id }; var result = await GetChannelItemsInternal(query, new SimpleProgress(), cancellationToken).ConfigureAwait(false); @@ -670,7 +675,7 @@ await GetChannelItemsInternal(new InternalItemsQuery { Parent = folder, EnableTotalRecordCount = false, - ChannelIds = new string[] { internalChannel.Id.ToString("N") } + ChannelIds = new Guid[] { internalChannel.Id } }, new SimpleProgress(), cancellationToken).ConfigureAwait(false); } @@ -704,7 +709,7 @@ public async Task> GetChannelItemsInternal(InternalItemsQu { query.Parent = channel; } - query.ChannelIds = new string[] { }; + query.ChannelIds = new Guid[] { }; // Not yet sure why this is causing a problem query.GroupByPresentationUniqueKey = false; diff --git a/Emby.Server.Implementations/Channels/ChannelPostScanTask.cs b/Emby.Server.Implementations/Channels/ChannelPostScanTask.cs index d012d17fe3..a1fd2901b3 100644 --- a/Emby.Server.Implementations/Channels/ChannelPostScanTask.cs +++ b/Emby.Server.Implementations/Channels/ChannelPostScanTask.cs @@ -69,7 +69,7 @@ private void CleanChannel(Guid id, CancellationToken cancellationToken) // Delete all channel items var allIds = _libraryManager.GetItemIds(new InternalItemsQuery { - ChannelIds = new[] { id.ToString("N") } + ChannelIds = new[] { id } }); foreach (var deleteId in allIds) diff --git a/Emby.Server.Implementations/Collections/CollectionManager.cs b/Emby.Server.Implementations/Collections/CollectionManager.cs index 2ef4c6fdc9..c874572b40 100644 --- a/Emby.Server.Implementations/Collections/CollectionManager.cs +++ b/Emby.Server.Implementations/Collections/CollectionManager.cs @@ -13,6 +13,12 @@ using System.Threading.Tasks; using MediaBrowser.Model.IO; using MediaBrowser.Model.Extensions; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Controller.Configuration; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Configuration; +using MediaBrowser.Controller.Plugins; +using MediaBrowser.Model.Globalization; namespace Emby.Server.Implementations.Collections { @@ -23,30 +29,74 @@ public class CollectionManager : ICollectionManager private readonly ILibraryMonitor _iLibraryMonitor; private readonly ILogger _logger; private readonly IProviderManager _providerManager; + private readonly ILocalizationManager _localizationManager; + private IApplicationPaths _appPaths; public event EventHandler CollectionCreated; public event EventHandler ItemsAddedToCollection; public event EventHandler ItemsRemovedFromCollection; - public CollectionManager(ILibraryManager libraryManager, IFileSystem fileSystem, ILibraryMonitor iLibraryMonitor, ILogger logger, IProviderManager providerManager) + public CollectionManager(ILibraryManager libraryManager, IApplicationPaths appPaths, ILocalizationManager localizationManager, IFileSystem fileSystem, ILibraryMonitor iLibraryMonitor, ILogger logger, IProviderManager providerManager) { _libraryManager = libraryManager; _fileSystem = fileSystem; _iLibraryMonitor = iLibraryMonitor; _logger = logger; _providerManager = providerManager; + _localizationManager = localizationManager; + _appPaths = appPaths; } - public Folder GetCollectionsFolder(string userId) + private IEnumerable FindFolders(string path) { - return _libraryManager.RootFolder.Children.OfType() - .FirstOrDefault() ?? _libraryManager.GetUserRootFolder().Children.OfType() - .FirstOrDefault(); + return _libraryManager + .RootFolder + .Children + .OfType() + .Where(i => _fileSystem.AreEqual(path, i.Path) || _fileSystem.ContainsSubPath(i.Path, path)); } - public IEnumerable GetCollections(User user) + internal async Task EnsureLibraryFolder(string path, string name) { - var folder = GetCollectionsFolder(user.Id.ToString("N")); + var existingFolders = FindFolders(path) + .ToList(); + + if (existingFolders.Count > 0) + { + return existingFolders[0]; + } + + var libraryOptions = new LibraryOptions + { + PathInfos = new[] { new MediaPathInfo { Path = path } }, + EnableRealtimeMonitor = false, + SaveLocalMetadata = true + }; + + if (string.IsNullOrWhiteSpace(name)) + { + name = _localizationManager.GetLocalizedString("Collections"); + } + + await _libraryManager.AddVirtualFolder(name, CollectionType.BoxSets, libraryOptions, true).ConfigureAwait(false); + + return FindFolders(path).First(); + } + + internal string GetCollectionsFolderPath() + { + return Path.Combine(_appPaths.DataPath, "collections"); + } + + private Task GetCollectionsFolder(bool createIfNeeded) + { + return EnsureLibraryFolder(GetCollectionsFolderPath(), null); + } + + private IEnumerable GetCollections(User user) + { + var folder = GetCollectionsFolder(false).Result; + return folder == null ? new List() : folder.GetChildren(user, true).OfType(); @@ -61,7 +111,7 @@ public BoxSet CreateCollection(CollectionCreationOptions options) // This could cause it to get re-resolved as a plain folder var folderName = _fileSystem.GetValidFilename(name) + " [boxset]"; - var parentFolder = GetParentFolder(options.ParentId); + var parentFolder = GetCollectionsFolder(true).Result; if (parentFolder == null) { @@ -82,12 +132,6 @@ public BoxSet CreateCollection(CollectionCreationOptions options) Path = path, IsLocked = options.IsLocked, ProviderIds = options.ProviderIds, - Shares = options.UserIds.Select(i => new Share - { - UserId = i, - CanEdit = true - - }).ToList(), DateCreated = DateTime.UtcNow }; @@ -123,33 +167,6 @@ public BoxSet CreateCollection(CollectionCreationOptions options) } } - private Folder GetParentFolder(Guid? parentId) - { - if (parentId.HasValue) - { - if (parentId.Value == Guid.Empty) - { - throw new ArgumentNullException("parentId"); - } - - var folder = _libraryManager.GetItemById(parentId.Value) as Folder; - - // Find an actual physical folder - if (folder is CollectionFolder) - { - var child = _libraryManager.RootFolder.Children.OfType() - .FirstOrDefault(i => folder.PhysicalLocations.Contains(i.Path, StringComparer.OrdinalIgnoreCase)); - - if (child != null) - { - return child; - } - } - } - - return GetCollectionsFolder(string.Empty); - } - public void AddToCollection(Guid collectionId, IEnumerable ids) { AddToCollection(collectionId, ids, true, new MetadataRefreshOptions(_fileSystem)); @@ -314,4 +331,78 @@ public IEnumerable CollapseItemsWithinBoxSets(IEnumerable it return results.Values; } } + + public class CollectionManagerEntryPoint : IServerEntryPoint + { + private readonly CollectionManager _collectionManager; + private readonly IServerConfigurationManager _config; + private readonly IFileSystem _fileSystem; + private ILogger _logger; + + public CollectionManagerEntryPoint(ICollectionManager collectionManager, IServerConfigurationManager config, IFileSystem fileSystem, ILogger logger) + { + _collectionManager = (CollectionManager)collectionManager; + _config = config; + _fileSystem = fileSystem; + _logger = logger; + } + + public async void Run() + { + if (!_config.Configuration.CollectionsUpgraded && _config.Configuration.IsStartupWizardCompleted) + { + var path = _collectionManager.GetCollectionsFolderPath(); + + if (_fileSystem.DirectoryExists(path)) + { + try + { + await _collectionManager.EnsureLibraryFolder(path, null).ConfigureAwait(false); + } + catch (Exception ex) + { + _logger.ErrorException("Error creating camera uploads library", ex); + } + + _config.Configuration.CollectionsUpgraded = true; + _config.SaveConfiguration(); + } + } + } + + #region IDisposable Support + private bool disposedValue = false; // To detect redundant calls + + protected virtual void Dispose(bool disposing) + { + if (!disposedValue) + { + if (disposing) + { + // TODO: dispose managed state (managed objects). + } + + // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. + // TODO: set large fields to null. + + disposedValue = true; + } + } + + // TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources. + // ~CollectionManagerEntryPoint() { + // // Do not change this code. Put cleanup code in Dispose(bool disposing) above. + // Dispose(false); + // } + + // This code added to correctly implement the disposable pattern. + public void Dispose() + { + // Do not change this code. Put cleanup code in Dispose(bool disposing) above. + Dispose(true); + // TODO: uncomment the following line if the finalizer is overridden above. + // GC.SuppressFinalize(this); + } + #endregion + } } diff --git a/Emby.Server.Implementations/Collections/CollectionsDynamicFolder.cs b/Emby.Server.Implementations/Collections/CollectionsDynamicFolder.cs deleted file mode 100644 index c7bcdfe256..0000000000 --- a/Emby.Server.Implementations/Collections/CollectionsDynamicFolder.cs +++ /dev/null @@ -1,34 +0,0 @@ -using MediaBrowser.Common.Configuration; -using MediaBrowser.Controller.Entities; -using System.IO; - -using MediaBrowser.Model.IO; -using MediaBrowser.Controller.Collections; -using MediaBrowser.Controller.IO; - -namespace Emby.Server.Implementations.Collections -{ - public class CollectionsDynamicFolder : IVirtualFolderCreator - { - private readonly IApplicationPaths _appPaths; - private readonly IFileSystem _fileSystem; - - public CollectionsDynamicFolder(IApplicationPaths appPaths, IFileSystem fileSystem) - { - _appPaths = appPaths; - _fileSystem = fileSystem; - } - - public BasePluginFolder GetFolder() - { - var path = Path.Combine(_appPaths.DataPath, "collections"); - - _fileSystem.CreateDirectory(path); - - return new ManualCollectionsFolder - { - Path = path - }; - } - } -} diff --git a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs index e73a69892c..c664b85fbf 100644 --- a/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs +++ b/Emby.Server.Implementations/Configuration/ServerConfigurationManager.cs @@ -237,6 +237,18 @@ public bool SetOptimalValues() changed = true; } + if (!config.CameraUploadUpgraded) + { + config.CameraUploadUpgraded = true; + changed = true; + } + + if (!config.CollectionsUpgraded) + { + config.CollectionsUpgraded = true; + changed = true; + } + return changed; } } diff --git a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs b/Emby.Server.Implementations/Data/BaseSqliteRepository.cs index d207c8d4f7..3dede98280 100644 --- a/Emby.Server.Implementations/Data/BaseSqliteRepository.cs +++ b/Emby.Server.Implementations/Data/BaseSqliteRepository.cs @@ -264,7 +264,6 @@ public void Dispose() { _disposed = true; Dispose(true); - GC.SuppressFinalize(this); } private readonly object _disposeLock = new object(); diff --git a/Emby.Server.Implementations/Data/ManagedConnection.cs b/Emby.Server.Implementations/Data/ManagedConnection.cs index 5d0fc8ebc7..91a2dfdf62 100644 --- a/Emby.Server.Implementations/Data/ManagedConnection.cs +++ b/Emby.Server.Implementations/Data/ManagedConnection.cs @@ -77,7 +77,6 @@ public void Dispose() { Close(); } - GC.SuppressFinalize(this); } } } diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 7dc9e07e36..8afa286f5d 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -1320,15 +1320,6 @@ private bool TypeRequiresDeserialization(Type type) { return false; } - - if (type == typeof(ManualCollectionsFolder)) - { - return false; - } - if (type == typeof(CameraUploadsFolder)) - { - return false; - } if (type == typeof(PlaylistsFolder)) { return false; @@ -2594,14 +2585,14 @@ private string[] GetFinalColumnsToSelect(InternalItemsQuery query, string[] star list.Add(builder.ToString()); var excludeIds = query.ExcludeItemIds.ToList(); - excludeIds.Add(item.Id.ToString("N")); + excludeIds.Add(item.Id); if (query.IncludeItemTypes.Length == 0 || query.IncludeItemTypes.Contains(typeof(Trailer).Name)) { var hasTrailers = item as IHasTrailers; if (hasTrailers != null) { - excludeIds.AddRange(hasTrailers.GetTrailerIds().Select(i => i.ToString("N"))); + excludeIds.AddRange(hasTrailers.GetTrailerIds()); } } @@ -3701,12 +3692,12 @@ private List GetWhereClauses(InternalItemsQuery query, IStatement statem whereClauses.Add("ChannelId=@ChannelId"); if (statement != null) { - statement.TryBind("@ChannelId", query.ChannelIds[0]); + statement.TryBind("@ChannelId", query.ChannelIds[0].ToString("N")); } } else if (query.ChannelIds.Length > 1) { - var inClause = string.Join(",", query.ChannelIds.Where(IsValidId).Select(i => "'" + i + "'").ToArray()); + var inClause = string.Join(",", query.ChannelIds.Select(i => "'" + i.ToString("N") + "'").ToArray()); whereClauses.Add(string.Format("ChannelId in ({0})", inClause)); } @@ -4436,7 +4427,7 @@ private List GetWhereClauses(InternalItemsQuery query, IStatement statem includeIds.Add("Guid = @IncludeId" + index); if (statement != null) { - statement.TryBind("@IncludeId" + index, new Guid(id)); + statement.TryBind("@IncludeId" + index, id); } index++; } @@ -4453,7 +4444,7 @@ private List GetWhereClauses(InternalItemsQuery query, IStatement statem excludeIds.Add("Guid <> @ExcludeId" + index); if (statement != null) { - statement.TryBind("@ExcludeId" + index, new Guid(id)); + statement.TryBind("@ExcludeId" + index, id); } index++; } @@ -4528,7 +4519,7 @@ private List GetWhereClauses(InternalItemsQuery query, IStatement statem var includedItemByNameTypes = GetItemByNameTypesInQuery(query).SelectMany(MapIncludeItemTypes).ToList(); var enableItemsByName = (query.IncludeItemsByName ?? false) && includedItemByNameTypes.Count > 0; - var queryTopParentIds = query.TopParentIds.Where(IsValidId).ToArray(); + var queryTopParentIds = query.TopParentIds; if (queryTopParentIds.Length == 1) { @@ -4551,12 +4542,12 @@ private List GetWhereClauses(InternalItemsQuery query, IStatement statem } if (statement != null) { - statement.TryBind("@TopParentId", queryTopParentIds[0]); + statement.TryBind("@TopParentId", queryTopParentIds[0].ToString("N")); } } else if (queryTopParentIds.Length > 1) { - var val = string.Join(",", queryTopParentIds.Select(i => "'" + i + "'").ToArray()); + var val = string.Join(",", queryTopParentIds.Select(i => "'" + i.ToString("N") + "'").ToArray()); if (enableItemsByName && includedItemByNameTypes.Count == 1) { @@ -4583,12 +4574,12 @@ private List GetWhereClauses(InternalItemsQuery query, IStatement statem if (statement != null) { - statement.TryBind("@AncestorId", new Guid(query.AncestorIds[0])); + statement.TryBind("@AncestorId", query.AncestorIds[0]); } } if (query.AncestorIds.Length > 1) { - var inClause = string.Join(",", query.AncestorIds.Select(i => "'" + new Guid(i).ToString("N") + "'").ToArray()); + var inClause = string.Join(",", query.AncestorIds.Select(i => "'" + i.ToString("N") + "'").ToArray()); whereClauses.Add(string.Format("Guid in (select itemId from AncestorIds where AncestorIdText in ({0}))", inClause)); } if (!string.IsNullOrWhiteSpace(query.AncestorWithPresentationUniqueKey)) diff --git a/Emby.Server.Implementations/Devices/CameraUploadsDynamicFolder.cs b/Emby.Server.Implementations/Devices/CameraUploadsDynamicFolder.cs deleted file mode 100644 index bb9ef157c4..0000000000 --- a/Emby.Server.Implementations/Devices/CameraUploadsDynamicFolder.cs +++ /dev/null @@ -1,40 +0,0 @@ -using MediaBrowser.Common.Configuration; -using MediaBrowser.Controller.Entities; -using System; -using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -using MediaBrowser.Controller.IO; -using MediaBrowser.Model.IO; -using MediaBrowser.Controller.Providers; -using MediaBrowser.Model.Serialization; - -namespace Emby.Server.Implementations.Devices -{ - public class CameraUploadsDynamicFolder : IVirtualFolderCreator - { - private readonly IApplicationPaths _appPaths; - private readonly IFileSystem _fileSystem; - - public CameraUploadsDynamicFolder(IApplicationPaths appPaths, IFileSystem fileSystem) - { - _appPaths = appPaths; - _fileSystem = fileSystem; - } - - public BasePluginFolder GetFolder() - { - var path = Path.Combine(_appPaths.DataPath, "camerauploads"); - - _fileSystem.CreateDirectory(path); - - return new CameraUploadsFolder - { - Path = path - }; - } - } - -} diff --git a/Emby.Server.Implementations/Devices/CameraUploadsFolder.cs b/Emby.Server.Implementations/Devices/CameraUploadsFolder.cs deleted file mode 100644 index 5c205dd199..0000000000 --- a/Emby.Server.Implementations/Devices/CameraUploadsFolder.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Providers; -using MediaBrowser.Model.Serialization; - -namespace Emby.Server.Implementations.Devices -{ - public class CameraUploadsFolder : BasePluginFolder, ISupportsUserSpecificView - { - public CameraUploadsFolder() - { - Name = "Camera Uploads"; - } - - public override bool IsVisible(User user) - { - if (!user.Policy.EnableAllFolders && !user.Policy.EnabledFolders.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase)) - { - return false; - } - - return base.IsVisible(user) && HasChildren(); - } - - [IgnoreDataMember] - public override string CollectionType - { - get { return MediaBrowser.Model.Entities.CollectionType.HomeVideos; } - } - - [IgnoreDataMember] - public override bool SupportsInheritedParentImages - { - get - { - return false; - } - } - - public override string GetClientTypeName() - { - return typeof(CollectionFolder).Name; - } - - private bool? _hasChildren; - private bool HasChildren() - { - if (!_hasChildren.HasValue) - { - _hasChildren = LibraryManager.GetItemIds(new InternalItemsQuery { Parent = this }).Count > 0; - } - - return _hasChildren.Value; - } - - protected override Task ValidateChildrenInternal(IProgress progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService) - { - _hasChildren = null; - return base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService); - } - - [IgnoreDataMember] - public bool EnableUserSpecificView - { - get { return true; } - } - } -} diff --git a/Emby.Server.Implementations/Devices/DeviceManager.cs b/Emby.Server.Implementations/Devices/DeviceManager.cs index 5ada82f8a1..ae3d98a27c 100644 --- a/Emby.Server.Implementations/Devices/DeviceManager.cs +++ b/Emby.Server.Implementations/Devices/DeviceManager.cs @@ -19,6 +19,10 @@ using MediaBrowser.Model.IO; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Configuration; +using MediaBrowser.Controller.Plugins; +using MediaBrowser.Model.Globalization; namespace Emby.Server.Implementations.Devices { @@ -31,6 +35,8 @@ public class DeviceManager : IDeviceManager private readonly IServerConfigurationManager _config; private readonly ILogger _logger; private readonly INetworkManager _network; + private readonly ILibraryManager _libraryManager; + private readonly ILocalizationManager _localizationManager; public event EventHandler> CameraImageUploaded; @@ -39,7 +45,7 @@ public class DeviceManager : IDeviceManager /// public event EventHandler> DeviceOptionsUpdated; - public DeviceManager(IDeviceRepository repo, IUserManager userManager, IFileSystem fileSystem, ILibraryMonitor libraryMonitor, IServerConfigurationManager config, ILogger logger, INetworkManager network) + public DeviceManager(IDeviceRepository repo, ILibraryManager libraryManager, ILocalizationManager localizationManager, IUserManager userManager, IFileSystem fileSystem, ILibraryMonitor libraryMonitor, IServerConfigurationManager config, ILogger logger, INetworkManager network) { _repo = repo; _userManager = userManager; @@ -48,6 +54,8 @@ public DeviceManager(IDeviceRepository repo, IUserManager userManager, IFileSyst _config = config; _logger = logger; _network = network; + _libraryManager = libraryManager; + _localizationManager = localizationManager; } public DeviceInfo RegisterDevice(string reportedId, string name, string appName, string appVersion, string usedByUserId, string usedByUserName) @@ -177,7 +185,9 @@ public ContentUploadHistory GetCameraUploadHistory(string deviceId) public async Task AcceptCameraUpload(string deviceId, Stream stream, LocalFileInfo file) { var device = GetDevice(deviceId); - var path = GetUploadPath(device); + var uploadPathInfo = GetUploadPath(device); + + var path = uploadPathInfo.Item1; if (!string.IsNullOrWhiteSpace(file.Album)) { @@ -187,10 +197,12 @@ public async Task AcceptCameraUpload(string deviceId, Stream stream, LocalFileIn path = Path.Combine(path, file.Name); path = Path.ChangeExtension(path, MimeTypes.ToExtension(file.MimeType) ?? "jpg"); - _libraryMonitor.ReportFileSystemChangeBeginning(path); - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(path)); + await EnsureLibraryFolder(uploadPathInfo.Item2, uploadPathInfo.Item3).ConfigureAwait(false); + + _libraryMonitor.ReportFileSystemChangeBeginning(path); + try { using (var fs = _fileSystem.GetFileStream(path, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read)) @@ -218,25 +230,71 @@ public async Task AcceptCameraUpload(string deviceId, Stream stream, LocalFileIn } } - private string GetUploadPath(DeviceInfo device) + internal Task EnsureLibraryFolder(string path, string name) + { + var existingFolders = _libraryManager + .RootFolder + .Children + .OfType() + .Where(i => _fileSystem.AreEqual(path, i.Path) || _fileSystem.ContainsSubPath(i.Path, path)) + .ToList(); + + if (existingFolders.Count > 0) + { + return Task.CompletedTask; + } + + var libraryOptions = new LibraryOptions + { + PathInfos = new[] { new MediaPathInfo { Path = path } }, + EnablePhotos = true, + EnableRealtimeMonitor = false, + SaveLocalMetadata = true + }; + + if (string.IsNullOrWhiteSpace(name)) + { + name = _localizationManager.GetLocalizedString("HeaderCameraUploads"); + } + + return _libraryManager.AddVirtualFolder(name, CollectionType.HomeVideos, libraryOptions, true); + } + + private Tuple GetUploadPath(DeviceInfo device) { if (!string.IsNullOrWhiteSpace(device.CameraUploadPath)) { - return device.CameraUploadPath; + return new Tuple(device.CameraUploadPath, device.CameraUploadPath, _fileSystem.GetDirectoryName(device.CameraUploadPath)); } var config = _config.GetUploadOptions(); var path = config.CameraUploadPath; + if (string.IsNullOrWhiteSpace(path)) { path = DefaultCameraUploadsPath; } + var topLibraryPath = path; + if (config.EnableCameraUploadSubfolders) { path = Path.Combine(path, _fileSystem.GetValidFilename(device.Name)); } + return new Tuple(path, topLibraryPath, null); + } + + internal string GetUploadsPath() + { + var config = _config.GetUploadOptions(); + var path = config.CameraUploadPath; + + if (string.IsNullOrWhiteSpace(path)) + { + path = DefaultCameraUploadsPath; + } + return path; } @@ -299,6 +357,80 @@ private bool CanAccessDevice(UserPolicy policy, string id) } } + public class DeviceManagerEntryPoint : IServerEntryPoint + { + private readonly DeviceManager _deviceManager; + private readonly IServerConfigurationManager _config; + private readonly IFileSystem _fileSystem; + private ILogger _logger; + + public DeviceManagerEntryPoint(IDeviceManager deviceManager, IServerConfigurationManager config, IFileSystem fileSystem, ILogger logger) + { + _deviceManager = (DeviceManager)deviceManager; + _config = config; + _fileSystem = fileSystem; + _logger = logger; + } + + public async void Run() + { + if (!_config.Configuration.CameraUploadUpgraded && _config.Configuration.IsStartupWizardCompleted) + { + var path = _deviceManager.GetUploadsPath(); + + if (_fileSystem.DirectoryExists(path)) + { + try + { + await _deviceManager.EnsureLibraryFolder(path, null).ConfigureAwait(false); + } + catch (Exception ex) + { + _logger.ErrorException("Error creating camera uploads library", ex); + } + + _config.Configuration.CameraUploadUpgraded = true; + _config.SaveConfiguration(); + } + } + } + + #region IDisposable Support + private bool disposedValue = false; // To detect redundant calls + + protected virtual void Dispose(bool disposing) + { + if (!disposedValue) + { + if (disposing) + { + // TODO: dispose managed state (managed objects). + } + + // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. + // TODO: set large fields to null. + + disposedValue = true; + } + } + + // TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources. + // ~DeviceManagerEntryPoint() { + // // Do not change this code. Put cleanup code in Dispose(bool disposing) above. + // Dispose(false); + // } + + // This code added to correctly implement the disposable pattern. + public void Dispose() + { + // Do not change this code. Put cleanup code in Dispose(bool disposing) above. + Dispose(true); + // TODO: uncomment the following line if the finalizer is overridden above. + // GC.SuppressFinalize(this); + } + #endregion + } + public class DevicesConfigStore : IConfigurationFactory { public IEnumerable GetConfigurations() diff --git a/Emby.Server.Implementations/Diagnostics/CommonProcess.cs b/Emby.Server.Implementations/Diagnostics/CommonProcess.cs index a0a5f32ef6..09b8bf22cd 100644 --- a/Emby.Server.Implementations/Diagnostics/CommonProcess.cs +++ b/Emby.Server.Implementations/Diagnostics/CommonProcess.cs @@ -104,7 +104,6 @@ public Task WaitForExitAsync(int timeMs) public void Dispose() { _process.Dispose(); - GC.SuppressFinalize(this); } } } diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index d647aa3b8b..d0117b0207 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -23,9 +23,8 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Threading; using System.Threading.Tasks; - -using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; using MediaBrowser.Model.Extensions; @@ -361,14 +360,7 @@ private BaseItemDto GetBaseItemDtoInternal(BaseItem item, DtoOptions options, Li { if (fields.Contains(ItemFields.MediaSources)) { - if (user == null) - { - dto.MediaSources = _mediaSourceManager().GetStaticMediaSources(hasMediaSources, true); - } - else - { - dto.MediaSources = _mediaSourceManager().GetStaticMediaSources(hasMediaSources, true, user); - } + dto.MediaSources = _mediaSourceManager().GetStaticMediaSources(item, true, user); NormalizeMediaSourceContainers(dto); } @@ -1308,7 +1300,7 @@ private void AttachBasicFields(BaseItemDto dto, BaseItem item, BaseItem owner, D } else { - mediaStreams = _mediaSourceManager().GetStaticMediaSources(iHasMediaSources, true).First().MediaStreams.ToArray(); + mediaStreams = _mediaSourceManager().GetStaticMediaSources(item, true).First().MediaStreams.ToArray(); } dto.MediaStreams = mediaStreams; diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 002f1cef08..5f495f847b 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -53,7 +53,6 @@ - @@ -62,8 +61,6 @@ - - @@ -388,7 +385,6 @@ - diff --git a/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs b/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs index c2cee00c80..561f5ee12e 100644 --- a/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs +++ b/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs @@ -112,7 +112,6 @@ public void Dispose() _appHost.HasPendingRestartChanged -= _appHost_HasPendingRestartChanged; DisposeTimer(); - GC.SuppressFinalize(this); } private void DisposeTimer() diff --git a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs index 044552d71e..cccb9f0b3b 100644 --- a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs +++ b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs @@ -288,7 +288,6 @@ public void Dispose() { _disposed = true; DisposeNat(); - GC.SuppressFinalize(this); } private void DisposeNat() diff --git a/Emby.Server.Implementations/EntryPoints/KeepServerAwake.cs b/Emby.Server.Implementations/EntryPoints/KeepServerAwake.cs index 221580681a..8ae85e3909 100644 --- a/Emby.Server.Implementations/EntryPoints/KeepServerAwake.cs +++ b/Emby.Server.Implementations/EntryPoints/KeepServerAwake.cs @@ -60,7 +60,6 @@ public void Dispose() _timer.Dispose(); _timer = null; } - GC.SuppressFinalize(this); } } } diff --git a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs index 28f00e9a9f..cb2ca621a0 100644 --- a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs @@ -453,7 +453,6 @@ private IEnumerable TranslatePhysicalItemToUserLibrary(T item, User user, public void Dispose() { Dispose(true); - GC.SuppressFinalize(this); } /// diff --git a/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs b/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs index 543bccd0bf..34d66bad1a 100644 --- a/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/RecordingNotifier.cs @@ -76,7 +76,6 @@ public void Dispose() _liveTvManager.SeriesTimerCancelled -= _liveTvManager_SeriesTimerCancelled; _liveTvManager.TimerCreated -= _liveTvManager_TimerCreated; _liveTvManager.SeriesTimerCreated -= _liveTvManager_SeriesTimerCreated; - GC.SuppressFinalize(this); } } } diff --git a/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs b/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs index 1743b7d4c8..1c4fa4b070 100644 --- a/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/ServerEventNotifier.cs @@ -179,7 +179,6 @@ private async void SendMessageToUserSession(User user, string name, T data) public void Dispose() { Dispose(true); - GC.SuppressFinalize(this); } /// diff --git a/Emby.Server.Implementations/EntryPoints/StartupWizard.cs b/Emby.Server.Implementations/EntryPoints/StartupWizard.cs index 103b4b321e..f68ecfb611 100644 --- a/Emby.Server.Implementations/EntryPoints/StartupWizard.cs +++ b/Emby.Server.Implementations/EntryPoints/StartupWizard.cs @@ -60,7 +60,6 @@ public void Run() /// public void Dispose() { - GC.SuppressFinalize(this); } } } \ No newline at end of file diff --git a/Emby.Server.Implementations/EntryPoints/SystemEvents.cs b/Emby.Server.Implementations/EntryPoints/SystemEvents.cs index 08f3edb3d5..e27de89673 100644 --- a/Emby.Server.Implementations/EntryPoints/SystemEvents.cs +++ b/Emby.Server.Implementations/EntryPoints/SystemEvents.cs @@ -34,7 +34,6 @@ private void _systemEvents_SystemShutdown(object sender, EventArgs e) public void Dispose() { _systemEvents.SystemShutdown -= _systemEvents_SystemShutdown; - GC.SuppressFinalize(this); } } } diff --git a/Emby.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs b/Emby.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs index d04df0d2b2..df5a7c985d 100644 --- a/Emby.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs +++ b/Emby.Server.Implementations/EntryPoints/UdpServerEntryPoint.cs @@ -65,7 +65,6 @@ public void Run() public void Dispose() { Dispose(true); - GC.SuppressFinalize(this); } /// diff --git a/Emby.Server.Implementations/EntryPoints/UsageEntryPoint.cs b/Emby.Server.Implementations/EntryPoints/UsageEntryPoint.cs index 3ce86de2ee..7d93f7495e 100644 --- a/Emby.Server.Implementations/EntryPoints/UsageEntryPoint.cs +++ b/Emby.Server.Implementations/EntryPoints/UsageEntryPoint.cs @@ -126,7 +126,6 @@ private async void OnTimerFired() public void Dispose() { _sessionManager.SessionStarted -= _sessionManager_SessionStarted; - GC.SuppressFinalize(this); } } } diff --git a/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs b/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs index 59c91174fb..7544c8179f 100644 --- a/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs +++ b/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs @@ -153,7 +153,6 @@ public void Dispose() } _userDataManager.UserDataSaved -= _userDataManager_UserDataSaved; - GC.SuppressFinalize(this); } } } diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs index 5cb6a8adb5..ef5b0ea1df 100644 --- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -896,7 +896,6 @@ protected virtual void Dispose(bool disposing) public void Dispose() { Dispose(true); - GC.SuppressFinalize(this); } public void StartServer(string[] urlPrefixes) diff --git a/Emby.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs b/Emby.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs index 71fee312d1..9928d8ba8a 100644 --- a/Emby.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs +++ b/Emby.Server.Implementations/HttpServer/SocketSharp/SharpWebSocket.cs @@ -123,7 +123,6 @@ public Task SendAsync(string text, bool endOfMessage, CancellationToken cancella public void Dispose() { Dispose(true); - GC.SuppressFinalize(this); } /// diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 505b08d3df..34b3fef4ba 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -1057,34 +1057,32 @@ public async Task ValidateMediaLibraryInternal(IProgress progress, Cance } } - private async Task PerformLibraryValidation(IProgress progress, CancellationToken cancellationToken) + private async Task ValidateTopLibraryFolders(CancellationToken cancellationToken) { - _logger.Info("Validating media library"); - - // Ensure these objects are lazy loaded. - // Without this there is a deadlock that will need to be investigated var rootChildren = RootFolder.Children.ToList(); rootChildren = GetUserRootFolder().Children.ToList(); await RootFolder.RefreshMetadata(cancellationToken).ConfigureAwait(false); - progress.Report(.5); - // Start by just validating the children of the root, but go no further await RootFolder.ValidateChildren(new SimpleProgress(), cancellationToken, new MetadataRefreshOptions(_fileSystem), recursive: false); - progress.Report(1); - await GetUserRootFolder().RefreshMetadata(cancellationToken).ConfigureAwait(false); await GetUserRootFolder().ValidateChildren(new SimpleProgress(), cancellationToken, new MetadataRefreshOptions(_fileSystem), recursive: false).ConfigureAwait(false); - progress.Report(2); // Quickly scan CollectionFolders for changes foreach (var folder in GetUserRootFolder().Children.OfType().ToList()) { await folder.RefreshMetadata(cancellationToken).ConfigureAwait(false); } + } + + private async Task PerformLibraryValidation(IProgress progress, CancellationToken cancellationToken) + { + _logger.Info("Validating media library"); + + await ValidateTopLibraryFolders(cancellationToken).ConfigureAwait(false); progress.Report(3); var innerProgress = new ActionableProgress(); @@ -1429,7 +1427,7 @@ private void SetTopParentOrAncestorIds(InternalItemsQuery query) return; } - var parents = query.AncestorIds.Select(i => GetItemById(new Guid(i))).ToList(); + var parents = query.AncestorIds.Select(i => GetItemById(i)).ToList(); if (parents.All(i => { @@ -1444,13 +1442,13 @@ private void SetTopParentOrAncestorIds(InternalItemsQuery query) })) { // Optimize by querying against top level views - query.TopParentIds = parents.SelectMany(i => GetTopParentIdsForQuery(i, query.User)).Select(i => i.ToString("N")).ToArray(); - query.AncestorIds = new string[] { }; + query.TopParentIds = parents.SelectMany(i => GetTopParentIdsForQuery(i, query.User)).ToArray(); + query.AncestorIds = new Guid[] { }; // Prevent searching in all libraries due to empty filter if (query.TopParentIds.Length == 0) { - query.TopParentIds = new[] { Guid.NewGuid().ToString("N") }; + query.TopParentIds = new[] { Guid.NewGuid() }; } } } @@ -1510,23 +1508,23 @@ private void SetTopParentIdsOrAncestors(InternalItemsQuery query, List })) { // Optimize by querying against top level views - query.TopParentIds = parents.SelectMany(i => GetTopParentIdsForQuery(i, query.User)).Select(i => i.ToString("N")).ToArray(); + query.TopParentIds = parents.SelectMany(i => GetTopParentIdsForQuery(i, query.User)).ToArray(); // Prevent searching in all libraries due to empty filter if (query.TopParentIds.Length == 0) { - query.TopParentIds = new[] { Guid.NewGuid().ToString("N") }; + query.TopParentIds = new[] { Guid.NewGuid() }; } } else { // We need to be able to query from any arbitrary ancestor up the tree - query.AncestorIds = parents.SelectMany(i => i.GetIdsForAncestorQuery()).Select(i => i.ToString("N")).ToArray(); + query.AncestorIds = parents.SelectMany(i => i.GetIdsForAncestorQuery()).ToArray(); // Prevent searching in all libraries due to empty filter if (query.AncestorIds.Length == 0) { - query.AncestorIds = new[] { Guid.NewGuid().ToString("N") }; + query.AncestorIds = new[] { Guid.NewGuid() }; } } @@ -1550,7 +1548,7 @@ private void AddUserToQuery(InternalItemsQuery query, User user, bool allowExter IncludeExternalContent = allowExternalContent }); - query.TopParentIds = userViews.SelectMany(i => GetTopParentIdsForQuery(i, user)).Select(i => i.ToString("N")).ToArray(); + query.TopParentIds = userViews.SelectMany(i => GetTopParentIdsForQuery(i, user)).ToArray(); } } @@ -2911,7 +2909,7 @@ public async Task ConvertImageToLocal(BaseItem item, ItemImageInf throw new InvalidOperationException(); } - public void AddVirtualFolder(string name, string collectionType, LibraryOptions options, bool refreshLibrary) + public async Task AddVirtualFolder(string name, string collectionType, LibraryOptions options, bool refreshLibrary) { if (string.IsNullOrWhiteSpace(name)) { @@ -2964,26 +2962,30 @@ public void AddVirtualFolder(string name, string collectionType, LibraryOptions } finally { - Task.Run(() => + if (refreshLibrary) { - // No need to start if scanning the library because it will handle it - if (refreshLibrary) - { - ValidateMediaLibrary(new SimpleProgress(), CancellationToken.None); - } - else - { - // Need to add a delay here or directory watchers may still pick up the changes - var task = Task.Delay(1000); - // Have to block here to allow exceptions to bubble - Task.WaitAll(task); + await ValidateTopLibraryFolders(CancellationToken.None).ConfigureAwait(false); - _libraryMonitorFactory().Start(); - } - }); + StartScanInBackground(); + } + else + { + // Need to add a delay here or directory watchers may still pick up the changes + await Task.Delay(1000).ConfigureAwait(false); + _libraryMonitorFactory().Start(); + } } } + private void StartScanInBackground() + { + Task.Run(() => + { + // No need to start if scanning the library because it will handle it + ValidateMediaLibrary(new SimpleProgress(), CancellationToken.None); + }); + } + private bool ValidateNetworkPath(string path) { //if (Environment.OSVersion.Platform == PlatformID.Win32NT) @@ -3118,7 +3120,7 @@ private void SyncLibraryOptionsToLocations(string virtualFolderPath, LibraryOpti } } - public void RemoveVirtualFolder(string name, bool refreshLibrary) + public async Task RemoveVirtualFolder(string name, bool refreshLibrary) { if (string.IsNullOrWhiteSpace(name)) { @@ -3142,25 +3144,20 @@ public void RemoveVirtualFolder(string name, bool refreshLibrary) } finally { - Task.Run(() => - { - CollectionFolder.OnCollectionFolderChange(); + CollectionFolder.OnCollectionFolderChange(); - // No need to start if scanning the library because it will handle it - if (refreshLibrary) - { - ValidateMediaLibrary(new SimpleProgress(), CancellationToken.None); - } - else - { - // Need to add a delay here or directory watchers may still pick up the changes - var task = Task.Delay(1000); - // Have to block here to allow exceptions to bubble - Task.WaitAll(task); + if (refreshLibrary) + { + await ValidateTopLibraryFolders(CancellationToken.None).ConfigureAwait(false); - _libraryMonitorFactory().Start(); - } - }); + StartScanInBackground(); + } + else + { + // Need to add a delay here or directory watchers may still pick up the changes + await Task.Delay(1000).ConfigureAwait(false); + _libraryMonitorFactory().Start(); + } } } diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.cs index 161f7f49e0..835afb937a 100644 --- a/Emby.Server.Implementations/Library/MediaSourceManager.cs +++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs @@ -112,19 +112,9 @@ private List GetMediaStreamsForItem(List streams) return streams; } - public async Task> GetPlayackMediaSources(string id, string userId, bool enablePathSubstitution, string[] supportedLiveMediaTypes, CancellationToken cancellationToken) + public async Task> GetPlayackMediaSources(BaseItem item, User user, bool enablePathSubstitution, CancellationToken cancellationToken) { - var item = _libraryManager.GetItemById(id); - - var hasMediaSources = (IHasMediaSources)item; - User user = null; - - if (!string.IsNullOrEmpty(userId)) - { - user = _userManager.GetUserById(userId); - } - - var mediaSources = GetStaticMediaSources(hasMediaSources, enablePathSubstitution, user); + var mediaSources = GetStaticMediaSources(item, enablePathSubstitution, user); if (mediaSources.Count == 1 && mediaSources[0].Type != MediaSourceType.Placeholder && !mediaSources[0].MediaStreams.Any(i => i.Type == MediaStreamType.Audio || i.Type == MediaStreamType.Video)) { @@ -135,10 +125,10 @@ await item.RefreshMetadata(new MediaBrowser.Controller.Providers.MetadataRefresh }, cancellationToken).ConfigureAwait(false); - mediaSources = GetStaticMediaSources(hasMediaSources, enablePathSubstitution, user); + mediaSources = GetStaticMediaSources(item, enablePathSubstitution, user); } - var dynamicMediaSources = await GetDynamicMediaSources(hasMediaSources, cancellationToken).ConfigureAwait(false); + var dynamicMediaSources = await GetDynamicMediaSources(item, cancellationToken).ConfigureAwait(false); var list = new List(); @@ -148,7 +138,7 @@ await item.RefreshMetadata(new MediaBrowser.Controller.Providers.MetadataRefresh { if (user != null) { - SetUserProperties(hasMediaSources as BaseItem, source, user); + SetUserProperties(item, source, user); } // Validate that this is actually possible @@ -174,7 +164,7 @@ await item.RefreshMetadata(new MediaBrowser.Controller.Providers.MetadataRefresh } } - return SortMediaSources(list).Where(i => i.Type != MediaSourceType.Placeholder); + return SortMediaSources(list).Where(i => i.Type != MediaSourceType.Placeholder).ToList(); } private bool SupportsDirectStream(string path, MediaProtocol protocol) @@ -200,7 +190,7 @@ private bool SupportsDirectStream(string path, MediaProtocol protocol) return false; } - private async Task> GetDynamicMediaSources(IHasMediaSources item, CancellationToken cancellationToken) + private async Task> GetDynamicMediaSources(BaseItem item, CancellationToken cancellationToken) { var tasks = _providers.Select(i => GetDynamicMediaSources(item, i, cancellationToken)); var results = await Task.WhenAll(tasks).ConfigureAwait(false); @@ -208,7 +198,7 @@ private async Task> GetDynamicMediaSources(IHasMedi return results.SelectMany(i => i.ToList()); } - private async Task> GetDynamicMediaSources(IHasMediaSources item, IMediaSourceProvider provider, CancellationToken cancellationToken) + private async Task> GetDynamicMediaSources(BaseItem item, IMediaSourceProvider provider, CancellationToken cancellationToken) { try { @@ -246,38 +236,39 @@ private void SetKeyProperties(IMediaSourceProvider provider, MediaSourceInfo med } } - public async Task GetMediaSource(IHasMediaSources item, string mediaSourceId, string liveStreamId, bool enablePathSubstitution, CancellationToken cancellationToken) + public async Task GetMediaSource(BaseItem item, string mediaSourceId, string liveStreamId, bool enablePathSubstitution, CancellationToken cancellationToken) { if (!string.IsNullOrEmpty(liveStreamId)) { return await GetLiveStream(liveStreamId, cancellationToken).ConfigureAwait(false); } - var sources = await GetPlayackMediaSources(item.Id.ToString("N"), null, enablePathSubstitution, new[] { MediaType.Audio, MediaType.Video }, - CancellationToken.None).ConfigureAwait(false); + var sources = await GetPlayackMediaSources(item, null, enablePathSubstitution, cancellationToken).ConfigureAwait(false); return sources.FirstOrDefault(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase)); } - public List GetStaticMediaSources(IHasMediaSources item, bool enablePathSubstitution, User user = null) + public List GetStaticMediaSources(BaseItem item, bool enablePathSubstitution, User user = null) { if (item == null) { throw new ArgumentNullException("item"); } + var hasMediaSources = (IHasMediaSources)item; + if (!(item is Video)) { - return item.GetMediaSources(enablePathSubstitution); + return hasMediaSources.GetMediaSources(enablePathSubstitution); } - var sources = item.GetMediaSources(enablePathSubstitution); + var sources = hasMediaSources.GetMediaSources(enablePathSubstitution); if (user != null) { foreach (var source in sources) { - SetUserProperties(item as BaseItem, source, user); + SetUserProperties(item, source, user); } } @@ -571,7 +562,6 @@ private Tuple GetProvider(string key) public void Dispose() { Dispose(true); - GC.SuppressFinalize(this); } private readonly object _disposeLock = new object(); diff --git a/Emby.Server.Implementations/Library/MusicManager.cs b/Emby.Server.Implementations/Library/MusicManager.cs index 1cbf4235aa..43c108e191 100644 --- a/Emby.Server.Implementations/Library/MusicManager.cs +++ b/Emby.Server.Implementations/Library/MusicManager.cs @@ -67,19 +67,19 @@ public List GetInstantMixFromGenres(IEnumerable genres, User u { try { - return _libraryManager.GetMusicGenre(i).Id.ToString("N"); + return _libraryManager.GetMusicGenre(i).Id; } catch { - return null; + return Guid.Empty; } - }).Where(i => i != null); + }).Where(i => i != Guid.Empty).ToArray(); return GetInstantMixFromGenreIds(genreIds, user, dtoOptions); } - public List GetInstantMixFromGenreIds(IEnumerable genreIds, User user, DtoOptions dtoOptions) + public List GetInstantMixFromGenreIds(Guid[] genreIds, User user, DtoOptions dtoOptions) { return _libraryManager.GetItemList(new InternalItemsQuery(user) { @@ -101,7 +101,7 @@ public List GetInstantMixFromItem(BaseItem item, User user, DtoOptions var genre = item as MusicGenre; if (genre != null) { - return GetInstantMixFromGenreIds(new[] { item.Id.ToString("N") }, user, dtoOptions); + return GetInstantMixFromGenreIds(new[] { item.Id }, user, dtoOptions); } var playlist = item as Playlist; diff --git a/Emby.Server.Implementations/Library/SearchEngine.cs b/Emby.Server.Implementations/Library/SearchEngine.cs index 28bbe6b013..cdbddb3c1c 100644 --- a/Emby.Server.Implementations/Library/SearchEngine.cs +++ b/Emby.Server.Implementations/Library/SearchEngine.cs @@ -202,7 +202,7 @@ private Task> GetSearchHints(SearchQuery query, User { if (searchQuery.ParentId.HasValue) { - searchQuery.AncestorIds = new string[] { searchQuery.ParentId.Value.ToString("N") }; + searchQuery.AncestorIds = new Guid[] { searchQuery.ParentId.Value }; } searchQuery.ParentId = null; searchQuery.IncludeItemsByName = true; diff --git a/Emby.Server.Implementations/Library/UserViewManager.cs b/Emby.Server.Implementations/Library/UserViewManager.cs index 75a231651c..be575310df 100644 --- a/Emby.Server.Implementations/Library/UserViewManager.cs +++ b/Emby.Server.Implementations/Library/UserViewManager.cs @@ -48,15 +48,6 @@ public Folder[] GetUserViews(UserViewQuery query) .OfType() .ToList(); - if (!query.IncludeHidden) - { - folders = folders.Where(i => - { - var hidden = i as IHiddenFromDisplay; - return hidden == null || !hidden.IsHiddenFromUser(user); - }).ToList(); - } - var groupedFolders = new List(); var list = new List(); @@ -126,6 +117,11 @@ public Folder[] GetUserViews(UserViewQuery query) } } + if (!query.IncludeHidden) + { + list = list.Where(i => !user.Configuration.MyMediaExcludes.Contains(i.Id.ToString("N"))).ToList(); + } + var sorted = _libraryManager.Sort(list, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending).ToList(); var orders = user.Configuration.OrderedViews.ToList(); @@ -246,7 +242,7 @@ private List GetItemsForLatestItems(User user, LatestItemsQuery reques { return _channelManager.GetLatestChannelItemsInternal(new InternalItemsQuery(user) { - ChannelIds = new string[] { request.ParentId }, + ChannelIds = new Guid[] { new Guid(request.ParentId) }, IsPlayed = request.IsPlayed, StartIndex = request.StartIndex, Limit = request.Limit, diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index e376d7cd1d..a72cb4ea83 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -109,12 +109,12 @@ private void _config_NamedConfigurationUpdated(object sender, ConfigurationUpdat } } - public void Start() + public async void Start() { _timerProvider.RestartTimers(); _systemEvents.Resume += _systemEvents_Resume; - CreateRecordingFolders(); + await CreateRecordingFolders().ConfigureAwait(false); } private void _systemEvents_Resume(object sender, EventArgs e) @@ -122,83 +122,78 @@ private void _systemEvents_Resume(object sender, EventArgs e) _timerProvider.RestartTimers(); } - private void OnRecordingFoldersChanged() + private async void OnRecordingFoldersChanged() { - CreateRecordingFolders(); + await CreateRecordingFolders().ConfigureAwait(false); } - internal void CreateRecordingFolders() + internal async Task CreateRecordingFolders() { try { - CreateRecordingFoldersInternal(); - } - catch (Exception ex) - { - _logger.ErrorException("Error creating recording folders", ex); - } - } + var recordingFolders = GetRecordingFolders(); - internal void CreateRecordingFoldersInternal() - { - var recordingFolders = GetRecordingFolders(); + var virtualFolders = _libraryManager.GetVirtualFolders() + .ToList(); - var virtualFolders = _libraryManager.GetVirtualFolders() - .ToList(); + var allExistingPaths = virtualFolders.SelectMany(i => i.Locations).ToList(); - var allExistingPaths = virtualFolders.SelectMany(i => i.Locations).ToList(); + var pathsAdded = new List(); - var pathsAdded = new List(); + foreach (var recordingFolder in recordingFolders) + { + var pathsToCreate = recordingFolder.Locations + .Where(i => !allExistingPaths.Any(p => _fileSystem.AreEqual(p, i))) + .ToList(); - foreach (var recordingFolder in recordingFolders) - { - var pathsToCreate = recordingFolder.Locations - .Where(i => !allExistingPaths.Any(p => _fileSystem.AreEqual(p, i))) - .ToList(); + if (pathsToCreate.Count == 0) + { + continue; + } - if (pathsToCreate.Count == 0) - { - continue; - } + var mediaPathInfos = pathsToCreate.Select(i => new MediaPathInfo { Path = i }).ToArray(); - var mediaPathInfos = pathsToCreate.Select(i => new MediaPathInfo { Path = i }).ToArray(); + var libraryOptions = new LibraryOptions + { + PathInfos = mediaPathInfos + }; + try + { + await _libraryManager.AddVirtualFolder(recordingFolder.Name, recordingFolder.CollectionType, libraryOptions, true).ConfigureAwait(false); + } + catch (Exception ex) + { + _logger.ErrorException("Error creating virtual folder", ex); + } - var libraryOptions = new LibraryOptions - { - PathInfos = mediaPathInfos - }; - try - { - _libraryManager.AddVirtualFolder(recordingFolder.Name, recordingFolder.CollectionType, libraryOptions, true); - } - catch (Exception ex) - { - _logger.ErrorException("Error creating virtual folder", ex); + pathsAdded.AddRange(pathsToCreate); } - pathsAdded.AddRange(pathsToCreate); - } + var config = GetConfiguration(); - var config = GetConfiguration(); + var pathsToRemove = config.MediaLocationsCreated + .Except(recordingFolders.SelectMany(i => i.Locations)) + .ToList(); - var pathsToRemove = config.MediaLocationsCreated - .Except(recordingFolders.SelectMany(i => i.Locations)) - .ToList(); + if (pathsAdded.Count > 0 || pathsToRemove.Count > 0) + { + pathsAdded.InsertRange(0, config.MediaLocationsCreated); + config.MediaLocationsCreated = pathsAdded.Except(pathsToRemove).Distinct(StringComparer.OrdinalIgnoreCase).ToArray(); + _config.SaveConfiguration("livetv", config); + } - if (pathsAdded.Count > 0 || pathsToRemove.Count > 0) - { - pathsAdded.InsertRange(0, config.MediaLocationsCreated); - config.MediaLocationsCreated = pathsAdded.Except(pathsToRemove).Distinct(StringComparer.OrdinalIgnoreCase).ToArray(); - _config.SaveConfiguration("livetv", config); + foreach (var path in pathsToRemove) + { + await RemovePathFromLibrary(path).ConfigureAwait(false); + } } - - foreach (var path in pathsToRemove) + catch (Exception ex) { - RemovePathFromLibrary(path); + _logger.ErrorException("Error creating recording folders", ex); } } - private void RemovePathFromLibrary(string path) + private async Task RemovePathFromLibrary(string path) { _logger.Debug("Removing path from library: {0}", path); @@ -218,7 +213,7 @@ private void RemovePathFromLibrary(string path) // remove entire virtual folder try { - _libraryManager.RemoveVirtualFolder(virtualFolder.Name, true); + await _libraryManager.RemoveVirtualFolder(virtualFolder.Name, true).ConfigureAwait(false); } catch (Exception ex) { @@ -2358,7 +2353,7 @@ private LiveTvProgram GetProgramInfoFromCache(string programId) { var query = new InternalItemsQuery { - ItemIds = new[] { _liveTvManager.GetInternalProgramId(Name, programId).ToString("N") }, + ItemIds = new[] { _liveTvManager.GetInternalProgramId(Name, programId) }, Limit = 1, DtoOptions = new DtoOptions() }; @@ -2393,7 +2388,7 @@ private LiveTvProgram GetProgramInfoFromCache(string channelId, DateTime startDa if (!string.IsNullOrWhiteSpace(channelId)) { - query.ChannelIds = new[] { _liveTvManager.GetInternalChannelId(Name, channelId).ToString("N") }; + query.ChannelIds = new[] { _liveTvManager.GetInternalChannelId(Name, channelId) }; } return _libraryManager.GetItemList(query).Cast().FirstOrDefault(); @@ -2598,7 +2593,7 @@ private IEnumerable GetTimersForSeries(SeriesTimerInfo seriesTimer) if (!seriesTimer.RecordAnyChannel) { - query.ChannelIds = new[] { _liveTvManager.GetInternalChannelId(Name, seriesTimer.ChannelId).ToString("N") }; + query.ChannelIds = new[] { _liveTvManager.GetInternalChannelId(Name, seriesTimer.ChannelId) }; } var tempChannelCache = new Dictionary(); @@ -2619,7 +2614,7 @@ private TimerInfo CreateTimer(LiveTvProgram parent, SeriesTimerInfo seriesTimer, channel = _libraryManager.GetItemList(new InternalItemsQuery { IncludeItemTypes = new string[] { typeof(LiveTvChannel).Name }, - ItemIds = new[] { parent.ChannelId }, + ItemIds = new[] { new Guid(parent.ChannelId) }, DtoOptions = new DtoOptions() }).Cast().FirstOrDefault(); @@ -2680,7 +2675,7 @@ private void CopyProgramInfoToTimerInfo(LiveTvProgram programInfo, TimerInfo tim channel = _libraryManager.GetItemList(new InternalItemsQuery { IncludeItemTypes = new string[] { typeof(LiveTvChannel).Name }, - ItemIds = new[] { programInfo.ChannelId }, + ItemIds = new[] { new Guid(programInfo.ChannelId) }, DtoOptions = new DtoOptions() }).Cast().FirstOrDefault(); @@ -2751,7 +2746,7 @@ private bool IsProgramAlreadyInLibrary(TimerInfo program) IncludeItemTypes = new[] { typeof(Series).Name }, Name = program.Name - }).Select(i => i.ToString("N")).ToArray(); + }).ToArray(); if (seriesIds.Length == 0) { @@ -2788,7 +2783,6 @@ public void Dispose() { pair.Value.CancellationTokenSource.Cancel(); } - GC.SuppressFinalize(this); } public List GetRecordingFolders() diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EntryPoint.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EntryPoint.cs index 7c5f630a70..cc9e80a821 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EntryPoint.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EntryPoint.cs @@ -12,7 +12,6 @@ public void Run() public void Dispose() { - GC.SuppressFinalize(this); } } } diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs index b3a1943b81..6c4e5ec7da 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs @@ -26,7 +26,16 @@ public static string GetRecordingName(TimerInfo info) } else if (info.OriginalAirDate.HasValue) { - name += " " + info.OriginalAirDate.Value.ToString("yyyy-MM-dd"); + var localAirDate = info.OriginalAirDate.Value.ToLocalTime(); + + if (localAirDate.Date.Equals(DateTime.Now.Date)) + { + name += " " + GetDateString(localAirDate); + } + else + { + name += " " + localAirDate.ToString("yyyy-MM-dd"); + } } else { diff --git a/Emby.Server.Implementations/LiveTv/Listings/XmlTvProvider.cs b/Emby.Server.Implementations/LiveTv/Listings/XmlTvProvider.cs deleted file mode 100644 index 7057b18b24..0000000000 --- a/Emby.Server.Implementations/LiveTv/Listings/XmlTvProvider.cs +++ /dev/null @@ -1,320 +0,0 @@ -using MediaBrowser.Controller.LiveTv; -using MediaBrowser.Model.Dto; -using MediaBrowser.Model.LiveTv; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.IO.Compression; -using System.Linq; -using System.Net; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Emby.XmlTv.Classes; -using Emby.XmlTv.Entities; -using MediaBrowser.Common.Extensions; -using MediaBrowser.Common.Net; -using MediaBrowser.Common.Progress; -using MediaBrowser.Controller.Configuration; -using MediaBrowser.Model.IO; -using MediaBrowser.Model.Logging; - -namespace Emby.Server.Implementations.LiveTv.Listings -{ - public class XmlTvProvider - { - private readonly IServerConfigurationManager _config; - private readonly IHttpClient _httpClient; - private readonly ILogger _logger; - private readonly IFileSystem _fileSystem; - private readonly IZipClient _zipClient; - - public XmlTvProvider(IServerConfigurationManager config, IHttpClient httpClient, ILogger logger, IFileSystem fileSystem, IZipClient zipClient) - { - _config = config; - _httpClient = httpClient; - _logger = logger; - _fileSystem = fileSystem; - _zipClient = zipClient; - } - - public string Name - { - get { return "XmlTV"; } - } - - public string Type - { - get { return "xmltv"; } - } - - private string GetLanguage(ListingsProviderInfo info) - { - if (!string.IsNullOrEmpty(info.PreferredLanguage)) - { - return info.PreferredLanguage; - } - - return _config.Configuration.PreferredMetadataLanguage; - } - - private async Task GetXml(ListingsProviderInfo info, string path, CancellationToken cancellationToken) - { - _logger.Info("xmltv path: {0}", path); - - if (!path.StartsWith("http", StringComparison.OrdinalIgnoreCase)) - { - return UnzipIfNeeded(path, path); - } - - var cacheFilename = DateTime.UtcNow.DayOfYear.ToString(CultureInfo.InvariantCulture) + "-" + DateTime.UtcNow.Hour.ToString(CultureInfo.InvariantCulture) + ".xml"; - var cacheFile = Path.Combine(_config.ApplicationPaths.CachePath, "xmltv", cacheFilename); - if (_fileSystem.FileExists(cacheFile)) - { - return UnzipIfNeeded(path, cacheFile); - } - - _logger.Info("Downloading xmltv listings from {0}", path); - - var tempFile = await _httpClient.GetTempFile(new HttpRequestOptions - { - CancellationToken = cancellationToken, - Url = path, - Progress = new SimpleProgress(), - DecompressionMethod = CompressionMethod.Gzip, - - // It's going to come back gzipped regardless of this value - // So we need to make sure the decompression method is set to gzip - EnableHttpCompression = true, - - UserAgent = string.IsNullOrEmpty(info.UserAgent) ? "Emby/3.0" : info.UserAgent - - }).ConfigureAwait(false); - - _fileSystem.CreateDirectory(_fileSystem.GetDirectoryName(cacheFile)); - - _fileSystem.CopyFile(tempFile, cacheFile, true); - - return UnzipIfNeeded(path, cacheFile); - } - - private string UnzipIfNeeded(string originalUrl, string file) - { - var ext = Path.GetExtension(originalUrl.Split('?')[0]); - - //if (string.Equals(ext, ".gz", StringComparison.OrdinalIgnoreCase)) - { - try - { - var tempFolder = ExtractGz(file); - return FindXmlFile(tempFolder); - } - catch (Exception ex) - { - //_logger.ErrorException("Error extracting from gz file {0}", ex, file); - } - - try - { - var tempFolder = ExtractFirstFileFromGz(file); - return FindXmlFile(tempFolder); - } - catch (Exception ex) - { - //_logger.ErrorException("Error extracting from zip file {0}", ex, file); - } - } - - return file; - } - - private string ExtractFirstFileFromGz(string file) - { - using (var stream = _fileSystem.OpenRead(file)) - { - var tempFolder = Path.Combine(_config.ApplicationPaths.TempDirectory, Guid.NewGuid().ToString()); - _fileSystem.CreateDirectory(tempFolder); - - _zipClient.ExtractFirstFileFromGz(stream, tempFolder, "data.xml"); - - return tempFolder; - } - } - - private string ExtractGz(string file) - { - using (var stream = _fileSystem.OpenRead(file)) - { - var tempFolder = Path.Combine(_config.ApplicationPaths.TempDirectory, Guid.NewGuid().ToString()); - _fileSystem.CreateDirectory(tempFolder); - - _zipClient.ExtractAllFromGz(stream, tempFolder, true); - - return tempFolder; - } - } - - private string FindXmlFile(string directory) - { - return _fileSystem.GetFiles(directory, true) - .Where(i => string.Equals(i.Extension, ".xml", StringComparison.OrdinalIgnoreCase)) - .Select(i => i.FullName) - .FirstOrDefault(); - } - - public async Task> GetProgramsAsync(ListingsProviderInfo info, string channelId, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken) - { - if (string.IsNullOrEmpty(channelId)) - { - throw new ArgumentNullException("channelId"); - } - - _logger.Debug("Getting xmltv programs for channel {0}", channelId); - - var path = await GetXml(info, info.Path, cancellationToken).ConfigureAwait(false); - - _logger.Debug("Opening XmlTvReader for {0}", path); - - return new XmlTvReader(path, GetLanguage(info)) - .GetProgrammes(channelId, startDateUtc, endDateUtc, cancellationToken) - .Select(p => GetProgramInfo(p, info)); - } - - private ProgramInfo GetProgramInfo(XmlTvProgram p, ListingsProviderInfo info) - { - var episodeTitle = p.Episode == null ? null : p.Episode.Title; - - var programInfo = new ProgramInfo - { - ChannelId = p.ChannelId, - EndDate = GetDate(p.EndDate), - EpisodeNumber = p.Episode == null ? null : p.Episode.Episode, - EpisodeTitle = episodeTitle, - Genres = p.Categories, - StartDate = GetDate(p.StartDate), - Name = p.Title, - Overview = p.Description, - ProductionYear = !p.CopyrightDate.HasValue ? (int?)null : p.CopyrightDate.Value.Year, - SeasonNumber = p.Episode == null ? null : p.Episode.Series, - IsSeries = p.Episode != null, - IsRepeat = p.IsPreviouslyShown && !p.IsNew, - IsPremiere = p.Premiere != null, - IsKids = p.Categories.Any(c => info.KidsCategories.Contains(c, StringComparer.OrdinalIgnoreCase)), - IsMovie = p.Categories.Any(c => info.MovieCategories.Contains(c, StringComparer.OrdinalIgnoreCase)), - IsNews = p.Categories.Any(c => info.NewsCategories.Contains(c, StringComparer.OrdinalIgnoreCase)), - IsSports = p.Categories.Any(c => info.SportsCategories.Contains(c, StringComparer.OrdinalIgnoreCase)), - ImageUrl = p.Icon != null && !String.IsNullOrEmpty(p.Icon.Source) ? p.Icon.Source : null, - HasImage = p.Icon != null && !String.IsNullOrEmpty(p.Icon.Source), - OfficialRating = p.Rating != null && !String.IsNullOrEmpty(p.Rating.Value) ? p.Rating.Value : null, - CommunityRating = p.StarRating.HasValue ? p.StarRating.Value : (float?)null, - SeriesId = p.Episode != null ? p.Title.GetMD5().ToString("N") : null, - ProviderIds = p.ProviderIds, - SeriesProviderIds = p.ProviderIds - }; - - if (!string.IsNullOrWhiteSpace(p.ProgramId)) - { - programInfo.ShowId = p.ProgramId; - } - else - { - string iceTvEpisodeNumber; - p.ProviderIds.TryGetValue("icetv", out iceTvEpisodeNumber); - - var uniqueString = (p.Title ?? string.Empty) + (episodeTitle ?? string.Empty) + (iceTvEpisodeNumber ?? string.Empty); - - if (programInfo.SeasonNumber.HasValue) - { - uniqueString = "-" + programInfo.SeasonNumber.Value.ToString(CultureInfo.InvariantCulture); - } - if (programInfo.EpisodeNumber.HasValue) - { - uniqueString = "-" + programInfo.EpisodeNumber.Value.ToString(CultureInfo.InvariantCulture); - } - - programInfo.ShowId = uniqueString.GetMD5().ToString("N"); - - // If we don't have valid episode info, assume it's a unique program, otherwise recordings might be skipped - if (programInfo.IsSeries && !programInfo.IsRepeat) - { - if ((programInfo.EpisodeNumber ?? 0) == 0) - { - programInfo.ShowId = programInfo.ShowId + programInfo.StartDate.Ticks.ToString(CultureInfo.InvariantCulture); - } - } - } - - // Construct an id from the channel and start date - programInfo.Id = String.Format("{0}_{1:O}", p.ChannelId, p.StartDate); - - if (programInfo.IsMovie) - { - programInfo.IsSeries = false; - programInfo.EpisodeNumber = null; - programInfo.EpisodeTitle = null; - } - - return programInfo; - } - - private DateTime GetDate(DateTime date) - { - if (date.Kind != DateTimeKind.Utc) - { - date = DateTime.SpecifyKind(date, DateTimeKind.Utc); - } - return date; - } - - public Task Validate(ListingsProviderInfo info, bool validateLogin, bool validateListings) - { - // Assume all urls are valid. check files for existence - if (!info.Path.StartsWith("http", StringComparison.OrdinalIgnoreCase) && !_fileSystem.FileExists(info.Path)) - { - throw new FileNotFoundException("Could not find the XmlTv file specified:", info.Path); - } - - return Task.FromResult(true); - } - - public async Task> GetLineups(ListingsProviderInfo info, string country, string location) - { - // In theory this should never be called because there is always only one lineup - var channels = await GetChannels(info, CancellationToken.None); - - return channels.Select(i => new NameIdPair - { - Name = i.Name, - Id = i.Id - - }).ToList(); - } - - public async Task> GetChannels(ListingsProviderInfo info, CancellationToken cancellationToken) - { - var path = await GetXml(info, info.Path, cancellationToken).ConfigureAwait(false); - - _logger.Debug("Opening XmlTvReader for {0}", path); - - var xmlChannels = new XmlTvReader(path, GetLanguage(info)).GetChannels(); - - var list = new List(); - - foreach (var xmlChannel in xmlChannels) - { - var channel = new ChannelInfo - { - Id = xmlChannel.Id, - Name = xmlChannel.DisplayName, - ImageUrl = xmlChannel.Icon != null && !string.IsNullOrWhiteSpace(xmlChannel.Icon.Source) ? xmlChannel.Icon.Source : null, - Number = string.IsNullOrWhiteSpace(xmlChannel.Number) ? xmlChannel.Id : xmlChannel.Number - }; - - list.Add(channel); - } - - return list; - } - } -} \ No newline at end of file diff --git a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs index a4e684d852..5723e1abdf 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs @@ -36,7 +36,7 @@ public LiveTvDtoService(IDtoService dtoService, IImageProcessor imageProcessor, _libraryManager = libraryManager; } - public TimerInfoDto GetTimerInfoDto(TimerInfo info, ILiveTvService service, LiveTvProgram program, LiveTvChannel channel) + public TimerInfoDto GetTimerInfoDto(TimerInfo info, ILiveTvService service, LiveTvProgram program, BaseItem channel) { var dto = new TimerInfoDto { @@ -464,7 +464,7 @@ public async Task GetTimerInfo(TimerInfoDto dto, bool isNew, LiveTvMa if (!string.IsNullOrEmpty(dto.ChannelId) && string.IsNullOrEmpty(info.ChannelId)) { - var channel = liveTv.GetInternalChannel(dto.ChannelId); + var channel = _libraryManager.GetItemById(dto.ChannelId); if (channel != null) { @@ -474,7 +474,7 @@ public async Task GetTimerInfo(TimerInfoDto dto, bool isNew, LiveTvMa if (!string.IsNullOrEmpty(dto.ProgramId) && string.IsNullOrEmpty(info.ProgramId)) { - var program = liveTv.GetInternalProgram(dto.ProgramId); + var program = _libraryManager.GetItemById(dto.ProgramId); if (program != null) { @@ -530,7 +530,7 @@ public async Task GetSeriesTimerInfo(SeriesTimerInfoDto dto, bo if (!string.IsNullOrEmpty(dto.ChannelId) && string.IsNullOrEmpty(info.ChannelId)) { - var channel = liveTv.GetInternalChannel(dto.ChannelId); + var channel = _libraryManager.GetItemById(dto.ChannelId); if (channel != null) { @@ -540,7 +540,7 @@ public async Task GetSeriesTimerInfo(SeriesTimerInfoDto dto, bo if (!string.IsNullOrEmpty(dto.ProgramId) && string.IsNullOrEmpty(info.ProgramId)) { - var program = liveTv.GetInternalProgram(dto.ProgramId); + var program = _libraryManager.GetItemById(dto.ProgramId); if (program != null) { diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index 60f9c0588f..24dbfd74c6 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -184,7 +184,7 @@ public QueryResult GetInternalChannels(LiveTvChannelQuery query, DtoOp IsSports = query.IsSports, IsSeries = query.IsSeries, IncludeItemTypes = new[] { typeof(LiveTvChannel).Name }, - TopParentIds = new[] { topFolder.Id.ToString("N") }, + TopParentIds = new[] { topFolder.Id }, IsFavorite = query.IsFavorite, IsLiked = query.IsLiked, StartIndex = query.StartIndex, @@ -211,32 +211,12 @@ public QueryResult GetInternalChannels(LiveTvChannelQuery query, DtoOp return _libraryManager.GetItemsResult(internalQuery); } - public LiveTvChannel GetInternalChannel(string id) - { - return GetInternalChannel(new Guid(id)); - } - - private LiveTvChannel GetInternalChannel(Guid id) - { - return _libraryManager.GetItemById(id) as LiveTvChannel; - } - - internal LiveTvProgram GetInternalProgram(string id) - { - return _libraryManager.GetItemById(id) as LiveTvProgram; - } - - internal LiveTvProgram GetInternalProgram(Guid id) - { - return _libraryManager.GetItemById(id) as LiveTvProgram; - } - public Task> GetChannelStream(string id, string mediaSourceId, CancellationToken cancellationToken) { return GetLiveStream(id, mediaSourceId, cancellationToken); } - public async Task> GetChannelMediaSources(IHasMediaSources item, CancellationToken cancellationToken) + public async Task> GetChannelMediaSources(BaseItem item, CancellationToken cancellationToken) { var baseItem = (LiveTvChannel)item; var service = GetService(baseItem); @@ -280,7 +260,7 @@ private async Task> GetLiveStream(string id, ILiveTvService service; ILiveStream liveStream = null; - var channel = GetInternalChannel(id); + var channel = (LiveTvChannel)_libraryManager.GetItemById(id); isVideo = channel.ChannelType == ChannelType.TV; service = GetService(channel); _logger.Info("Opening channel stream from {0}, external channel Id: {1}", service.Name, channel.ExternalId); @@ -720,7 +700,7 @@ private Tuple GetProgram(ProgramInfo info, Dictionary public async Task GetProgram(string id, CancellationToken cancellationToken, User user = null) { - var program = GetInternalProgram(id); + var program = _libraryManager.GetItemById(id); var dto = _dtoService.GetBaseItemDto(program, new DtoOptions(), user); @@ -768,7 +748,7 @@ public async Task> GetPrograms(ProgramQuery query, DtoO Limit = query.Limit, OrderBy = query.OrderBy, EnableTotalRecordCount = query.EnableTotalRecordCount, - TopParentIds = new[] { topFolder.Id.ToString("N") }, + TopParentIds = new[] { topFolder.Id }, Name = query.Name, DtoOptions = options }; @@ -836,7 +816,7 @@ public QueryResult GetRecommendedProgramsInternal(RecommendedProgramQu IsKids = query.IsKids, EnableTotalRecordCount = query.EnableTotalRecordCount, OrderBy = new[] { new Tuple(ItemSortBy.StartDate, SortOrder.Ascending) }, - TopParentIds = new[] { topFolder.Id.ToString("N") }, + TopParentIds = new[] { topFolder.Id }, DtoOptions = options, GenreIds = query.GenreIds }; @@ -918,7 +898,7 @@ private int GetRecommendationScore(LiveTvProgram program, Guid userId, bool fact score++; } - var channel = GetInternalChannel(program.ChannelId); + var channel = _libraryManager.GetItemById(program.ChannelId); if (channel != null) { @@ -1038,7 +1018,7 @@ internal Task RefreshChannels(IProgress progress, CancellationToken canc private async Task RefreshChannelsInternal(IProgress progress, CancellationToken cancellationToken) { - EmbyTV.EmbyTV.Current.CreateRecordingFolders(); + await EmbyTV.EmbyTV.Current.CreateRecordingFolders().ConfigureAwait(false); await EmbyTV.EmbyTV.Current.ScanForTunerDeviceChanges(cancellationToken).ConfigureAwait(false); @@ -1183,7 +1163,7 @@ private async Task, List>> RefreshChannelsInternal(ILiveT { IncludeItemTypes = new string[] { typeof(LiveTvProgram).Name }, - ChannelIds = new string[] { currentChannel.Id.ToString("N") }, + ChannelIds = new Guid[] { currentChannel.Id }, DtoOptions = new DtoOptions(true) }).Cast().ToDictionary(i => i.Id); @@ -1413,7 +1393,7 @@ private QueryResult GetEmbyRecordings(RecordingQuery query, DtoOptions { MediaTypes = new[] { MediaType.Video }, Recursive = true, - AncestorIds = folderIds.Select(i => i.ToString("N")).ToArray(folderIds.Count), + AncestorIds = folderIds.ToArray(folderIds.Count), IsFolder = false, IsVirtualItem = false, Limit = limit, @@ -1476,7 +1456,7 @@ public QueryResult GetRecordingSeries(RecordingQuery query, DtoOpti var internalResult = _libraryManager.GetItemsResult(new InternalItemsQuery(user) { Recursive = true, - AncestorIds = folders.Select(i => i.Id.ToString("N")).ToArray(folders.Count), + AncestorIds = folders.Select(i => i.Id).ToArray(folders.Count), Limit = query.Limit, OrderBy = new[] { new Tuple(ItemSortBy.DateCreated, SortOrder.Descending) }, EnableTotalRecordCount = query.EnableTotalRecordCount, @@ -1494,7 +1474,7 @@ public QueryResult GetRecordingSeries(RecordingQuery query, DtoOpti }; } - public async Task AddInfoToProgramDto(List> tuples, ItemFields[] fields, User user = null) + public Task AddInfoToProgramDto(List> tuples, ItemFields[] fields, User user = null) { var programTuples = new List>(); var hasChannelImage = fields.Contains(ItemFields.ChannelImage); @@ -1544,7 +1524,7 @@ public async Task AddInfoToProgramDto(List> tuples, if (hasChannelInfo || hasChannelImage) { - var channel = GetInternalChannel(program.ChannelId); + var channel = _libraryManager.GetItemById(program.ChannelId) as LiveTvChannel; if (channel != null) { @@ -1571,7 +1551,7 @@ public async Task AddInfoToProgramDto(List> tuples, programTuples.Add(new Tuple(dto, serviceName, program.ExternalId, externalSeriesId)); } - await AddRecordingInfo(programTuples, CancellationToken.None).ConfigureAwait(false); + return AddRecordingInfo(programTuples, CancellationToken.None); } public ActiveRecordingInfo GetActiveRecordingInfo(string path) @@ -1585,7 +1565,7 @@ public void AddInfoToRecordingDto(BaseItem item, BaseItemDto dto, ActiveRecordin var info = activeRecordingInfo.Timer; - var channel = string.IsNullOrWhiteSpace(info.ChannelId) ? null : GetInternalChannel(_tvDtoService.GetInternalChannelId(service.Name, info.ChannelId)); + var channel = string.IsNullOrWhiteSpace(info.ChannelId) ? null : _libraryManager.GetItemById(_tvDtoService.GetInternalChannelId(service.Name, info.ChannelId)); dto.SeriesTimerId = string.IsNullOrEmpty(info.SeriesTimerId) ? null @@ -1725,9 +1705,9 @@ public async Task> GetTimers(TimerQuery query, Cancell { var program = string.IsNullOrEmpty(i.Item1.ProgramId) ? null : - GetInternalProgram(_tvDtoService.GetInternalProgramId(i.Item2.Name, i.Item1.ProgramId).ToString("N")); + _libraryManager.GetItemById(_tvDtoService.GetInternalProgramId(i.Item2.Name, i.Item1.ProgramId).ToString("N")) as LiveTvProgram; - var channel = string.IsNullOrEmpty(i.Item1.ChannelId) ? null : GetInternalChannel(_tvDtoService.GetInternalChannelId(i.Item2.Name, i.Item1.ChannelId)); + var channel = string.IsNullOrEmpty(i.Item1.ChannelId) ? null : _libraryManager.GetItemById(_tvDtoService.GetInternalChannelId(i.Item2.Name, i.Item1.ChannelId)); returnList.Add(_tvDtoService.GetTimerInfoDto(i.Item1, i.Item2, program, channel)); } @@ -1894,7 +1874,7 @@ public async Task> GetSeriesTimers(SeriesTimerQu if (!string.IsNullOrEmpty(i.Item1.ChannelId)) { var internalChannelId = _tvDtoService.GetInternalChannelId(i.Item2.Name, i.Item1.ChannelId); - var channel = GetInternalChannel(internalChannelId); + var channel = _libraryManager.GetItemById(internalChannelId); channelName = channel == null ? null : channel.Name; } @@ -1914,7 +1894,7 @@ public void AddChannelInfo(List> tuples, DtoOp { var now = DateTime.UtcNow; - var channelIds = tuples.Select(i => i.Item2.Id.ToString("N")).Distinct().ToArray(); + var channelIds = tuples.Select(i => i.Item2.Id).Distinct().ToArray(); var programs = options.AddCurrentProgram ? _libraryManager.GetItemList(new InternalItemsQuery(user) { @@ -1924,7 +1904,7 @@ public void AddChannelInfo(List> tuples, DtoOp MinEndDate = now, Limit = channelIds.Length, OrderBy = new[] { new Tuple(ItemSortBy.StartDate, SortOrder.Ascending) }, - TopParentIds = new[] { GetInternalLiveTvFolder(CancellationToken.None).Id.ToString("N") }, + TopParentIds = new[] { GetInternalLiveTvFolder(CancellationToken.None).Id }, DtoOptions = options }) : new List(); @@ -1993,7 +1973,7 @@ private async Task> GetNewTimerDefaultsIn if (program != null) { - var channel = GetInternalChannel(program.ChannelId); + var channel = _libraryManager.GetItemById(program.ChannelId); programInfo = new ProgramInfo { @@ -2052,7 +2032,7 @@ public async Task GetNewTimerDefaults(CancellationToken canc public async Task GetNewTimerDefaults(string programId, CancellationToken cancellationToken) { - var program = GetInternalProgram(programId); + var program = (LiveTvProgram)_libraryManager.GetItemById(programId); var programDto = await GetProgram(programId, cancellationToken).ConfigureAwait(false); var defaults = await GetNewTimerDefaultsInternal(cancellationToken, program).ConfigureAwait(false); @@ -2207,7 +2187,6 @@ public GuideInfo GetGuideInfo() public void Dispose() { Dispose(true); - GC.SuppressFinalize(this); } private bool _isDisposed = false; @@ -2257,7 +2236,7 @@ private async Task GetServiceInfo(ILiveTvService service, Can if (!string.IsNullOrEmpty(i.ChannelId)) { var internalChannelId = _tvDtoService.GetInternalChannelId(service.Name, i.ChannelId); - var channel = GetInternalChannel(internalChannelId); + var channel = _libraryManager.GetItemById(internalChannelId); channelName = channel == null ? null : channel.Name; } diff --git a/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs b/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs index c735cc9560..21ea4df78f 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs @@ -40,7 +40,7 @@ public LiveTvMediaSourceProvider(ILiveTvManager liveTvManager, IApplicationPaths _appPaths = appPaths; } - public Task> GetMediaSources(IHasMediaSources item, CancellationToken cancellationToken) + public Task> GetMediaSources(BaseItem item, CancellationToken cancellationToken) { var baseItem = (BaseItem)item; @@ -61,7 +61,7 @@ public Task> GetMediaSources(IHasMediaSources item, private const char StreamIdDelimeter = '_'; private const string StreamIdDelimeterString = "_"; - private async Task> GetMediaSourcesInternal(IHasMediaSources item, ActiveRecordingInfo activeRecordingInfo, CancellationToken cancellationToken) + private async Task> GetMediaSourcesInternal(BaseItem item, ActiveRecordingInfo activeRecordingInfo, CancellationToken cancellationToken) { IEnumerable sources; @@ -82,9 +82,7 @@ private async Task> GetMediaSourcesInternal(IHasMed } catch (NotImplementedException) { - var hasMediaSources = (IHasMediaSources)item; - - sources = _mediaSourceManager.GetStaticMediaSources(hasMediaSources, false); + sources = _mediaSourceManager.GetStaticMediaSources(item, false); forceRequireOpening = true; } diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs index a61ad84da1..2bc5a0ed3e 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs @@ -112,8 +112,6 @@ public void Dispose() var task = StopStreaming(socket); Task.WaitAll(task); } - - GC.SuppressFinalize(this); } } diff --git a/Emby.Server.Implementations/Localization/Core/ar.json b/Emby.Server.Implementations/Localization/Core/ar.json index 1e2b456933..fd730c482f 100644 --- a/Emby.Server.Implementations/Localization/Core/ar.json +++ b/Emby.Server.Implementations/Localization/Core/ar.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "\u0627\u0644\u0623\u062d\u062f\u062b", "ValueSpecialEpisodeName": "\u062e\u0627\u0635 - {0}", "Inherit": "\u062a\u0648\u0631\u064a\u062b", diff --git a/Emby.Server.Implementations/Localization/Core/bg-BG.json b/Emby.Server.Implementations/Localization/Core/bg-BG.json index f33608b227..3929c71a59 100644 --- a/Emby.Server.Implementations/Localization/Core/bg-BG.json +++ b/Emby.Server.Implementations/Localization/Core/bg-BG.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438", "ValueSpecialEpisodeName": "\u0421\u043f\u0435\u0446\u0438\u0430\u043b\u043d\u0438 - {0}", "Inherit": "\u041d\u0430\u0441\u043b\u0435\u0434\u044f\u0432\u0430\u043d\u0435", diff --git a/Emby.Server.Implementations/Localization/Core/ca.json b/Emby.Server.Implementations/Localization/Core/ca.json index 6092a36f7c..3b1810611d 100644 --- a/Emby.Server.Implementations/Localization/Core/ca.json +++ b/Emby.Server.Implementations/Localization/Core/ca.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Darreres", "ValueSpecialEpisodeName": "Especial - {0}", "Inherit": "Heretat", diff --git a/Emby.Server.Implementations/Localization/Core/cs.json b/Emby.Server.Implementations/Localization/Core/cs.json index 0250e4fadd..da1bbba92d 100644 --- a/Emby.Server.Implementations/Localization/Core/cs.json +++ b/Emby.Server.Implementations/Localization/Core/cs.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Nejnov\u011bj\u0161\u00ed", "ValueSpecialEpisodeName": "Speci\u00e1l - {0}", "Inherit": "Zd\u011bdit", diff --git a/Emby.Server.Implementations/Localization/Core/da.json b/Emby.Server.Implementations/Localization/Core/da.json index a81654d19e..bd180cca08 100644 --- a/Emby.Server.Implementations/Localization/Core/da.json +++ b/Emby.Server.Implementations/Localization/Core/da.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Seneste", "ValueSpecialEpisodeName": "Special - {0}", "Inherit": "Arv", diff --git a/Emby.Server.Implementations/Localization/Core/de.json b/Emby.Server.Implementations/Localization/Core/de.json index 799bb299bf..0f38bf7726 100644 --- a/Emby.Server.Implementations/Localization/Core/de.json +++ b/Emby.Server.Implementations/Localization/Core/de.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Neueste", "ValueSpecialEpisodeName": "Special - {0}", "Inherit": "\u00dcbernehmen", diff --git a/Emby.Server.Implementations/Localization/Core/el.json b/Emby.Server.Implementations/Localization/Core/el.json index 8dbbbbf064..bd376390d7 100644 --- a/Emby.Server.Implementations/Localization/Core/el.json +++ b/Emby.Server.Implementations/Localization/Core/el.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "\u03a4\u03b5\u03bb\u03b5\u03c5\u03c4\u03b1\u03af\u03b1", "ValueSpecialEpisodeName": "\u0395\u03b9\u03b4\u03b9\u03ba\u03ac - {0} ", "Inherit": "Inherit", diff --git a/Emby.Server.Implementations/Localization/Core/en-GB.json b/Emby.Server.Implementations/Localization/Core/en-GB.json index 3f3ea053a4..4c215bfdd8 100644 --- a/Emby.Server.Implementations/Localization/Core/en-GB.json +++ b/Emby.Server.Implementations/Localization/Core/en-GB.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Latest", "ValueSpecialEpisodeName": "Special - {0}", "Inherit": "Inherit", diff --git a/Emby.Server.Implementations/Localization/Core/en-US.json b/Emby.Server.Implementations/Localization/Core/en-US.json index a767e96301..271e3f9b10 100644 --- a/Emby.Server.Implementations/Localization/Core/en-US.json +++ b/Emby.Server.Implementations/Localization/Core/en-US.json @@ -88,5 +88,6 @@ "User": "User", "System": "System", "Application": "Application", - "Plugin": "Plugin" + "Plugin": "Plugin", + "HeaderCameraUploads": "Camera Uploads" } \ No newline at end of file diff --git a/Emby.Server.Implementations/Localization/Core/es-AR.json b/Emby.Server.Implementations/Localization/Core/es-AR.json index 5d79ed8111..84e7d60b1a 100644 --- a/Emby.Server.Implementations/Localization/Core/es-AR.json +++ b/Emby.Server.Implementations/Localization/Core/es-AR.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Latest", "ValueSpecialEpisodeName": "Special - {0}", "Inherit": "Inherit", diff --git a/Emby.Server.Implementations/Localization/Core/es-MX.json b/Emby.Server.Implementations/Localization/Core/es-MX.json index 851c82609c..45c4c1158c 100644 --- a/Emby.Server.Implementations/Localization/Core/es-MX.json +++ b/Emby.Server.Implementations/Localization/Core/es-MX.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Subidos desde Camara", "Latest": "Recientes", "ValueSpecialEpisodeName": "Especial - {0}", "Inherit": "Heredar", diff --git a/Emby.Server.Implementations/Localization/Core/es.json b/Emby.Server.Implementations/Localization/Core/es.json index 632113d759..4179d6b22d 100644 --- a/Emby.Server.Implementations/Localization/Core/es.json +++ b/Emby.Server.Implementations/Localization/Core/es.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "\u00daltimos", "ValueSpecialEpisodeName": "Especial - {0}", "Inherit": "Heredar", diff --git a/Emby.Server.Implementations/Localization/Core/fr-CA.json b/Emby.Server.Implementations/Localization/Core/fr-CA.json index ef9f059105..4348fddaeb 100644 --- a/Emby.Server.Implementations/Localization/Core/fr-CA.json +++ b/Emby.Server.Implementations/Localization/Core/fr-CA.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Latest", "ValueSpecialEpisodeName": "Sp\u00e9cial - {0}", "Inherit": "Inherit", diff --git a/Emby.Server.Implementations/Localization/Core/fr.json b/Emby.Server.Implementations/Localization/Core/fr.json index 5b16255c6d..d19d6e5f63 100644 --- a/Emby.Server.Implementations/Localization/Core/fr.json +++ b/Emby.Server.Implementations/Localization/Core/fr.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Derniers", "ValueSpecialEpisodeName": "Sp\u00e9cial - {0}", "Inherit": "H\u00e9riter", diff --git a/Emby.Server.Implementations/Localization/Core/gsw.json b/Emby.Server.Implementations/Localization/Core/gsw.json index e018b11e00..480e5cbcda 100644 --- a/Emby.Server.Implementations/Localization/Core/gsw.json +++ b/Emby.Server.Implementations/Localization/Core/gsw.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Letschte", "ValueSpecialEpisodeName": "Spezial - {0}", "Inherit": "Hinzuef\u00fcege", diff --git a/Emby.Server.Implementations/Localization/Core/he.json b/Emby.Server.Implementations/Localization/Core/he.json index 6b36cb6d34..14920b7ccc 100644 --- a/Emby.Server.Implementations/Localization/Core/he.json +++ b/Emby.Server.Implementations/Localization/Core/he.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "\u05d0\u05d7\u05e8\u05d5\u05df", "ValueSpecialEpisodeName": "\u05de\u05d9\u05d5\u05d7\u05d3- {0}", "Inherit": "Inherit", diff --git a/Emby.Server.Implementations/Localization/Core/hr.json b/Emby.Server.Implementations/Localization/Core/hr.json index c688c1b8a6..3a23698b58 100644 --- a/Emby.Server.Implementations/Localization/Core/hr.json +++ b/Emby.Server.Implementations/Localization/Core/hr.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Najnovije", "ValueSpecialEpisodeName": "Specijal - {0}", "Inherit": "Naslijedi", diff --git a/Emby.Server.Implementations/Localization/Core/hu.json b/Emby.Server.Implementations/Localization/Core/hu.json index 292ca595e7..27a573b58c 100644 --- a/Emby.Server.Implementations/Localization/Core/hu.json +++ b/Emby.Server.Implementations/Localization/Core/hu.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Leg\u00fajabb", "ValueSpecialEpisodeName": "Special - {0}", "Inherit": "Inherit", diff --git a/Emby.Server.Implementations/Localization/Core/it.json b/Emby.Server.Implementations/Localization/Core/it.json index 15952ca09a..0697582d46 100644 --- a/Emby.Server.Implementations/Localization/Core/it.json +++ b/Emby.Server.Implementations/Localization/Core/it.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Pi\u00f9 recenti", "ValueSpecialEpisodeName": "Speciale - {0}", "Inherit": "Eredita", diff --git a/Emby.Server.Implementations/Localization/Core/kk.json b/Emby.Server.Implementations/Localization/Core/kk.json index d64e99aeba..0329234520 100644 --- a/Emby.Server.Implementations/Localization/Core/kk.json +++ b/Emby.Server.Implementations/Localization/Core/kk.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "\u0415\u04a3 \u043a\u0435\u0439\u0456\u043d\u0433\u0456", "ValueSpecialEpisodeName": "\u0410\u0440\u043d\u0430\u0439\u044b - {0}", "Inherit": "\u041c\u04b1\u0440\u0430\u0493\u0430 \u0438\u0435\u043b\u0435\u043d\u0443", diff --git a/Emby.Server.Implementations/Localization/Core/ko.json b/Emby.Server.Implementations/Localization/Core/ko.json index cf81e24340..67dc635be9 100644 --- a/Emby.Server.Implementations/Localization/Core/ko.json +++ b/Emby.Server.Implementations/Localization/Core/ko.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Latest", "ValueSpecialEpisodeName": "Special - {0}", "Inherit": "Inherit", diff --git a/Emby.Server.Implementations/Localization/Core/lt-LT.json b/Emby.Server.Implementations/Localization/Core/lt-LT.json index 2800afbb69..1e4e187edf 100644 --- a/Emby.Server.Implementations/Localization/Core/lt-LT.json +++ b/Emby.Server.Implementations/Localization/Core/lt-LT.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Latest", "ValueSpecialEpisodeName": "Ypatinga - {0}", "Inherit": "Inherit", diff --git a/Emby.Server.Implementations/Localization/Core/ms.json b/Emby.Server.Implementations/Localization/Core/ms.json index 5d79ed8111..84e7d60b1a 100644 --- a/Emby.Server.Implementations/Localization/Core/ms.json +++ b/Emby.Server.Implementations/Localization/Core/ms.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Latest", "ValueSpecialEpisodeName": "Special - {0}", "Inherit": "Inherit", diff --git a/Emby.Server.Implementations/Localization/Core/nb.json b/Emby.Server.Implementations/Localization/Core/nb.json index d4c60b0d2e..22b02d2090 100644 --- a/Emby.Server.Implementations/Localization/Core/nb.json +++ b/Emby.Server.Implementations/Localization/Core/nb.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Siste", "ValueSpecialEpisodeName": "Spesial - {0}", "Inherit": "Arve", diff --git a/Emby.Server.Implementations/Localization/Core/nl.json b/Emby.Server.Implementations/Localization/Core/nl.json index 7bed4f47bc..cc0364a597 100644 --- a/Emby.Server.Implementations/Localization/Core/nl.json +++ b/Emby.Server.Implementations/Localization/Core/nl.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Nieuwste", "ValueSpecialEpisodeName": "Speciaal - {0}", "Inherit": "Overerven", diff --git a/Emby.Server.Implementations/Localization/Core/pl.json b/Emby.Server.Implementations/Localization/Core/pl.json index 0d311f558d..604019480d 100644 --- a/Emby.Server.Implementations/Localization/Core/pl.json +++ b/Emby.Server.Implementations/Localization/Core/pl.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Ostatnio dodane do", "ValueSpecialEpisodeName": "Specjalne - {0}", "Inherit": "Dziedzicz", diff --git a/Emby.Server.Implementations/Localization/Core/pt-BR.json b/Emby.Server.Implementations/Localization/Core/pt-BR.json index f29a62d494..aa68d099e2 100644 --- a/Emby.Server.Implementations/Localization/Core/pt-BR.json +++ b/Emby.Server.Implementations/Localization/Core/pt-BR.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Recente", "ValueSpecialEpisodeName": "Especial - {0}", "Inherit": "Herdar", diff --git a/Emby.Server.Implementations/Localization/Core/pt-PT.json b/Emby.Server.Implementations/Localization/Core/pt-PT.json index 250d3eb9d4..7300b25f32 100644 --- a/Emby.Server.Implementations/Localization/Core/pt-PT.json +++ b/Emby.Server.Implementations/Localization/Core/pt-PT.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Latest", "ValueSpecialEpisodeName": "Especial - {0}", "Inherit": "Inherit", diff --git a/Emby.Server.Implementations/Localization/Core/ru.json b/Emby.Server.Implementations/Localization/Core/ru.json index a1a1003f1a..07956920eb 100644 --- a/Emby.Server.Implementations/Localization/Core/ru.json +++ b/Emby.Server.Implementations/Localization/Core/ru.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "\u041d\u043e\u0432\u0435\u0439\u0448\u0435\u0435", "ValueSpecialEpisodeName": "\u0421\u043f\u0435\u0446\u044d\u043f\u0438\u0437\u043e\u0434 - {0}", "Inherit": "\u041d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u043e\u0435", diff --git a/Emby.Server.Implementations/Localization/Core/sk.json b/Emby.Server.Implementations/Localization/Core/sk.json index 7fa98e287f..2b6e9564fd 100644 --- a/Emby.Server.Implementations/Localization/Core/sk.json +++ b/Emby.Server.Implementations/Localization/Core/sk.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Najnov\u0161ie", "ValueSpecialEpisodeName": "\u0160peci\u00e1l - {0}", "Inherit": "Zdedi\u0165", diff --git a/Emby.Server.Implementations/Localization/Core/sl-SI.json b/Emby.Server.Implementations/Localization/Core/sl-SI.json index 8d2138965c..79f11c033a 100644 --- a/Emby.Server.Implementations/Localization/Core/sl-SI.json +++ b/Emby.Server.Implementations/Localization/Core/sl-SI.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Latest", "ValueSpecialEpisodeName": "Special - {0}", "Inherit": "Inherit", diff --git a/Emby.Server.Implementations/Localization/Core/sv.json b/Emby.Server.Implementations/Localization/Core/sv.json index 4264e3061a..a00e187ff5 100644 --- a/Emby.Server.Implementations/Localization/Core/sv.json +++ b/Emby.Server.Implementations/Localization/Core/sv.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Senaste", "ValueSpecialEpisodeName": "Specialavsnitt - {0}", "Inherit": "\u00c4rv", diff --git a/Emby.Server.Implementations/Localization/Core/tr.json b/Emby.Server.Implementations/Localization/Core/tr.json index 77af87d648..29efb1f447 100644 --- a/Emby.Server.Implementations/Localization/Core/tr.json +++ b/Emby.Server.Implementations/Localization/Core/tr.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Latest", "ValueSpecialEpisodeName": "Special - {0}", "Inherit": "Inherit", diff --git a/Emby.Server.Implementations/Localization/Core/zh-CN.json b/Emby.Server.Implementations/Localization/Core/zh-CN.json index 9e0a38ccec..e88caf96a4 100644 --- a/Emby.Server.Implementations/Localization/Core/zh-CN.json +++ b/Emby.Server.Implementations/Localization/Core/zh-CN.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "\u6700\u65b0", "ValueSpecialEpisodeName": "\u7279\u5178 - {0}", "Inherit": "\u7ee7\u627f", diff --git a/Emby.Server.Implementations/Localization/Core/zh-HK.json b/Emby.Server.Implementations/Localization/Core/zh-HK.json index 6a4311db58..6efb431bda 100644 --- a/Emby.Server.Implementations/Localization/Core/zh-HK.json +++ b/Emby.Server.Implementations/Localization/Core/zh-HK.json @@ -1,4 +1,5 @@ { + "HeaderCameraUploads": "Camera Uploads", "Latest": "Latest", "ValueSpecialEpisodeName": "Special - {0}", "Inherit": "Inherit", diff --git a/Emby.Server.Implementations/Logging/SimpleLogManager.cs b/Emby.Server.Implementations/Logging/SimpleLogManager.cs index caf05cc08b..390814c34e 100644 --- a/Emby.Server.Implementations/Logging/SimpleLogManager.cs +++ b/Emby.Server.Implementations/Logging/SimpleLogManager.cs @@ -150,7 +150,6 @@ public void Dispose() } _fileLogger = null; - GC.SuppressFinalize(this); } } @@ -244,8 +243,6 @@ public void Dispose() stream.Flush(true); } } - - GC.SuppressFinalize(this); } } diff --git a/Emby.Server.Implementations/Net/DisposableManagedObjectBase.cs b/Emby.Server.Implementations/Net/DisposableManagedObjectBase.cs index b18335da77..b721e8a262 100644 --- a/Emby.Server.Implementations/Net/DisposableManagedObjectBase.cs +++ b/Emby.Server.Implementations/Net/DisposableManagedObjectBase.cs @@ -54,16 +54,9 @@ public bool IsDisposed /// public void Dispose() { - try - { - IsDisposed = true; + IsDisposed = true; - Dispose(true); - } - finally - { - GC.SuppressFinalize(this); - } + Dispose(true); } #endregion diff --git a/Emby.Server.Implementations/News/NewsEntryPoint.cs b/Emby.Server.Implementations/News/NewsEntryPoint.cs index 8c218a5d57..84e7ee5fbf 100644 --- a/Emby.Server.Implementations/News/NewsEntryPoint.cs +++ b/Emby.Server.Implementations/News/NewsEntryPoint.cs @@ -274,7 +274,6 @@ public void Dispose() _timer.Dispose(); _timer = null; } - GC.SuppressFinalize(this); } } } diff --git a/Emby.Server.Implementations/Notifications/Notifications.cs b/Emby.Server.Implementations/Notifications/Notifications.cs index 0eaf54ea39..222d5aac0f 100644 --- a/Emby.Server.Implementations/Notifications/Notifications.cs +++ b/Emby.Server.Implementations/Notifications/Notifications.cs @@ -551,7 +551,6 @@ public void Dispose() _deviceManager.CameraImageUploaded -= _deviceManager_CameraImageUploaded; _userManager.UserLockedOut -= _userManager_UserLockedOut; - GC.SuppressFinalize(this); } private void DisposeLibraryUpdateTimer() diff --git a/Emby.Server.Implementations/Notifications/WebSocketNotifier.cs b/Emby.Server.Implementations/Notifications/WebSocketNotifier.cs index 6e57e7f816..d9f1d15270 100644 --- a/Emby.Server.Implementations/Notifications/WebSocketNotifier.cs +++ b/Emby.Server.Implementations/Notifications/WebSocketNotifier.cs @@ -50,7 +50,6 @@ void _notificationsRepo_NotificationAdded(object sender, NotificationUpdateEvent public void Dispose() { _notificationsRepo.NotificationAdded -= _notificationsRepo_NotificationAdded; - GC.SuppressFinalize(this); } } } diff --git a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs index b2fa0da165..f6397b6700 100644 --- a/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs +++ b/Emby.Server.Implementations/ScheduledTasks/ScheduledTaskWorker.cs @@ -645,7 +645,6 @@ private void OnTaskCompleted(DateTime startTime, DateTime endTime, TaskCompletio public void Dispose() { Dispose(true); - GC.SuppressFinalize(this); } /// diff --git a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs index 69f531c365..475f425c10 100644 --- a/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs +++ b/Emby.Server.Implementations/ScheduledTasks/TaskManager.cs @@ -297,7 +297,6 @@ public void AddTasks(IEnumerable tasks) public void Dispose() { Dispose(true); - GC.SuppressFinalize(this); } /// diff --git a/Emby.Server.Implementations/ServerManager/ServerManager.cs b/Emby.Server.Implementations/ServerManager/ServerManager.cs index b267f928b6..a20e9c39ac 100644 --- a/Emby.Server.Implementations/ServerManager/ServerManager.cs +++ b/Emby.Server.Implementations/ServerManager/ServerManager.cs @@ -330,7 +330,6 @@ public void Dispose() _disposed = true; Dispose(true); - GC.SuppressFinalize(this); } /// diff --git a/Emby.Server.Implementations/ServerManager/WebSocketConnection.cs b/Emby.Server.Implementations/ServerManager/WebSocketConnection.cs index f0553c3edc..e0a0c43f33 100644 --- a/Emby.Server.Implementations/ServerManager/WebSocketConnection.cs +++ b/Emby.Server.Implementations/ServerManager/WebSocketConnection.cs @@ -248,7 +248,6 @@ public WebSocketState State public void Dispose() { Dispose(true); - GC.SuppressFinalize(this); } /// diff --git a/Emby.Server.Implementations/Services/ServiceExec.cs b/Emby.Server.Implementations/Services/ServiceExec.cs index 4fbc1052c2..b77ff2e2c5 100644 --- a/Emby.Server.Implementations/Services/ServiceExec.cs +++ b/Emby.Server.Implementations/Services/ServiceExec.cs @@ -112,8 +112,6 @@ private static object GetTaskResult(Task task) return taskObject.Result; } - //task.Wait(); - var type = task.GetType().GetTypeInfo(); if (!type.IsGenericType) { diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.cs index 26fec94a56..4392889b75 100644 --- a/Emby.Server.Implementations/Session/SessionManager.cs +++ b/Emby.Server.Implementations/Session/SessionManager.cs @@ -285,7 +285,7 @@ public void ReportSessionEnded(string sessionId) } } - private Task GetMediaSource(IHasMediaSources item, string mediaSourceId, string liveStreamId) + private Task GetMediaSource(BaseItem item, string mediaSourceId, string liveStreamId) { return _mediaSourceManager.GetMediaSource(item, mediaSourceId, liveStreamId, false, CancellationToken.None); } @@ -312,7 +312,7 @@ private async Task UpdateNowPlayingItem(SessionInfo session, PlaybackProgressInf var hasMediaSources = libraryItem as IHasMediaSources; if (hasMediaSources != null) { - mediaSource = await GetMediaSource(hasMediaSources, info.MediaSourceId, info.LiveStreamId).ConfigureAwait(false); + mediaSource = await GetMediaSource(libraryItem, info.MediaSourceId, info.LiveStreamId).ConfigureAwait(false); if (mediaSource != null) { @@ -784,7 +784,7 @@ public async Task OnPlaybackStopped(PlaybackStopInfo info) var hasMediaSources = libraryItem as IHasMediaSources; if (hasMediaSources != null) { - mediaSource = await GetMediaSource(hasMediaSources, info.MediaSourceId, info.LiveStreamId).ConfigureAwait(false); + mediaSource = await GetMediaSource(libraryItem, info.MediaSourceId, info.LiveStreamId).ConfigureAwait(false); } info.Item = GetItemInfo(libraryItem, mediaSource); diff --git a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs index 903dc6ec1c..dffa79ef7f 100644 --- a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs +++ b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs @@ -93,7 +93,6 @@ private SessionInfo GetSession(QueryParamCollection queryString, string remoteEn public void Dispose() { _serverManager.WebSocketConnected -= _serverManager_WebSocketConnected; - GC.SuppressFinalize(this); } /// diff --git a/Emby.Server.Implementations/Session/WebSocketController.cs b/Emby.Server.Implementations/Session/WebSocketController.cs index b1085443a0..b61fb19242 100644 --- a/Emby.Server.Implementations/Session/WebSocketController.cs +++ b/Emby.Server.Implementations/Session/WebSocketController.cs @@ -105,7 +105,6 @@ public void Dispose() { socket.Closed -= connection_Closed; } - GC.SuppressFinalize(this); } } } diff --git a/Emby.Server.Implementations/TV/TVSeriesManager.cs b/Emby.Server.Implementations/TV/TVSeriesManager.cs index 74d1687214..afefe6d66b 100644 --- a/Emby.Server.Implementations/TV/TVSeriesManager.cs +++ b/Emby.Server.Implementations/TV/TVSeriesManager.cs @@ -37,7 +37,6 @@ public QueryResult GetNextUp(NextUpQuery request, DtoOptions dtoOption } string presentationUniqueKey = null; - int? limit = null; if (!string.IsNullOrEmpty(request.SeriesId)) { var series = _libraryManager.GetItemById(request.SeriesId) as Series; @@ -45,7 +44,6 @@ public QueryResult GetNextUp(NextUpQuery request, DtoOptions dtoOption if (series != null) { presentationUniqueKey = GetUniqueSeriesKey(series); - limit = 1; } } diff --git a/Emby.Server.Implementations/Threading/CommonTimer.cs b/Emby.Server.Implementations/Threading/CommonTimer.cs index bb67325d14..9451b07f32 100644 --- a/Emby.Server.Implementations/Threading/CommonTimer.cs +++ b/Emby.Server.Implementations/Threading/CommonTimer.cs @@ -31,7 +31,6 @@ public void Change(int dueTimeMs, int periodMs) public void Dispose() { _timer.Dispose(); - GC.SuppressFinalize(this); } } } diff --git a/Emby.Server.Implementations/Udp/UdpServer.cs b/Emby.Server.Implementations/Udp/UdpServer.cs index 28de80da16..f195ca7104 100644 --- a/Emby.Server.Implementations/Udp/UdpServer.cs +++ b/Emby.Server.Implementations/Udp/UdpServer.cs @@ -234,7 +234,6 @@ private void OnMessageReceived(SocketReceiveResult message) public void Dispose() { Dispose(true); - GC.SuppressFinalize(this); } /// diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index 3da2d21634..a37ad87668 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -673,7 +673,6 @@ protected virtual void Dispose(bool dispose) public void Dispose() { Dispose(true); - GC.SuppressFinalize(this); } } } diff --git a/Emby.Server.Implementations/UserViews/CollectionFolderImageProvider.cs b/Emby.Server.Implementations/UserViews/CollectionFolderImageProvider.cs index 4bffd9b5e8..782ac4b05f 100644 --- a/Emby.Server.Implementations/UserViews/CollectionFolderImageProvider.cs +++ b/Emby.Server.Implementations/UserViews/CollectionFolderImageProvider.cs @@ -55,6 +55,14 @@ protected override List GetItemsWithImages(BaseItem item) { includeItemTypes = new string[] { "Game" }; } + else if (string.Equals(viewType, CollectionType.BoxSets)) + { + includeItemTypes = new string[] { "BoxSet" }; + } + else if (string.Equals(viewType, CollectionType.HomeVideos) || string.Equals(viewType, CollectionType.Photos)) + { + includeItemTypes = new string[] { "Video", "Photo" }; + } else { includeItemTypes = new string[] { "Video", "Audio", "Photo", "Movie", "Series" }; @@ -100,51 +108,4 @@ protected override string CreateImage(BaseItem item, List itemsWithIma return base.CreateImage(item, itemsWithImages, outputPath, imageType, imageIndex); } } - - public class ManualCollectionFolderImageProvider : BaseDynamicImageProvider - { - private readonly ILibraryManager _libraryManager; - - public ManualCollectionFolderImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor, ILibraryManager libraryManager) : base(fileSystem, providerManager, applicationPaths, imageProcessor) - { - _libraryManager = libraryManager; - } - - protected override List GetItemsWithImages(BaseItem item) - { - var view = (ManualCollectionsFolder)item; - - return _libraryManager.GetItemList(new InternalItemsQuery - { - IncludeItemTypes = new[] { typeof(BoxSet).Name }, - Limit = 4, - OrderBy = new[] { new Tuple(ItemSortBy.Random, SortOrder.Ascending) }, - ImageTypes = new ImageType[] { ImageType.Primary }, - DtoOptions = new DtoOptions(false) - }); - } - - protected override bool Supports(BaseItem item) - { - return item is ManualCollectionsFolder; - } - - protected override string CreateImage(BaseItem item, List itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex) - { - var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ".png"); - - if (imageType == ImageType.Primary) - { - if (itemsWithImages.Count == 0) - { - return null; - } - - return CreateThumbCollage(item, itemsWithImages, outputPath, 960, 540); - } - - return base.CreateImage(item, itemsWithImages, outputPath, imageType, imageIndex); - } - } - } diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index 04cef60bfc..2ab5e315e6 100644 --- a/MediaBrowser.Api/ApiEntryPoint.cs +++ b/MediaBrowser.Api/ApiEntryPoint.cs @@ -88,7 +88,6 @@ public void Run() public void Dispose() { - GC.SuppressFinalize(this); } } } diff --git a/MediaBrowser.Api/BrandingService.cs b/MediaBrowser.Api/BrandingService.cs index 4602f56ed9..f89295ac9e 100644 --- a/MediaBrowser.Api/BrandingService.cs +++ b/MediaBrowser.Api/BrandingService.cs @@ -26,17 +26,15 @@ public BrandingService(IConfigurationManager config) public object Get(GetBrandingOptions request) { - var result = _config.GetConfiguration("branding"); - - return ToOptimizedResult(result); + return _config.GetConfiguration("branding"); } public object Get(GetBrandingCss request) { var result = _config.GetConfiguration("branding"); - // When null this throws a 405 error under Mono OSX, so default to empty string - return ResultFactory.GetResult(result.CustomCss ?? string.Empty, "text/css"); + // When null this throws a 405 error under Mono OSX, so default to empty string + return ResultFactory.GetResult(result.CustomCss ?? string.Empty, "text/css"); } } } diff --git a/MediaBrowser.Api/ChannelService.cs b/MediaBrowser.Api/ChannelService.cs index fa2dbb5f8c..34975b0930 100644 --- a/MediaBrowser.Api/ChannelService.cs +++ b/MediaBrowser.Api/ChannelService.cs @@ -233,7 +233,7 @@ public async Task Get(GetChannelItems request) { Limit = request.Limit, StartIndex = request.StartIndex, - ChannelIds = new string[] { request.Id }, + ChannelIds = new Guid[] { new Guid(request.Id) }, ParentId = string.IsNullOrWhiteSpace(request.FolderId) ? (Guid?)null : new Guid(request.FolderId), OrderBy = request.GetOrderBy(), DtoOptions = new Controller.Dto.DtoOptions @@ -292,7 +292,7 @@ public async Task Get(GetLatestChannelItems request) { Limit = request.Limit, StartIndex = request.StartIndex, - ChannelIds = (request.ChannelIds ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToArray(), + ChannelIds = (request.ChannelIds ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => new Guid(i)).ToArray(), DtoOptions = new Controller.Dto.DtoOptions { Fields = request.GetItemFields() diff --git a/MediaBrowser.Api/Dlna/DlnaService.cs b/MediaBrowser.Api/Dlna/DlnaService.cs index 4dd71f4463..12d5994b58 100644 --- a/MediaBrowser.Api/Dlna/DlnaService.cs +++ b/MediaBrowser.Api/Dlna/DlnaService.cs @@ -52,23 +52,17 @@ public DlnaService(IDlnaManager dlnaManager) public object Get(GetProfileInfos request) { - var result = _dlnaManager.GetProfileInfos().ToArray(); - - return ToOptimizedResult(result); + return _dlnaManager.GetProfileInfos().ToArray(); } public object Get(GetProfile request) { - var result = _dlnaManager.GetProfile(request.Id); - - return ToOptimizedResult(result); + return _dlnaManager.GetProfile(request.Id); } public object Get(GetDefaultProfile request) { - var result = _dlnaManager.GetDefaultProfile(); - - return ToOptimizedResult(result); + return _dlnaManager.GetDefaultProfile(); } public void Delete(DeleteProfile request) diff --git a/MediaBrowser.Api/FilterService.cs b/MediaBrowser.Api/FilterService.cs index 83144a772c..110130d083 100644 --- a/MediaBrowser.Api/FilterService.cs +++ b/MediaBrowser.Api/FilterService.cs @@ -126,7 +126,7 @@ public object Get(GetQueryFilters request) // Non recursive not yet supported for library folders if ((request.Recursive ?? true) || parentItem is UserView || parentItem is ICollectionFolder) { - genreQuery.AncestorIds = parentItem == null ? new string[] { } : new string[] { parentItem.Id.ToString("N") }; + genreQuery.AncestorIds = parentItem == null ? new Guid[] { } : new Guid[] { parentItem.Id }; } else { diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs index 20759e7db3..4222f1e496 100644 --- a/MediaBrowser.Api/Images/ImageService.cs +++ b/MediaBrowser.Api/Images/ImageService.cs @@ -373,11 +373,7 @@ private ImageInfo GetImageInfo(BaseItem item, ItemImageInfo info, int? imageInde /// System.Object. public object Get(GetItemImage request) { - var item = string.IsNullOrEmpty(request.Id) ? - _libraryManager.RootFolder : - _libraryManager.GetItemById(request.Id); - - return GetImage(request, item, false); + return GetImage(request, request.Id, null, false); } /// @@ -387,11 +383,7 @@ public object Get(GetItemImage request) /// System.Object. public object Head(GetItemImage request) { - var item = string.IsNullOrEmpty(request.Id) ? - _libraryManager.RootFolder : - _libraryManager.GetItemById(request.Id); - - return GetImage(request, item, true); + return GetImage(request, request.Id, null, true); } /// @@ -403,14 +395,14 @@ public object Get(GetUserImage request) { var item = _userManager.GetUserById(request.Id); - return GetImage(request, item, false); + return GetImage(request, null, item, false); } public object Head(GetUserImage request) { var item = _userManager.GetUserById(request.Id); - return GetImage(request, item, true); + return GetImage(request, null, item, true); } public object Get(GetItemByNameImage request) @@ -419,7 +411,7 @@ public object Get(GetItemByNameImage request) var item = GetItemByName(request.Name, type, _libraryManager, new DtoOptions(false)); - return GetImage(request, item, false); + return GetImage(request, item.Id.ToString("N"), item, false); } public object Head(GetItemByNameImage request) @@ -428,7 +420,7 @@ public object Head(GetItemByNameImage request) var item = GetItemByName(request.Name, type, _libraryManager, new DtoOptions(false)); - return GetImage(request, item, true); + return GetImage(request, item.Id.ToString("N"), item, true); } /// @@ -519,7 +511,7 @@ private void UpdateItemIndex(BaseItem item, ImageType type, int currentIndex, in /// if set to true [is head request]. /// System.Object. /// - public Task GetImage(ImageRequest request, BaseItem item, bool isHeadRequest) + public Task GetImage(ImageRequest request, string itemId, BaseItem item, bool isHeadRequest) { if (request.PercentPlayed.HasValue) { @@ -545,14 +537,34 @@ public Task GetImage(ImageRequest request, BaseItem item, bool isHeadReq } } + if (item == null) + { + item = _libraryManager.GetItemById(itemId); + } + var imageInfo = GetImageInfo(request, item); if (imageInfo == null) { - throw new ResourceNotFoundException(string.Format("{0} does not have an image of type {1}", item.Name, request.Type)); + var displayText = item == null ? itemId : item.Name; + throw new ResourceNotFoundException(string.Format("{0} does not have an image of type {1}", displayText, request.Type)); } - var supportedImageEnhancers = request.EnableImageEnhancers ? _imageProcessor.GetSupportedEnhancers(item, request.Type) : new List(); + List supportedImageEnhancers; + + if (_imageProcessor.ImageEnhancers.Length > 0) + { + if (item == null) + { + item = _libraryManager.GetItemById(itemId); + } + + supportedImageEnhancers = request.EnableImageEnhancers ? _imageProcessor.GetSupportedEnhancers(item, request.Type) : new List(); + } + else + { + supportedImageEnhancers = new List(); + } var cropwhitespace = request.Type == ImageType.Logo || request.Type == ImageType.Art; @@ -578,6 +590,7 @@ public Task GetImage(ImageRequest request, BaseItem item, bool isHeadReq }; return GetImageResult(item, + itemId, request, imageInfo, cropwhitespace, @@ -589,6 +602,7 @@ public Task GetImage(ImageRequest request, BaseItem item, bool isHeadReq } private async Task GetImageResult(BaseItem item, + string itemId, ImageRequest request, ItemImageInfo image, bool cropwhitespace, @@ -606,8 +620,7 @@ private async Task GetImageResult(BaseItem item, ImageIndex = request.Index ?? 0, Image = image, Item = item, - ItemId = item.Id.ToString("N"), - ItemType = item.GetType().Name, + ItemId = itemId, MaxHeight = request.MaxHeight, MaxWidth = request.MaxWidth, Quality = request.Quality ?? 100, diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index c9aa8d52ee..9574c3b4dd 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -611,7 +611,7 @@ public object Get(GetMediaFolders request) Items = items.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions)).ToArray() }; - return ToOptimizedResult(result); + return result; } public void Post(PostUpdatedSeries request) diff --git a/MediaBrowser.Api/Library/LibraryStructureService.cs b/MediaBrowser.Api/Library/LibraryStructureService.cs index 0bafc41a8b..fc624b93ab 100644 --- a/MediaBrowser.Api/Library/LibraryStructureService.cs +++ b/MediaBrowser.Api/Library/LibraryStructureService.cs @@ -224,7 +224,7 @@ public void Post(UpdateLibraryOptions request) /// Posts the specified request. /// /// The request. - public void Post(AddVirtualFolder request) + public Task Post(AddVirtualFolder request) { var libraryOptions = request.LibraryOptions ?? new LibraryOptions(); @@ -233,7 +233,7 @@ public void Post(AddVirtualFolder request) libraryOptions.PathInfos = request.Paths.Select(i => new MediaPathInfo { Path = i }).ToArray(); } - _libraryManager.AddVirtualFolder(request.Name, request.CollectionType, libraryOptions, request.RefreshLibrary); + return _libraryManager.AddVirtualFolder(request.Name, request.CollectionType, libraryOptions, request.RefreshLibrary); } /// @@ -309,9 +309,9 @@ public void Post(RenameVirtualFolder request) /// Deletes the specified request. /// /// The request. - public void Delete(RemoveVirtualFolder request) + public Task Delete(RemoveVirtualFolder request) { - _libraryManager.RemoveVirtualFolder(request.Name, request.RefreshLibrary); + return _libraryManager.RemoveVirtualFolder(request.Name, request.RefreshLibrary); } /// diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index c0be8bfb63..466665d35a 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -413,6 +413,11 @@ public class GetPrograms : IReturn>, IHasDtoOptions [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] public string Fields { get; set; } + public Guid[] GetGuids(string value) + { + return (value ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(i => new Guid(i)).ToArray(); + } + public GetPrograms() { EnableTotalRecordCount = true; @@ -478,6 +483,11 @@ public GetRecommendedPrograms() [ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] public bool? EnableUserData { get; set; } + + public Guid[] GetGuids(string value) + { + return (value ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(i => new Guid(i)).ToArray(); + } } [Route("/LiveTv/Programs/{Id}", "GET", Summary = "Gets a live tv program")] @@ -1015,7 +1025,7 @@ public async Task Get(GetPrograms request) { var query = new ProgramQuery { - ChannelIds = ApiEntryPoint.Split(request.ChannelIds, ',', true), + ChannelIds = ApiEntryPoint.Split(request.ChannelIds, ',', true).Select(i => new Guid(i)).ToArray(), UserId = request.UserId, HasAired = request.HasAired, EnableTotalRecordCount = request.EnableTotalRecordCount @@ -1051,7 +1061,7 @@ public async Task Get(GetPrograms request) query.IsSports = request.IsSports; query.SeriesTimerId = request.SeriesTimerId; query.Genres = (request.Genres ?? String.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - query.GenreIds = (request.GenreIds ?? String.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); + query.GenreIds = request.GetGuids(request.GenreIds); if (!string.IsNullOrWhiteSpace(request.LibrarySeriesId)) { @@ -1085,7 +1095,7 @@ public object Get(GetRecommendedPrograms request) EnableTotalRecordCount = request.EnableTotalRecordCount }; - query.GenreIds = (request.GenreIds ?? String.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); + query.GenreIds = request.GetGuids(request.GenreIds); var result = _liveTvManager.GetRecommendedPrograms(query, GetDtoOptions(_authContext, request), CancellationToken.None); diff --git a/MediaBrowser.Api/Movies/CollectionService.cs b/MediaBrowser.Api/Movies/CollectionService.cs index 2a22b6c33f..62e0a90e87 100644 --- a/MediaBrowser.Api/Movies/CollectionService.cs +++ b/MediaBrowser.Api/Movies/CollectionService.cs @@ -77,10 +77,10 @@ public object Post(CreateCollection request) var dto = _dtoService.GetBaseItemDto(item, dtoOptions); - return ToOptimizedResult(new CollectionCreationResult + return new CollectionCreationResult { Id = dto.Id - }); + }; } public void Post(AddToCollection request) diff --git a/MediaBrowser.Api/Movies/MoviesService.cs b/MediaBrowser.Api/Movies/MoviesService.cs index 5a3e44062f..a83ee7a729 100644 --- a/MediaBrowser.Api/Movies/MoviesService.cs +++ b/MediaBrowser.Api/Movies/MoviesService.cs @@ -217,7 +217,7 @@ private IEnumerable GetRecommendationCategories(User user, st OrderBy = new[] { ItemSortBy.Random }.Select(i => new Tuple(i, SortOrder.Descending)).ToArray(), Limit = 10, IsFavoriteOrLiked = true, - ExcludeItemIds = recentlyPlayedMovies.Select(i => i.Id.ToString("N")).ToArray(recentlyPlayedMovies.Count), + ExcludeItemIds = recentlyPlayedMovies.Select(i => i.Id).ToArray(recentlyPlayedMovies.Count), EnableGroupByMetadataKey = true, ParentId = parentIdGuid, Recursive = true, diff --git a/MediaBrowser.Api/Music/InstantMixService.cs b/MediaBrowser.Api/Music/InstantMixService.cs index 8a18298f1e..1147a2fa62 100644 --- a/MediaBrowser.Api/Music/InstantMixService.cs +++ b/MediaBrowser.Api/Music/InstantMixService.cs @@ -200,7 +200,7 @@ private object GetResult(List items, User user, BaseGetSimilarItems re result.Items = returnList; - return ToOptimizedResult(result); + return result; } } diff --git a/MediaBrowser.Api/NotificationsService.cs b/MediaBrowser.Api/NotificationsService.cs index 1d60327ca6..49d5d7a82c 100644 --- a/MediaBrowser.Api/NotificationsService.cs +++ b/MediaBrowser.Api/NotificationsService.cs @@ -99,23 +99,17 @@ public NotificationsService(INotificationsRepository notificationsRepo, INotific public object Get(GetNotificationTypes request) { - var result = _notificationManager.GetNotificationTypes(); - - return ToOptimizedResult(result); + return _notificationManager.GetNotificationTypes(); } public object Get(GetNotificationServices request) { - var result = _notificationManager.GetNotificationServices().ToList(); - - return ToOptimizedResult(result); + return _notificationManager.GetNotificationServices().ToList(); } public object Get(GetNotificationsSummary request) { - var result = _notificationsRepo.GetNotificationsSummary(request.UserId); - - return ToOptimizedResult(result); + return _notificationsRepo.GetNotificationsSummary(request.UserId); } public Task Post(AddAdminNotification request) diff --git a/MediaBrowser.Api/Session/SessionsService.cs b/MediaBrowser.Api/Session/SessionsService.cs index fbc65f2dd0..b410dd87dc 100644 --- a/MediaBrowser.Api/Session/SessionsService.cs +++ b/MediaBrowser.Api/Session/SessionsService.cs @@ -295,7 +295,7 @@ public SessionsService(ISessionManager sessionManager, IServerApplicationHost ap public object Get(GetAuthProviders request) { - return ToOptimizedResult(_userManager.GetAuthenticationProviders()); + return _userManager.GetAuthenticationProviders(); } public void Delete(RevokeKey request) @@ -334,7 +334,7 @@ public object Get(GetApiKeys request) HasUser = false }); - return ToOptimizedResult(result); + return result; } /// diff --git a/MediaBrowser.Api/SimilarItemsHelper.cs b/MediaBrowser.Api/SimilarItemsHelper.cs index 22a07e8fdf..556208dd10 100644 --- a/MediaBrowser.Api/SimilarItemsHelper.cs +++ b/MediaBrowser.Api/SimilarItemsHelper.cs @@ -28,6 +28,11 @@ public class BaseGetSimilarItemsFromItem : BaseGetSimilarItems public string Id { get; set; } public string ExcludeArtistIds { get; set; } + + public Guid[] GetGuids(string value) + { + return (value ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(i => new Guid(i)).ToArray(); + } } public class BaseGetSimilarItems : IReturn>, IHasDtoOptions @@ -89,7 +94,7 @@ internal static QueryResult GetSimilarItemsResult(DtoOptions dtoOpt // ExcludeArtistIds if (!string.IsNullOrEmpty(request.ExcludeArtistIds)) { - query.ExcludeArtistIds = request.ExcludeArtistIds.Split('|'); + query.ExcludeArtistIds = request.GetGuids(request.ExcludeArtistIds); } var inputItems = libraryManager.GetItemList(query); diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.cs index d48f0e44af..7f7d7cbea0 100644 --- a/MediaBrowser.Api/StartupWizardService.cs +++ b/MediaBrowser.Api/StartupWizardService.cs @@ -74,7 +74,6 @@ public StartupWizardService(IServerConfigurationManager config, IHttpClient http public void Post(ReportStartupWizardComplete request) { _config.Configuration.IsStartupWizardCompleted = true; - _config.Configuration.AutoRunWebApp = true; _config.SetOptimalValues(); _config.SaveConfiguration(); diff --git a/MediaBrowser.Api/Subtitles/SubtitleService.cs b/MediaBrowser.Api/Subtitles/SubtitleService.cs index 18f1e10c58..73599343f5 100644 --- a/MediaBrowser.Api/Subtitles/SubtitleService.cs +++ b/MediaBrowser.Api/Subtitles/SubtitleService.cs @@ -237,7 +237,9 @@ public async Task Get(GetSubtitle request) private Task GetSubtitles(GetSubtitle request) { - return _subtitleEncoder.GetSubtitles(request.Id, + var item = _libraryManager.GetItemById(request.Id); + + return _subtitleEncoder.GetSubtitles(item, request.MediaSourceId, request.Index, request.Format, @@ -251,19 +253,19 @@ public async Task Get(SearchRemoteSubtitles request) { var video = (Video)_libraryManager.GetItemById(request.Id); - var response = await _subtitleManager.SearchSubtitles(video, request.Language, request.IsPerfectMatch, CancellationToken.None).ConfigureAwait(false); - - return ToOptimizedResult(response); + return await _subtitleManager.SearchSubtitles(video, request.Language, request.IsPerfectMatch, CancellationToken.None).ConfigureAwait(false); } public Task Delete(DeleteSubtitle request) { - return _subtitleManager.DeleteSubtitles(request.Id, request.Index); + var item = _libraryManager.GetItemById(request.Id); + return _subtitleManager.DeleteSubtitles(item, request.Index); } public object Get(GetSubtitleProviders request) { - var result = _subtitleManager.GetProviders(request.Id); + var item = _libraryManager.GetItemById(request.Id); + var result = _subtitleManager.GetProviders(item); return ToOptimizedResult(result); } diff --git a/MediaBrowser.Api/SuggestionsService.cs b/MediaBrowser.Api/SuggestionsService.cs index 3b918d8a2f..d456a004cc 100644 --- a/MediaBrowser.Api/SuggestionsService.cs +++ b/MediaBrowser.Api/SuggestionsService.cs @@ -51,9 +51,7 @@ public SuggestionsService(IDtoService dtoService, IAuthorizationContext authCont public object Get(GetSuggestedItems request) { - var result = GetResultItems(request); - - return ToOptimizedResult(result); + return GetResultItems(request); } private QueryResult GetResultItems(GetSuggestedItems request) diff --git a/MediaBrowser.Api/UserLibrary/ArtistsService.cs b/MediaBrowser.Api/UserLibrary/ArtistsService.cs index 4018759d99..a911d1c62d 100644 --- a/MediaBrowser.Api/UserLibrary/ArtistsService.cs +++ b/MediaBrowser.Api/UserLibrary/ArtistsService.cs @@ -56,9 +56,7 @@ public class ArtistsService : BaseItemsByNameService /// System.Object. public object Get(GetArtist request) { - var result = GetItem(request); - - return ToOptimizedResult(result); + return GetItem(request); } /// @@ -71,7 +69,7 @@ private BaseItemDto GetItem(GetArtist request) var dtoOptions = GetDtoOptions(AuthorizationContext, request); var item = GetArtist(request.Name, LibraryManager, dtoOptions); - + if (!string.IsNullOrWhiteSpace(request.UserId)) { var user = UserManager.GetUserById(request.UserId); @@ -94,9 +92,7 @@ public object Get(GetArtists request) //request.IncludeItemTypes = "Audio,MusicVideo"; } - var result = GetResultSlim(request); - - return ToOptimizedResult(result); + return GetResultSlim(request); } /// diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs index 1aaa4ce495..8bb13737dc 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs @@ -137,11 +137,11 @@ protected QueryResult GetResultSlim(GetItemsByName request) { if (parentItem is Folder) { - query.AncestorIds = new[] { request.ParentId }; + query.AncestorIds = new[] { new Guid(request.ParentId) }; } else { - query.ItemIds = new[] { request.ParentId }; + query.ItemIds = new[] { new Guid(request.ParentId) }; } } @@ -158,7 +158,7 @@ protected QueryResult GetResultSlim(GetItemsByName request) { return null; } - }).Where(i => i != null).Select(i => i.Id.ToString("N")).ToArray(); + }).Where(i => i != null).Select(i => i.Id).ToArray(); } foreach (var filter in request.GetFilters()) diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs index b1328421ef..4f41632161 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs @@ -366,9 +366,14 @@ public string[] GetIncludeItemTypes() return (IncludeItemTypes ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } - public string[] GetExcludeItemIds() + public Guid[] GetGuids(string value) { - return (ExcludeItemIds ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + return (value ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(i => new Guid(i)).ToArray(); + } + + public Guid[] GetExcludeItemIds() + { + return GetGuids(ExcludeItemIds); } public string[] GetExcludeItemTypes() @@ -386,19 +391,19 @@ public string[] GetStudios() return (Studios ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); } - public string[] GetArtistIds() + public Guid[] GetArtistIds() { - return (ArtistIds ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); + return GetGuids(ArtistIds); } - public string[] GetStudioIds() + public Guid[] GetStudioIds() { - return (StudioIds ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); + return GetGuids(StudioIds); } - public string[] GetGenreIds() + public Guid[] GetGenreIds() { - return (GenreIds ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); + return GetGuids(GenreIds); } public string[] GetPersonTypes() @@ -406,14 +411,14 @@ public string[] GetPersonTypes() return (PersonTypes ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); } - public string[] GetPersonIds() + public Guid[] GetPersonIds() { - return (PersonIds ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + return GetGuids(PersonIds); } - public string[] GetItemIds() + public Guid[] GetItemIds() { - return (Ids ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + return GetGuids(Ids); } public VideoType[] GetVideoTypes() diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index 3cd3468624..0cdd3443e4 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -92,7 +92,7 @@ public object Get(GetResumeItems request) var options = GetDtoOptions(_authContext, request); - var ancestorIds = new List(); + var ancestorIds = new List(); var excludeFolderIds = user.Configuration.LatestItemsExcludes; if (!parentIdGuid.HasValue && excludeFolderIds.Length > 0) @@ -100,7 +100,7 @@ public object Get(GetResumeItems request) ancestorIds = _libraryManager.GetUserRootFolder().GetChildren(user, true) .Where(i => i is Folder) .Where(i => !excludeFolderIds.Contains(i.Id.ToString("N"))) - .Select(i => i.Id.ToString("N")) + .Select(i => i.Id) .ToList(); } @@ -421,18 +421,18 @@ private InternalItemsQuery GetItemsQuery(GetItems request, DtoOptions dtoOptions { return null; } - }).Where(i => i != null).Select(i => i.Id.ToString("N")).ToArray(); + }).Where(i => i != null).Select(i => i.Id).ToArray(); } // ExcludeArtistIds if (!string.IsNullOrWhiteSpace(request.ExcludeArtistIds)) { - query.ExcludeArtistIds = request.ExcludeArtistIds.Split('|'); + query.ExcludeArtistIds = request.GetGuids(request.ExcludeArtistIds); } if (!string.IsNullOrWhiteSpace(request.AlbumIds)) { - query.AlbumIds = request.AlbumIds.Split('|'); + query.AlbumIds = request.GetGuids(request.AlbumIds); } // Albums @@ -446,7 +446,7 @@ private InternalItemsQuery GetItemsQuery(GetItems request, DtoOptions dtoOptions Name = i, Limit = 1 - }).Select(albumId => albumId.ToString("N")); + }).Select(albumId => albumId); }).ToArray(); } @@ -464,7 +464,7 @@ private InternalItemsQuery GetItemsQuery(GetItems request, DtoOptions dtoOptions { return null; } - }).Where(i => i != null).Select(i => i.Id.ToString("N")).ToArray(); + }).Where(i => i != null).Select(i => i.Id).ToArray(); } // Apply default sorting if none requested diff --git a/MediaBrowser.Api/UserLibrary/UserViewsService.cs b/MediaBrowser.Api/UserLibrary/UserViewsService.cs index 9110d43727..3e15f870f6 100644 --- a/MediaBrowser.Api/UserLibrary/UserViewsService.cs +++ b/MediaBrowser.Api/UserLibrary/UserViewsService.cs @@ -28,6 +28,7 @@ public class GetUserViews : IReturn> [ApiMember(Name = "IncludeExternalContent", Description = "Whether or not to include external views such as channels or live tv", IsRequired = true, DataType = "boolean", ParameterType = "query", Verb = "POST")] public bool? IncludeExternalContent { get; set; } + public bool IncludeHidden { get; set; } public string PresetViews { get; set; } } @@ -71,6 +72,7 @@ public object Get(GetUserViews request) { query.IncludeExternalContent = request.IncludeExternalContent.Value; } + query.IncludeHidden = request.IncludeHidden; if (!string.IsNullOrWhiteSpace(request.PresetViews)) { diff --git a/MediaBrowser.Common/Net/HttpResponseInfo.cs b/MediaBrowser.Common/Net/HttpResponseInfo.cs index 0d7fb69cb6..ed941a4474 100644 --- a/MediaBrowser.Common/Net/HttpResponseInfo.cs +++ b/MediaBrowser.Common/Net/HttpResponseInfo.cs @@ -70,7 +70,6 @@ public void Dispose() { _disposable.Dispose(); } - GC.SuppressFinalize(this); } } } diff --git a/MediaBrowser.Common/Progress/ActionableProgress.cs b/MediaBrowser.Common/Progress/ActionableProgress.cs index 5b318c6a78..503f3f407a 100644 --- a/MediaBrowser.Common/Progress/ActionableProgress.cs +++ b/MediaBrowser.Common/Progress/ActionableProgress.cs @@ -30,7 +30,6 @@ public void RegisterAction(Action action) public void Dispose() { Dispose(true); - GC.SuppressFinalize(this); } /// diff --git a/MediaBrowser.Controller/Channels/Channel.cs b/MediaBrowser.Controller/Channels/Channel.cs index ef19d06faa..87408f4856 100644 --- a/MediaBrowser.Controller/Channels/Channel.cs +++ b/MediaBrowser.Controller/Channels/Channel.cs @@ -52,7 +52,7 @@ protected override QueryResult GetItemsInternal(InternalItemsQuery que try { query.Parent = this; - query.ChannelIds = new string[] { Id.ToString("N") }; + query.ChannelIds = new Guid[] { Id }; // Don't blow up here because it could cause parent screens with other content to fail return ChannelManager.GetChannelItemsInternal(query, new SimpleProgress(), CancellationToken.None).Result; diff --git a/MediaBrowser.Controller/Collections/ICollectionManager.cs b/MediaBrowser.Controller/Collections/ICollectionManager.cs index a25fc8fc6a..05bc927ba0 100644 --- a/MediaBrowser.Controller/Collections/ICollectionManager.cs +++ b/MediaBrowser.Controller/Collections/ICollectionManager.cs @@ -53,19 +53,5 @@ public interface ICollectionManager /// The user. /// IEnumerable{BaseItem}. IEnumerable CollapseItemsWithinBoxSets(IEnumerable items, User user); - - /// - /// Gets the collections folder. - /// - /// The user identifier. - /// Folder. - Folder GetCollectionsFolder(string userId); - - /// - /// Gets the collections. - /// - /// The user. - /// IEnumerable<BoxSet>. - IEnumerable GetCollections(User user); } } diff --git a/MediaBrowser.Controller/Collections/ManualCollectionsFolder.cs b/MediaBrowser.Controller/Collections/ManualCollectionsFolder.cs deleted file mode 100644 index 38d2611f0f..0000000000 --- a/MediaBrowser.Controller/Collections/ManualCollectionsFolder.cs +++ /dev/null @@ -1,46 +0,0 @@ -using MediaBrowser.Controller.Entities; -using MediaBrowser.Model.Serialization; - -namespace MediaBrowser.Controller.Collections -{ - public class ManualCollectionsFolder : BasePluginFolder, IHiddenFromDisplay - { - public ManualCollectionsFolder() - { - Name = "Collections"; - } - - public override bool IsHidden - { - get - { - return true; - } - } - - [IgnoreDataMember] - public override bool SupportsInheritedParentImages - { - get - { - return false; - } - } - - public bool IsHiddenFromUser(User user) - { - return !ConfigurationManager.Configuration.DisplayCollectionsView; - } - - [IgnoreDataMember] - public override string CollectionType - { - get { return Model.Entities.CollectionType.BoxSets; } - } - - public override string GetClientTypeName() - { - return typeof(CollectionFolder).Name; - } - } -} \ No newline at end of file diff --git a/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs b/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs index 18824c67a9..8c2461594e 100644 --- a/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs +++ b/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs @@ -16,7 +16,6 @@ public ImageProcessingOptions() } public string ItemId { get; set; } - public string ItemType { get; set; } public BaseItem Item { get; set; } public ItemImageInfo Image { get; set; } diff --git a/MediaBrowser.Controller/Drawing/ImageStream.cs b/MediaBrowser.Controller/Drawing/ImageStream.cs index b5e14eb6c8..353abaca33 100644 --- a/MediaBrowser.Controller/Drawing/ImageStream.cs +++ b/MediaBrowser.Controller/Drawing/ImageStream.cs @@ -23,7 +23,6 @@ public void Dispose() { Stream.Dispose(); } - GC.SuppressFinalize(this); } } } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index 8760a8c43d..dbdadc7595 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -92,7 +92,7 @@ public IList GetTaggedItems(InternalItemsQuery query) if (query.IncludeItemTypes.Length == 0) { query.IncludeItemTypes = new[] { typeof(Audio).Name, typeof(MusicVideo).Name, typeof(MusicAlbum).Name }; - query.ArtistIds = new[] { Id.ToString("N") }; + query.ArtistIds = new[] { Id }; } return LibraryManager.GetItemList(query); diff --git a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs index d86274f9c9..6dd6a9b0b8 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs @@ -101,7 +101,7 @@ public override bool SupportsPeople public IList GetTaggedItems(InternalItemsQuery query) { - query.GenreIds = new[] { Id.ToString("N") }; + query.GenreIds = new[] { Id }; query.IncludeItemTypes = new[] { typeof(MusicVideo).Name, typeof(Audio).Name, typeof(MusicAlbum).Name, typeof(MusicArtist).Name }; return LibraryManager.GetItemList(query); diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 4c6f882136..02ae7cf74a 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -895,7 +895,7 @@ public QueryResult GetItems(InternalItemsQuery query) var ids = query.ItemIds.ToList(); // Try to preserve order - result.Items = result.Items.OrderBy(i => ids.IndexOf(i.Id.ToString("N"))).ToArray(); + result.Items = result.Items.OrderBy(i => ids.IndexOf(i.Id)).ToArray(); } return result; } @@ -916,7 +916,7 @@ public BaseItem[] GetItemList(InternalItemsQuery query) var ids = query.ItemIds.ToList(); // Try to preserve order - return result.OrderBy(i => ids.IndexOf(i.Id.ToString("N"))).ToArray(); + return result.OrderBy(i => ids.IndexOf(i.Id)).ToArray(); } return result.ToArray(result.Count); } @@ -931,7 +931,7 @@ protected virtual QueryResult GetItemsInternal(InternalItemsQuery quer try { query.Parent = this; - query.ChannelIds = new string[] { ChannelId }; + query.ChannelIds = new Guid[] { new Guid(ChannelId) }; // Don't blow up here because it could cause parent screens with other content to fail return ChannelManager.GetChannelItemsInternal(query, new SimpleProgress(), CancellationToken.None).Result; diff --git a/MediaBrowser.Controller/Entities/GameGenre.cs b/MediaBrowser.Controller/Entities/GameGenre.cs index 7644e21678..b26724a2b8 100644 --- a/MediaBrowser.Controller/Entities/GameGenre.cs +++ b/MediaBrowser.Controller/Entities/GameGenre.cs @@ -75,7 +75,7 @@ public override bool CanDelete() public IList GetTaggedItems(InternalItemsQuery query) { - query.GenreIds = new[] { Id.ToString("N") }; + query.GenreIds = new[] { Id }; query.IncludeItemTypes = new[] { typeof(Game).Name }; return LibraryManager.GetItemList(query); diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs index ca1ac0108d..5ba77e2511 100644 --- a/MediaBrowser.Controller/Entities/Genre.cs +++ b/MediaBrowser.Controller/Entities/Genre.cs @@ -87,7 +87,7 @@ public override bool IsOwnedItem public IList GetTaggedItems(InternalItemsQuery query) { - query.GenreIds = new[] { Id.ToString("N") }; + query.GenreIds = new[] { Id }; query.ExcludeItemTypes = new[] { typeof(Game).Name, typeof(MusicVideo).Name, typeof(Audio.Audio).Name, typeof(MusicAlbum).Name, typeof(MusicArtist).Name }; return LibraryManager.GetItemList(query); diff --git a/MediaBrowser.Controller/Entities/IHiddenFromDisplay.cs b/MediaBrowser.Controller/Entities/IHiddenFromDisplay.cs deleted file mode 100644 index ba6311296a..0000000000 --- a/MediaBrowser.Controller/Entities/IHiddenFromDisplay.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace MediaBrowser.Controller.Entities -{ - public interface IHiddenFromDisplay - { - /// - /// Determines whether the specified user is hidden. - /// - /// The user. - /// true if the specified user is hidden; otherwise, false. - bool IsHiddenFromUser(User user); - } -} diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index eb8a557042..5daa530f0d 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -52,9 +52,9 @@ public class InternalItemsQuery public string Name { get; set; } public string Person { get; set; } - public string[] PersonIds { get; set; } - public string[] ItemIds { get; set; } - public string[] ExcludeItemIds { get; set; } + public Guid[] PersonIds { get; set; } + public Guid[] ItemIds { get; set; } + public Guid[] ExcludeItemIds { get; set; } public string AdjacentTo { get; set; } public string[] PersonTypes { get; set; } @@ -75,8 +75,8 @@ public class InternalItemsQuery public bool? HasTrailer { get; set; } public bool? HasParentalRating { get; set; } - public string[] StudioIds { get; set; } - public string[] GenreIds { get; set; } + public Guid[] StudioIds { get; set; } + public Guid[] GenreIds { get; set; } public ImageType[] ImageTypes { get; set; } public VideoType[] VideoTypes { get; set; } public UnratedItem[] BlockUnratedItems { get; set; } @@ -105,7 +105,7 @@ public class InternalItemsQuery public double? MinCriticRating { get; set; } public double? MinCommunityRating { get; set; } - public string[] ChannelIds { get; set; } + public Guid[] ChannelIds { get; set; } public int? ParentIndexNumber { get; set; } public int? ParentIndexNumberNotEquals { get; set; } @@ -118,8 +118,8 @@ public class InternalItemsQuery public Guid? ParentId { get; set; } public string ParentType { get; set; } - public string[] AncestorIds { get; set; } - public string[] TopParentIds { get; set; } + public Guid[] AncestorIds { get; set; } + public Guid[] TopParentIds { get; set; } public BaseItem Parent { @@ -146,9 +146,9 @@ public BaseItem Parent public string ExternalSeriesId { get; set; } public string ExternalId { get; set; } - public string[] AlbumIds { get; set; } - public string[] ArtistIds { get; set; } - public string[] ExcludeArtistIds { get; set; } + public Guid[] AlbumIds { get; set; } + public Guid[] ArtistIds { get; set; } + public Guid[] ExcludeArtistIds { get; set; } public string AncestorWithPresentationUniqueKey { get; set; } public string SeriesPresentationUniqueKey { get; set; } @@ -184,9 +184,9 @@ public InternalItemsQuery() EnableTotalRecordCount = true; DtoOptions = new DtoOptions(); - AlbumIds = new string[] { }; - ArtistIds = new string[] { }; - ExcludeArtistIds = new string[] { }; + AlbumIds = new Guid[] { }; + ArtistIds = new Guid[] { }; + ExcludeArtistIds = new Guid[] { }; ExcludeProviderIds = new Dictionary(StringComparer.OrdinalIgnoreCase); BlockUnratedItems = new UnratedItem[] { }; @@ -196,18 +196,18 @@ public InternalItemsQuery() IncludeItemTypes = new string[] { }; ExcludeItemTypes = new string[] { }; Genres = new string[] { }; - StudioIds = new string[] { }; - GenreIds = new string[] { }; + StudioIds = new Guid[] { }; + GenreIds = new Guid[] { }; ImageTypes = new ImageType[] { }; VideoTypes = new VideoType[] { }; Years = new int[] { }; PersonTypes = new string[] { }; - PersonIds = new string[] { }; - ChannelIds = new string[] { }; - ItemIds = new string[] { }; - ExcludeItemIds = new string[] { }; - AncestorIds = new string[] { }; - TopParentIds = new string[] { }; + PersonIds = new Guid[] { }; + ChannelIds = new Guid[] { }; + ItemIds = new Guid[] { }; + ExcludeItemIds = new Guid[] { }; + AncestorIds = new Guid[] { }; + TopParentIds = new Guid[] { }; ExcludeTags = new string[] { }; ExcludeInheritedTags = new string[] { }; PresetViews = new string[] { }; diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index b37f2edbab..4484cfe897 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -13,10 +13,8 @@ namespace MediaBrowser.Controller.Entities.Movies /// /// Class BoxSet /// - public class BoxSet : Folder, IHasTrailers, IHasDisplayOrder, IHasLookupInfo, IHasShares + public class BoxSet : Folder, IHasTrailers, IHasDisplayOrder, IHasLookupInfo { - public List Shares { get; set; } - public BoxSet() { RemoteTrailers = EmptyMediaUrlArray; @@ -24,7 +22,6 @@ public BoxSet() RemoteTrailerIds = EmptyGuidArray; DisplayOrder = ItemSortBy.PremiereDate; - Shares = new List(); } [IgnoreDataMember] @@ -169,14 +166,6 @@ public BoxSetInfo GetLookupInfo() public override bool IsVisible(User user) { - var userId = user.Id.ToString("N"); - - // Need to check Count > 0 for boxsets created prior to the introduction of Shares - if (Shares.Count > 0 && Shares.Any(i => string.Equals(userId, i.UserId, StringComparison.OrdinalIgnoreCase))) - { - return true; - } - if (base.IsVisible(user)) { return base.GetChildren(user, true).Count > 0; diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index 0adad2cf75..4e375778c9 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -41,7 +41,7 @@ public PersonLookupInfo GetLookupInfo() public IList GetTaggedItems(InternalItemsQuery query) { - query.PersonIds = new[] { Id.ToString("N") }; + query.PersonIds = new[] { Id }; return LibraryManager.GetItemList(query); } diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs index b54b32dc4c..343f2184f3 100644 --- a/MediaBrowser.Controller/Entities/Studio.cs +++ b/MediaBrowser.Controller/Entities/Studio.cs @@ -89,7 +89,7 @@ public override bool IsOwnedItem public IList GetTaggedItems(InternalItemsQuery query) { - query.StudioIds = new[] { Id.ToString("N") }; + query.StudioIds = new[] { Id }; return LibraryManager.GetItemList(query); } diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index 4cfc6b28f4..91ddf46c7d 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -277,7 +277,7 @@ private QueryResult GetMovieGenreItems(Folder queryParent, Folder disp { query.Recursive = true; query.Parent = queryParent; - query.GenreIds = new[] { displayParent.Id.ToString("N") }; + query.GenreIds = new[] { displayParent.Id }; query.SetUser(user); query.IncludeItemTypes = new[] { typeof(Movie).Name }; @@ -401,7 +401,7 @@ private QueryResult GetTvGenreItems(Folder queryParent, Folder display { query.Recursive = true; query.Parent = queryParent; - query.GenreIds = new[] { displayParent.Id.ToString("N") }; + query.GenreIds = new[] { displayParent.Id }; query.SetUser(user); query.IncludeItemTypes = new[] { typeof(Series).Name }; @@ -839,7 +839,7 @@ public static bool Filter(BaseItem item, User user, InternalItemsQuery query, IU if (query.ItemIds.Length > 0) { - if (!query.ItemIds.Contains(item.Id.ToString("N"), StringComparer.OrdinalIgnoreCase)) + if (!query.ItemIds.Contains(item.Id)) { return false; } diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 39b1410072..987d45fab9 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -530,8 +530,8 @@ IEnumerable