From 2c6fc11dcffcaf44aebc8db5c9555e5f72a9269f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 11 Oct 2016 17:33:38 -0400 Subject: [PATCH] update live stream sharing --- .../Entities/Audio/Audio.cs | 9 +++++ MediaBrowser.Controller/Entities/Folder.cs | 12 ------ MediaBrowser.Controller/Entities/Game.cs | 2 - .../Entities/InternalItemsQuery.cs | 2 + .../Entities/Movies/Movie.cs | 9 +++++ MediaBrowser.Controller/Entities/Video.cs | 9 +++++ .../LiveTv/LiveTvVideoRecording.cs | 9 +++++ MediaBrowser.Controller/Playlists/Playlist.cs | 14 +++---- MediaBrowser.Model/Querying/ItemFields.cs | 4 +- .../Library/UserDataManager.cs | 4 ++ .../TunerHosts/HdHomerun/HdHomerunHost.cs | 21 ++-------- .../Persistence/SqliteItemRepository.cs | 40 ++++++++++++++++--- .../Playlists/ManualPlaylistsFolder.cs | 2 +- 13 files changed, 90 insertions(+), 47 deletions(-) diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index 891fb7d52..56c3248f3 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -59,6 +59,15 @@ namespace MediaBrowser.Controller.Entities.Audio AlbumArtists = new List(); } + [IgnoreDataMember] + public override bool SupportsPlayedStatus + { + get + { + return true; + } + } + [IgnoreDataMember] public override bool SupportsAddingToPlaylist { diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 993e36fd8..1e466ec08 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -807,18 +807,6 @@ namespace MediaBrowser.Controller.Entities return true; } - if (query.HasThemeSong.HasValue) - { - Logger.Debug("Query requires post-filtering due to HasThemeSong"); - return true; - } - - if (query.HasThemeVideo.HasValue) - { - Logger.Debug("Query requires post-filtering due to HasThemeVideo"); - return true; - } - // Filter by VideoType if (query.VideoTypes.Length > 0) { diff --git a/MediaBrowser.Controller/Entities/Game.cs b/MediaBrowser.Controller/Entities/Game.cs index 59bfc2363..aa2ccf4bc 100644 --- a/MediaBrowser.Controller/Entities/Game.cs +++ b/MediaBrowser.Controller/Entities/Game.cs @@ -16,8 +16,6 @@ namespace MediaBrowser.Controller.Entities RemoteTrailers = new List(); LocalTrailerIds = new List(); RemoteTrailerIds = new List(); - ThemeSongIds = new List(); - ThemeVideoIds = new List(); } public List LocalTrailerIds { get; set; } diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index f375e1b1c..fec703b94 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -168,6 +168,8 @@ namespace MediaBrowser.Controller.Entities switch (name) { + case ItemFields.ThemeSongIds: + case ItemFields.ThemeVideoIds: case ItemFields.ProductionLocations: case ItemFields.Keywords: case ItemFields.Taglines: diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs index 9a10a63bd..22cc0316a 100644 --- a/MediaBrowser.Controller/Entities/Movies/Movie.cs +++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs @@ -68,6 +68,15 @@ namespace MediaBrowser.Controller.Entities.Movies set { TmdbCollectionName = value; } } + [IgnoreDataMember] + protected override bool SupportsIsInMixedFolderDetection + { + get + { + return false; + } + } + protected override async Task RefreshedOwnedItems(MetadataRefreshOptions options, List fileSystemChildren, CancellationToken cancellationToken) { var hasChanges = await base.RefreshedOwnedItems(options, fileSystemChildren, cancellationToken).ConfigureAwait(false); diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index e83d1298e..5aaff6fef 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -53,6 +53,15 @@ namespace MediaBrowser.Controller.Entities } } + [IgnoreDataMember] + protected override bool SupportsIsInMixedFolderDetection + { + get + { + return true; + } + } + public override string CreatePresentationUniqueKey() { if (!string.IsNullOrWhiteSpace(PrimaryVersionId)) diff --git a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs index 635df5dc7..c255630f5 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs @@ -54,6 +54,15 @@ namespace MediaBrowser.Controller.LiveTv } } + [IgnoreDataMember] + protected override bool SupportsIsInMixedFolderDetection + { + get + { + return false; + } + } + [IgnoreDataMember] public override bool SupportsPlayedStatus { diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index 8e0ac7ea8..6ab85f079 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -207,15 +207,15 @@ namespace MediaBrowser.Controller.Playlists public override bool IsVisible(User user) { - if (base.IsVisible(user)) - { - var userId = user.Id.ToString("N"); + var userId = user.Id.ToString("N"); - return Shares.Any(i => string.Equals(userId, i.UserId, StringComparison.OrdinalIgnoreCase)) || - string.Equals(OwnerUserId, userId, StringComparison.OrdinalIgnoreCase); - } + return Shares.Any(i => string.Equals(userId, i.UserId, StringComparison.OrdinalIgnoreCase)) || + string.Equals(OwnerUserId, userId, StringComparison.OrdinalIgnoreCase); + } - return false; + public override bool IsVisibleStandalone(User user) + { + return IsVisible(user); } } } diff --git a/MediaBrowser.Model/Querying/ItemFields.cs b/MediaBrowser.Model/Querying/ItemFields.cs index fcacc621c..dfca9e771 100644 --- a/MediaBrowser.Model/Querying/ItemFields.cs +++ b/MediaBrowser.Model/Querying/ItemFields.cs @@ -260,6 +260,8 @@ /// /// The service name /// - ServiceName + ServiceName, + ThemeSongIds, + ThemeVideoIds } } diff --git a/MediaBrowser.Server.Implementations/Library/UserDataManager.cs b/MediaBrowser.Server.Implementations/Library/UserDataManager.cs index 139ea0ab6..9ee65a57c 100644 --- a/MediaBrowser.Server.Implementations/Library/UserDataManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserDataManager.cs @@ -274,6 +274,10 @@ namespace MediaBrowser.Server.Implementations.Library positionTicks = 0; data.Played = false; } + if (item is Audio) + { + positionTicks = 0; + } data.PlaybackPositionTicks = positionTicks; diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index 365f784a7..c4922eec5 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -512,29 +512,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun if (EnableLocalBuffer()) { var liveStream = new HdHomerunLiveStream(mediaSource, streamId, _fileSystem, _httpClient, Logger, Config.ApplicationPaths, _appHost); - if (info.AllowHWTranscoding) - { - var model = await GetModelInfo(info, cancellationToken).ConfigureAwait(false); - - if ((model ?? string.Empty).IndexOf("hdtc", StringComparison.OrdinalIgnoreCase) != -1) - { - liveStream.EnableStreamSharing = !info.AllowHWTranscoding; - } - else - { - liveStream.EnableStreamSharing = true; - } - } - else - { - liveStream.EnableStreamSharing = true; - } + liveStream.EnableStreamSharing = true; return liveStream; } else { var liveStream = new LiveStream(mediaSource); - liveStream.EnableStreamSharing = false; + liveStream.EnableStreamSharing = true; + //liveStream.EnableStreamSharing = false; return liveStream; } } diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index 1656d8304..2235bfe0d 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -1875,17 +1875,23 @@ namespace MediaBrowser.Server.Implementations.Persistence index++; } - if (!reader.IsDBNull(index)) + if (query.HasField(ItemFields.ThemeSongIds)) { - item.ThemeSongIds = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => new Guid(i)).ToList(); + if (!reader.IsDBNull(index)) + { + item.ThemeSongIds = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => new Guid(i)).ToList(); + } + index++; } - index++; - if (!reader.IsDBNull(index)) + if (query.HasField(ItemFields.ThemeVideoIds)) { - item.ThemeVideoIds = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => new Guid(i)).ToList(); + if (!reader.IsDBNull(index)) + { + item.ThemeVideoIds = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => new Guid(i)).ToList(); + } + index++; } - index++; if (string.IsNullOrWhiteSpace(item.Tagline)) { @@ -3826,6 +3832,28 @@ namespace MediaBrowser.Server.Implementations.Persistence clause += ")"; whereClauses.Add(clause); } + if (query.HasThemeSong.HasValue) + { + if (query.HasThemeSong.Value) + { + whereClauses.Add("ThemeSongIds not null"); + } + else + { + whereClauses.Add("ThemeSongIds is null"); + } + } + if (query.HasThemeVideo.HasValue) + { + if (query.HasThemeVideo.Value) + { + whereClauses.Add("ThemeVideoIds not null"); + } + else + { + whereClauses.Add("ThemeVideoIds is null"); + } + } //var enableItemsByName = query.IncludeItemsByName ?? query.IncludeItemTypes.Length > 0; var enableItemsByName = query.IncludeItemsByName ?? false; diff --git a/MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs b/MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs index 07b63718c..d9c36cd3b 100644 --- a/MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs +++ b/MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs @@ -17,7 +17,7 @@ namespace MediaBrowser.Server.Implementations.Playlists public override bool IsVisible(User user) { - return base.IsVisible(user); + return base.IsVisible(user) && GetChildren(user, true).Any(); } protected override IEnumerable GetEligibleChildrenForRecursiveChildren(User user)