From a93c2682d96dee4acf0f98f3adb44ef46610227a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 20 Dec 2016 00:21:21 -0500 Subject: [PATCH 01/10] update timer settings --- .../LiveTv/EmbyTV/EmbyTV.cs | 23 +++++++++++-------- .../LiveTv/LiveTvManager.cs | 2 +- MediaBrowser.Api/LiveTv/LiveTvService.cs | 4 +++- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 84a255c7a..2e591711b 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -326,7 +326,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { epgData = GetEpgDataForChannel(timer.ChannelId); } - await UpdateTimersForSeriesTimer(epgData, timer, true).ConfigureAwait(false); + await UpdateTimersForSeriesTimer(epgData, timer, false, true).ConfigureAwait(false); } } @@ -573,7 +573,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } _seriesTimerProvider.Add(info); - await UpdateTimersForSeriesTimer(epgData, info, false).ConfigureAwait(false); + await UpdateTimersForSeriesTimer(epgData, info, true, false).ConfigureAwait(false); return info.Id; } @@ -614,7 +614,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV epgData = GetEpgDataForChannel(instance.ChannelId); } - await UpdateTimersForSeriesTimer(epgData, instance, true).ConfigureAwait(false); + await UpdateTimersForSeriesTimer(epgData, instance, true, true).ConfigureAwait(false); } } @@ -2159,7 +2159,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } } - private async Task UpdateTimersForSeriesTimer(List epgData, SeriesTimerInfo seriesTimer, bool deleteInvalidTimers) + private async Task UpdateTimersForSeriesTimer(List epgData, SeriesTimerInfo seriesTimer, bool updateTimerSettings, bool deleteInvalidTimers) { var allTimers = GetTimersForSeries(seriesTimer, epgData) .ToList(); @@ -2204,12 +2204,15 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV enabledTimersForSeries.Add(existingTimer); } - existingTimer.KeepUntil = seriesTimer.KeepUntil; - existingTimer.IsPostPaddingRequired = seriesTimer.IsPostPaddingRequired; - existingTimer.IsPrePaddingRequired = seriesTimer.IsPrePaddingRequired; - existingTimer.PostPaddingSeconds = seriesTimer.PostPaddingSeconds; - existingTimer.PrePaddingSeconds = seriesTimer.PrePaddingSeconds; - existingTimer.Priority = seriesTimer.Priority; + if (updateTimerSettings) + { + existingTimer.KeepUntil = seriesTimer.KeepUntil; + existingTimer.IsPostPaddingRequired = seriesTimer.IsPostPaddingRequired; + existingTimer.IsPrePaddingRequired = seriesTimer.IsPrePaddingRequired; + existingTimer.PostPaddingSeconds = seriesTimer.PostPaddingSeconds; + existingTimer.PrePaddingSeconds = seriesTimer.PrePaddingSeconds; + existingTimer.Priority = seriesTimer.Priority; + } existingTimer.SeriesTimerId = seriesTimer.Id; _timerProvider.Update(existingTimer); diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index 265817cbe..525db4036 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -1681,7 +1681,7 @@ namespace Emby.Server.Implementations.LiveTv return new QueryResult(); } - if (_services.Count == 1 && !(query.IsInProgress ?? false)) + if (_services.Count == 1 && !(query.IsInProgress ?? false) && (!query.IsLibraryItem.HasValue || query.IsLibraryItem.Value)) { return GetEmbyRecordings(query, new DtoOptions(), user); } diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index c829ad2ab..85a66080d 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -202,6 +202,7 @@ namespace MediaBrowser.Api.LiveTv public bool? IsKids { get; set; } public bool? IsSports { get; set; } public bool? IsNews { get; set; } + public bool? IsLibraryItem { get; set; } public GetRecordings() { @@ -1057,7 +1058,8 @@ namespace MediaBrowser.Api.LiveTv IsNews = request.IsNews, IsSeries = request.IsSeries, IsKids = request.IsKids, - IsSports = request.IsSports + IsSports = request.IsSports, + IsLibraryItem = request.IsLibraryItem }, options, CancellationToken.None).ConfigureAwait(false); From 40e8d0c75e5f19167f08f0159830723684178a4f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 20 Dec 2016 00:21:52 -0500 Subject: [PATCH 02/10] add additional http server error handling --- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 ++-- RSSDP/SsdpCommunicationsServer.cs | 4 ++++ SocketHttpListener.Portable/Net/EndPointListener.cs | 5 ++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index daeb754ba..6b5895720 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.691 + 3.0.692 Emby.Common Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index a34a9bee2..36ff96226 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.691 + 3.0.692 Emby.Server.Core Emby Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Emby Server. Copyright © Emby 2013 - + diff --git a/RSSDP/SsdpCommunicationsServer.cs b/RSSDP/SsdpCommunicationsServer.cs index b709861d5..97f5ebbd0 100644 --- a/RSSDP/SsdpCommunicationsServer.cs +++ b/RSSDP/SsdpCommunicationsServer.cs @@ -182,6 +182,10 @@ namespace Rssdp.Infrastructure try { await socket.SendAsync(messageData, messageData.Length, destination).ConfigureAwait(false); + } + catch (ObjectDisposedException) + { + } catch (Exception ex) { diff --git a/SocketHttpListener.Portable/Net/EndPointListener.cs b/SocketHttpListener.Portable/Net/EndPointListener.cs index 690dedd09..2bd7a3da6 100644 --- a/SocketHttpListener.Portable/Net/EndPointListener.cs +++ b/SocketHttpListener.Portable/Net/EndPointListener.cs @@ -71,7 +71,10 @@ namespace SocketHttpListener.Net } catch (SocketCreateException ex) { - if (_enableDualMode && endpoint.IpAddress.Equals(IpAddressInfo.IPv6Any) && string.Equals(ex.ErrorCode, "AddressFamilyNotSupported", StringComparison.OrdinalIgnoreCase)) + if (_enableDualMode && endpoint.IpAddress.Equals(IpAddressInfo.IPv6Any) && + (string.Equals(ex.ErrorCode, "AddressFamilyNotSupported", StringComparison.OrdinalIgnoreCase) || + // mono on bsd is throwing this + string.Equals(ex.ErrorCode, "ProtocolNotSupported", StringComparison.OrdinalIgnoreCase))) { endpoint = new IpEndPointInfo(IpAddressInfo.Any, endpoint.Port); _enableDualMode = false; From e9ae47936054da3dd7543e0dc5f7afd1e2fdf7c9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 20 Dec 2016 00:22:31 -0500 Subject: [PATCH 03/10] fix duplicate latest recordings section --- MediaBrowser.Model/LiveTv/RecordingQuery.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/MediaBrowser.Model/LiveTv/RecordingQuery.cs b/MediaBrowser.Model/LiveTv/RecordingQuery.cs index 265aad335..9e9aafc44 100644 --- a/MediaBrowser.Model/LiveTv/RecordingQuery.cs +++ b/MediaBrowser.Model/LiveTv/RecordingQuery.cs @@ -68,6 +68,7 @@ namespace MediaBrowser.Model.LiveTv /// The fields. public ItemFields[] Fields { get; set; } public bool? EnableImages { get; set; } + public bool? IsLibraryItem { get; set; } public bool? IsNews { get; set; } public bool? IsMovie { get; set; } public bool? IsSeries { get; set; } From d588ed705ff2141dfe96d2c8c66f919b11c20eac Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 20 Dec 2016 00:23:22 -0500 Subject: [PATCH 04/10] update subtitle burn in params --- MediaBrowser.Api/Playback/BaseStreamingService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 3718edba4..6545d995c 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -818,7 +818,7 @@ namespace MediaBrowser.Api.Playback if (state.VideoStream != null && state.VideoStream.Width.HasValue && state.VideoStream.Height.HasValue) { - videoSizeParam = string.Format(",scale={0}:{1}", state.VideoStream.Width.Value.ToString(UsCulture), state.VideoStream.Height.Value.ToString(UsCulture)); + videoSizeParam = string.Format("scale={0}:{1}", state.VideoStream.Width.Value.ToString(UsCulture), state.VideoStream.Height.Value.ToString(UsCulture)); } var mapPrefix = state.SubtitleStream.IsExternal ? @@ -829,7 +829,7 @@ namespace MediaBrowser.Api.Playback ? 0 : state.SubtitleStream.Index; - return string.Format(" -filter_complex \"[{0}:{1}]format=yuva444p{4},lut=u=128:v=128:y=gammaval(.3)[sub] ; [0:{2}] [sub] overlay{3}\"", + return string.Format(" -filter_complex \"[{0}:{1}]{4}[sub] ; [0:{2}] [sub] overlay{3}\"", mapPrefix.ToString(UsCulture), subtitleStreamIndex.ToString(UsCulture), state.VideoStream.Index.ToString(UsCulture), From 27c4c30082d8b8d122041f1c6080148bd4c92382 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 20 Dec 2016 00:23:33 -0500 Subject: [PATCH 05/10] update media info bitrate --- .../Probing/ProbeResultNormalizer.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs index de055146a..c16d3afbd 100644 --- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs +++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs @@ -180,6 +180,17 @@ namespace MediaBrowser.MediaEncoding.Probing { info.Video3DFormat = Video3DFormat.FullSideBySide; } + + var videoStreamsBitrate = info.MediaStreams.Where(i => i.Type == MediaStreamType.Video).Select(i => i.BitRate ?? 0).Sum(); + // If ffprobe reported the container bitrate as being the same as the video stream bitrate, then it's wrong + if (videoStreamsBitrate == (info.Bitrate ?? 0)) + { + var streamBitrates = info.MediaStreams.Where(i => !i.IsExternal).Select(i => i.BitRate ?? 0).Sum(); + if (streamBitrates > (info.Bitrate ?? 0)) + { + info.Bitrate = streamBitrates; + } + } } return info; From 74ec6e5a06679e5360b9e8daf00fea40de4c699a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 20 Dec 2016 02:31:30 -0500 Subject: [PATCH 06/10] update dlna music genres --- Emby.Dlna/ContentDirectory/ControlHandler.cs | 63 +++++++++++++++---- .../Entities/UserViewBuilder.cs | 15 ----- MediaBrowser.Model/Entities/CollectionType.cs | 8 --- 3 files changed, 50 insertions(+), 36 deletions(-) diff --git a/Emby.Dlna/ContentDirectory/ControlHandler.cs b/Emby.Dlna/ContentDirectory/ControlHandler.cs index bba8c53d9..55d662e64 100644 --- a/Emby.Dlna/ContentDirectory/ControlHandler.cs +++ b/Emby.Dlna/ContentDirectory/ControlHandler.cs @@ -23,6 +23,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using System.Xml; +using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Model.Globalization; using MediaBrowser.Model.Xml; @@ -492,29 +493,53 @@ namespace Emby.Dlna.ContentDirectory return ApplyPaging(new QueryResult(), startIndex, limit); } - var folder = (Folder)item; - - var sortOrders = new List(); - if (!folder.IsPreSorted) + if (item is MusicGenre) { - sortOrders.Add(ItemSortBy.SortName); + return GetMusicGenreItems(item, null, user, sort, startIndex, limit); } - var queryResult = await folder.GetItems(new InternalItemsQuery + var folder = (Folder)item; + + var query = new InternalItemsQuery { Limit = limit, StartIndex = startIndex, - SortBy = sortOrders.ToArray(), - SortOrder = sort.SortOrder, User = user, IsMissing = false, - PresetViews = new[] { CollectionType.Movies, CollectionType.TvShows, CollectionType.Music }, - ExcludeItemTypes = new[] { typeof(Game).Name, typeof(Book).Name }, + PresetViews = new[] {CollectionType.Movies, CollectionType.TvShows, CollectionType.Music}, + ExcludeItemTypes = new[] {typeof (Game).Name, typeof (Book).Name}, IsPlaceHolder = false + }; - }).ConfigureAwait(false); + SetSorting(query, sort, folder.IsPreSorted); - var serverItems = queryResult + var queryResult = await folder.GetItems(query).ConfigureAwait(false); + + return ToResult(queryResult); + } + + private QueryResult GetMusicGenreItems(BaseItem item, Guid? parentId, User user, SortCriteria sort, int? startIndex, int? limit) + { + var query = new InternalItemsQuery(user) + { + Recursive = true, + ParentId = parentId, + GenreIds = new[] {item.Id.ToString("N")}, + IncludeItemTypes = new[] {typeof (MusicAlbum).Name}, + Limit = limit, + StartIndex = startIndex + }; + + SetSorting(query, sort, false); + + var result = _libraryManager.GetItemsResult(query); + + return ToResult(result); + } + + private QueryResult ToResult(QueryResult result) + { + var serverItems = result .Items .Select(i => new ServerItem { @@ -524,11 +549,23 @@ namespace Emby.Dlna.ContentDirectory return new QueryResult { - TotalRecordCount = queryResult.TotalRecordCount, + TotalRecordCount = result.TotalRecordCount, Items = serverItems }; } + private void SetSorting(InternalItemsQuery query, SortCriteria sort, bool isPreSorted) + { + var sortOrders = new List(); + if (!isPreSorted) + { + sortOrders.Add(ItemSortBy.SortName); + } + + query.SortBy = sortOrders.ToArray(); + query.SortOrder = sort.SortOrder; + } + private QueryResult GetItemsFromPerson(Person person, User user, int? startIndex, int? limit) { var itemsResult = _libraryManager.GetItemsResult(new InternalItemsQuery(user) diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index d5781d21e..abaf43fd5 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -203,9 +203,6 @@ namespace MediaBrowser.Controller.Entities case SpecialFolder.MusicGenres: return GetMusicGenres(queryParent, user, query); - case SpecialFolder.MusicGenre: - return await GetMusicGenreItems(queryParent, displayParent, user, query).ConfigureAwait(false); - case SpecialFolder.MusicLatest: return GetMusicLatest(queryParent, user, query); @@ -306,18 +303,6 @@ namespace MediaBrowser.Controller.Entities }; } - private async Task> GetMusicGenreItems(Folder queryParent, Folder displayParent, User user, InternalItemsQuery query) - { - query.Recursive = true; - query.ParentId = queryParent.Id; - query.Genres = new[] { displayParent.Name }; - query.SetUser(user); - - query.IncludeItemTypes = new[] { typeof(MusicAlbum).Name }; - - return _libraryManager.GetItemsResult(query); - } - private QueryResult GetMusicAlbumArtists(Folder parent, User user, InternalItemsQuery query) { var artists = _libraryManager.GetAlbumArtists(new InternalItemsQuery(user) diff --git a/MediaBrowser.Model/Entities/CollectionType.cs b/MediaBrowser.Model/Entities/CollectionType.cs index 187334c71..b1cbb9ac3 100644 --- a/MediaBrowser.Model/Entities/CollectionType.cs +++ b/MediaBrowser.Model/Entities/CollectionType.cs @@ -48,18 +48,10 @@ public const string MovieGenres = "MovieGenres"; public const string MovieGenre = "MovieGenre"; - public const string LatestGames = "LatestGames"; - public const string RecentlyPlayedGames = "RecentlyPlayedGames"; - public const string GameSystems = "GameSystems"; - public const string GameGenres = "GameGenres"; - public const string GameFavorites = "GameFavorites"; - public const string GameGenre = "GameGenre"; - public const string MusicArtists = "MusicArtists"; public const string MusicAlbumArtists = "MusicAlbumArtists"; public const string MusicAlbums = "MusicAlbums"; public const string MusicGenres = "MusicGenres"; - public const string MusicGenre = "MusicGenre"; public const string MusicLatest = "MusicLatest"; public const string MusicPlaylists = "MusicPlaylists"; public const string MusicSongs = "MusicSongs"; From ac2c45dd6a2a932ce950069a4d3644b18c8037e0 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 20 Dec 2016 14:59:25 -0500 Subject: [PATCH 07/10] update dlna genre views --- Emby.Dlna/ContentDirectory/ControlHandler.cs | 64 +++++++++++++------ .../Data/SqliteItemRepository.cs | 27 ++------ MediaBrowser.Api/Reports/ReportsService.cs | 16 ----- .../UserLibrary/BaseItemsByNameService.cs | 17 ++++- .../UserLibrary/BaseItemsRequest.cs | 5 ++ MediaBrowser.Api/UserLibrary/ItemsService.cs | 39 +++++++---- .../Entities/Audio/MusicArtist.cs | 2 +- .../Entities/InternalItemsQuery.cs | 6 +- MediaBrowser.Controller/Entities/Studio.cs | 2 +- MediaBrowser.Controller/Entities/TV/Series.cs | 28 ++++---- .../Entities/UserViewBuilder.cs | 21 ++---- MediaBrowser.Controller/Playlists/Playlist.cs | 2 +- 12 files changed, 125 insertions(+), 104 deletions(-) diff --git a/Emby.Dlna/ContentDirectory/ControlHandler.cs b/Emby.Dlna/ContentDirectory/ControlHandler.cs index 55d662e64..432991128 100644 --- a/Emby.Dlna/ContentDirectory/ControlHandler.cs +++ b/Emby.Dlna/ContentDirectory/ControlHandler.cs @@ -465,6 +465,16 @@ namespace Emby.Dlna.ContentDirectory private async Task> GetUserItems(BaseItem item, StubType? stubType, User user, SortCriteria sort, int? startIndex, int? limit) { + if (item is MusicGenre) + { + return GetMusicGenreItems(item, null, user, sort, startIndex, limit); + } + + if (item is MusicArtist) + { + return GetMusicArtistItems(item, null, user, sort, startIndex, limit); + } + if (stubType.HasValue) { if (stubType.Value == StubType.People) @@ -477,7 +487,7 @@ namespace Emby.Dlna.ContentDirectory var result = new QueryResult { - Items = items.Select(i => new ServerItem { Item = i, StubType = StubType.Folder }).ToArray(), + Items = items.Select(i => new ServerItem(i)).ToArray(), TotalRecordCount = items.Length }; @@ -493,11 +503,6 @@ namespace Emby.Dlna.ContentDirectory return ApplyPaging(new QueryResult(), startIndex, limit); } - if (item is MusicGenre) - { - return GetMusicGenreItems(item, null, user, sort, startIndex, limit); - } - var folder = (Folder)item; var query = new InternalItemsQuery @@ -518,6 +523,25 @@ namespace Emby.Dlna.ContentDirectory return ToResult(queryResult); } + private QueryResult GetMusicArtistItems(BaseItem item, Guid? parentId, User user, SortCriteria sort, int? startIndex, int? limit) + { + var query = new InternalItemsQuery(user) + { + Recursive = true, + ParentId = parentId, + ArtistIds = new[] { item.Id.ToString("N") }, + IncludeItemTypes = new[] { typeof(MusicAlbum).Name }, + Limit = limit, + StartIndex = startIndex + }; + + SetSorting(query, sort, false); + + var result = _libraryManager.GetItemsResult(query); + + return ToResult(result); + } + private QueryResult GetMusicGenreItems(BaseItem item, Guid? parentId, User user, SortCriteria sort, int? startIndex, int? limit) { var query = new InternalItemsQuery(user) @@ -541,10 +565,7 @@ namespace Emby.Dlna.ContentDirectory { var serverItems = result .Items - .Select(i => new ServerItem - { - Item = i - }) + .Select(i => new ServerItem(i)) .ToArray(); return new QueryResult @@ -578,11 +599,7 @@ namespace Emby.Dlna.ContentDirectory }); - var serverItems = itemsResult.Items.Select(i => new ServerItem - { - Item = i, - StubType = null - }) + var serverItems = itemsResult.Items.Select(i => new ServerItem(i)) .ToArray(); return new QueryResult @@ -603,7 +620,7 @@ namespace Emby.Dlna.ContentDirectory { return DidlBuilder.IsIdRoot(id) - ? new ServerItem { Item = user.RootFolder } + ? new ServerItem(user.RootFolder) : ParseItemId(id, user); } @@ -638,16 +655,15 @@ namespace Emby.Dlna.ContentDirectory { var item = _libraryManager.GetItemById(itemId); - return new ServerItem + return new ServerItem(item) { - Item = item, StubType = stubType }; } Logger.Error("Error parsing item Id: {0}. Returning user root folder.", id); - return new ServerItem { Item = user.RootFolder }; + return new ServerItem(user.RootFolder); } } @@ -655,6 +671,16 @@ namespace Emby.Dlna.ContentDirectory { public BaseItem Item { get; set; } public StubType? StubType { get; set; } + + public ServerItem(BaseItem item) + { + Item = item; + + if (item is IItemByName && !(item is Folder)) + { + StubType = Dlna.ContentDirectory.StubType.Folder; + } + } } public enum StubType diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 151702905..8e6a277a4 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -3855,16 +3855,18 @@ namespace Emby.Server.Implementations.Data } } - if (query.ArtistNames.Length > 0) + if (query.ArtistIds.Length > 0) { var clauses = new List(); var index = 0; - foreach (var artist in query.ArtistNames) + foreach (var artistId in query.ArtistIds) { - clauses.Add("@ArtistName" + index + " in (select CleanValue from itemvalues where ItemId=Guid and Type <= 1)"); + var paramName = "@ArtistIds" + index; + + clauses.Add("(select CleanName from TypedBaseItems where guid=" + paramName + ") in (select CleanValue from itemvalues where ItemId=Guid and Type<=1)"); if (statement != null) { - statement.TryBind("@ArtistName" + index, GetCleanValue(artist)); + statement.TryBind(paramName, artistId.ToGuidParamValue()); } index++; } @@ -3963,23 +3965,6 @@ namespace Emby.Server.Implementations.Data whereClauses.Add(clause); } - if (query.Studios.Length > 0) - { - var clauses = new List(); - var index = 0; - foreach (var item in query.Studios) - { - clauses.Add("@Studio" + index + " in (select CleanValue from itemvalues where ItemId=Guid and Type=3)"); - if (statement != null) - { - statement.TryBind("@Studio" + index, GetCleanValue(item)); - } - index++; - } - var clause = "(" + string.Join(" OR ", clauses.ToArray()) + ")"; - whereClauses.Add(clause); - } - if (query.Keywords.Length > 0) { var clauses = new List(); diff --git a/MediaBrowser.Api/Reports/ReportsService.cs b/MediaBrowser.Api/Reports/ReportsService.cs index 5c4d21d66..efbfa1bdf 100644 --- a/MediaBrowser.Api/Reports/ReportsService.cs +++ b/MediaBrowser.Api/Reports/ReportsService.cs @@ -209,7 +209,6 @@ namespace MediaBrowser.Api.Reports OfficialRatings = request.GetOfficialRatings(), Genres = request.GetGenres(), GenreIds = request.GetGenreIds(), - Studios = request.GetStudios(), StudioIds = request.GetStudioIds(), Person = request.Person, PersonIds = request.GetPersonIds(), @@ -314,21 +313,6 @@ namespace MediaBrowser.Api.Reports query.MaxParentalRating = _localization.GetRatingLevel(request.MaxOfficialRating); } - // Artists - if (!string.IsNullOrEmpty(request.ArtistIds)) - { - var artistIds = request.ArtistIds.Split(new[] { '|', ',' }); - - var artistItems = artistIds.Select(_libraryManager.GetItemById).Where(i => i != null).ToList(); - query.ArtistNames = artistItems.Select(i => i.Name).ToArray(); - } - - // Artists - if (!string.IsNullOrEmpty(request.Artists)) - { - query.ArtistNames = request.Artists.Split('|'); - } - // Albums if (!string.IsNullOrEmpty(request.Albums)) { diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs index ff285b605..5b939244e 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs @@ -124,7 +124,6 @@ namespace MediaBrowser.Api.UserLibrary OfficialRatings = request.GetOfficialRatings(), Genres = request.GetGenres(), GenreIds = request.GetGenreIds(), - Studios = request.GetStudios(), StudioIds = request.GetStudioIds(), Person = request.Person, PersonIds = request.GetPersonIds(), @@ -145,6 +144,22 @@ namespace MediaBrowser.Api.UserLibrary } } + // Studios + if (!string.IsNullOrEmpty(request.Studios)) + { + query.StudioIds = request.Studios.Split('|').Select(i => + { + try + { + return LibraryManager.GetStudio(i); + } + catch + { + return null; + } + }).Where(i => i != null).Select(i => i.Id.ToString("N")).ToArray(); + } + foreach (var filter in request.GetFilters()) { switch (filter) diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs index f106adde5..0594691a2 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs @@ -394,6 +394,11 @@ namespace MediaBrowser.Api.UserLibrary return (Studios ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); } + public string[] GetArtistIds() + { + return (ArtistIds ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); + } + public string[] GetStudioIds() { return (StudioIds ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index a07128f74..049a7b1c6 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -230,8 +230,8 @@ namespace MediaBrowser.Api.UserLibrary Tags = request.GetTags(), OfficialRatings = request.GetOfficialRatings(), Genres = request.GetGenres(), + ArtistIds = request.GetArtistIds(), GenreIds = request.GetGenreIds(), - Studios = request.GetStudios(), StudioIds = request.GetStudioIds(), Person = request.Person, PersonIds = request.GetPersonIds(), @@ -338,19 +338,20 @@ namespace MediaBrowser.Api.UserLibrary query.MaxParentalRating = _localization.GetRatingLevel(request.MaxOfficialRating); } - // Artists - if (!string.IsNullOrEmpty(request.ArtistIds)) - { - var artistIds = request.ArtistIds.Split(new[] { '|', ',' }); - - var artistItems = artistIds.Select(_libraryManager.GetItemById).Where(i => i != null).ToList(); - query.ArtistNames = artistItems.Select(i => i.Name).ToArray(); - } - // Artists if (!string.IsNullOrEmpty(request.Artists)) { - query.ArtistNames = request.Artists.Split('|'); + query.ArtistIds = request.Artists.Split('|').Select(i => + { + try + { + return _libraryManager.GetArtist(i); + } + catch + { + return null; + } + }).Where(i => i != null).Select(i => i.Id.ToString("N")).ToArray(); } // ExcludeArtistIds @@ -365,6 +366,22 @@ namespace MediaBrowser.Api.UserLibrary query.AlbumNames = request.Albums.Split('|'); } + // Studios + if (!string.IsNullOrEmpty(request.Studios)) + { + query.StudioIds = request.Studios.Split('|').Select(i => + { + try + { + return _libraryManager.GetStudio(i); + } + catch + { + return null; + } + }).Where(i => i != null).Select(i => i.Id.ToString("N")).ToArray(); + } + return query; } } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index fd20f2ab4..1d2716b64 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -69,7 +69,7 @@ namespace MediaBrowser.Controller.Entities.Audio if (query.IncludeItemTypes.Length == 0) { query.IncludeItemTypes = new[] { typeof(Audio).Name, typeof(MusicVideo).Name, typeof(MusicAlbum).Name }; - query.ArtistNames = new[] { Name }; + query.ArtistIds = new[] { Id.ToString("N") }; } return LibraryManager.GetItemList(query); diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index a2d278a71..15af0888d 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -83,7 +83,6 @@ namespace MediaBrowser.Controller.Entities public bool? HasTrailer { get; set; } public bool? HasParentalRating { get; set; } - public string[] Studios { get; set; } public string[] StudioIds { get; set; } public string[] GenreIds { get; set; } public ImageType[] ImageTypes { get; set; } @@ -144,7 +143,7 @@ namespace MediaBrowser.Controller.Entities public string ExternalId { get; set; } public string[] AlbumNames { get; set; } - public string[] ArtistNames { get; set; } + public string[] ArtistIds { get; set; } public string[] ExcludeArtistIds { get; set; } public string AncestorWithPresentationUniqueKey { get; set; } public string SeriesPresentationUniqueKey { get; set; } @@ -203,7 +202,7 @@ namespace MediaBrowser.Controller.Entities DtoOptions = new DtoOptions(); AlbumNames = new string[] { }; - ArtistNames = new string[] { }; + ArtistIds = new string[] { }; ExcludeArtistIds = new string[] { }; ExcludeProviderIds = new Dictionary(StringComparer.OrdinalIgnoreCase); @@ -216,7 +215,6 @@ namespace MediaBrowser.Controller.Entities IncludeItemTypes = new string[] { }; ExcludeItemTypes = new string[] { }; Genres = new string[] { }; - Studios = new string[] { }; StudioIds = new string[] { }; GenreIds = new string[] { }; ImageTypes = new ImageType[] { }; diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs index ec623eeda..c14dd70bf 100644 --- a/MediaBrowser.Controller/Entities/Studio.cs +++ b/MediaBrowser.Controller/Entities/Studio.cs @@ -83,7 +83,7 @@ namespace MediaBrowser.Controller.Entities public IEnumerable GetTaggedItems(InternalItemsQuery query) { - query.Studios = new[] { Name }; + query.StudioIds = new[] { Id.ToString("N") }; return LibraryManager.GetItemList(query); } diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index 872011ce8..eea11b167 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -248,19 +248,25 @@ namespace MediaBrowser.Controller.Entities.TV } public IEnumerable GetSeasons(User user) + { + var query = new InternalItemsQuery(user); + + SetSeasonQueryOptions(query, user); + + return LibraryManager.GetItemList(query).Cast(); + } + + private void SetSeasonQueryOptions(InternalItemsQuery query, User user) { var config = user.Configuration; var enableSeriesPresentationKey = ConfigurationManager.Configuration.EnableSeriesPresentationUniqueKey; var seriesKey = GetUniqueSeriesKey(this); - var query = new InternalItemsQuery(user) - { - AncestorWithPresentationUniqueKey = enableSeriesPresentationKey ? null : seriesKey, - SeriesPresentationUniqueKey = enableSeriesPresentationKey ? seriesKey : null, - IncludeItemTypes = new[] { typeof(Season).Name }, - SortBy = new[] { ItemSortBy.SortName } - }; + query.AncestorWithPresentationUniqueKey = enableSeriesPresentationKey ? null : seriesKey; + query.SeriesPresentationUniqueKey = enableSeriesPresentationKey ? seriesKey : null; + query.IncludeItemTypes = new[] { typeof(Season).Name }; + query.SortBy = new[] {ItemSortBy.SortName}; if (!config.DisplayMissingEpisodes && !config.DisplayUnairedEpisodes) { @@ -274,8 +280,6 @@ namespace MediaBrowser.Controller.Entities.TV { query.IsVirtualUnaired = false; } - - return LibraryManager.GetItemList(query).Cast(); } protected override Task> GetItemsInternal(InternalItemsQuery query) @@ -306,11 +310,9 @@ namespace MediaBrowser.Controller.Entities.TV return Task.FromResult(LibraryManager.GetItemsResult(query)); } - Func filter = i => UserViewBuilder.Filter(i, user, query, UserDataManager, LibraryManager); + SetSeasonQueryOptions(query, user); - var items = GetSeasons(user).Where(filter); - var result = PostFilterAndSort(items, query, false, true); - return Task.FromResult(result); + return Task.FromResult(LibraryManager.GetItemsResult(query)); } public IEnumerable GetEpisodes(User user) diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index abaf43fd5..58d2cdc6c 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -1005,11 +1005,6 @@ namespace MediaBrowser.Controller.Entities return false; } - if (request.Studios.Length > 0) - { - return false; - } - if (request.StudioIds.Length > 0) { return false; @@ -1514,12 +1509,6 @@ namespace MediaBrowser.Controller.Entities return false; } - // Apply studio filter - if (query.Studios.Length > 0 && !query.Studios.Any(v => item.Studios.Contains(v, StringComparer.OrdinalIgnoreCase))) - { - return false; - } - // Apply studio filter if (query.StudioIds.Length > 0 && !query.StudioIds.Any(id => { @@ -1733,14 +1722,14 @@ namespace MediaBrowser.Controller.Entities } // Artists - if (query.ArtistNames.Length > 0) + if (query.ArtistIds.Length > 0) { var audio = item as IHasArtist; - if (!(audio != null && query.ArtistNames.Any(audio.HasAnyArtist))) - { - return false; - } + //if (!(audio != null && query.ArtistNames.Any(audio.HasAnyArtist))) + //{ + // return false; + //} } // Albums diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index 02e736d99..9087a6e1d 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -153,7 +153,7 @@ namespace MediaBrowser.Controller.Playlists : user.RootFolder.GetRecursiveChildren(user, new InternalItemsQuery(user) { IncludeItemTypes = new[] { typeof(Audio).Name }, - ArtistNames = new[] { musicArtist.Name } + ArtistIds = new[] { musicArtist.Id.ToString("N") } }); return LibraryManager.Sort(items, user, new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName }, SortOrder.Ascending); From 7f7be26771bbc221dada2a9395da8182b512dd6c Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 20 Dec 2016 15:00:04 -0500 Subject: [PATCH 08/10] restore version --- SharedVersion.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SharedVersion.cs b/SharedVersion.cs index 0561738e2..16c597910 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,4 +1,4 @@ using System.Reflection; -//[assembly: AssemblyVersion("3.1.*")] -[assembly: AssemblyVersion("3.1.259")] +[assembly: AssemblyVersion("3.1.*")] +//[assembly: AssemblyVersion("3.1.259")] From 617bbce0e116d76f412ab64f2e6fa585a48e6211 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 20 Dec 2016 15:06:36 -0500 Subject: [PATCH 09/10] 3.1.260 --- SharedVersion.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SharedVersion.cs b/SharedVersion.cs index 16c597910..aa4bd7a34 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,4 +1,4 @@ using System.Reflection; -[assembly: AssemblyVersion("3.1.*")] -//[assembly: AssemblyVersion("3.1.259")] +//[assembly: AssemblyVersion("3.1.*")] +[assembly: AssemblyVersion("3.1.260")] From c0128a0a114f75b06c30896a69969a68a5128f22 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 21 Dec 2016 15:08:20 -0500 Subject: [PATCH 10/10] resolve holiday theme disrupting playback --- .../Migrations/LibraryScanMigration.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Emby.Server.Implementations/Migrations/LibraryScanMigration.cs b/Emby.Server.Implementations/Migrations/LibraryScanMigration.cs index c494abc0b..600dd8033 100644 --- a/Emby.Server.Implementations/Migrations/LibraryScanMigration.cs +++ b/Emby.Server.Implementations/Migrations/LibraryScanMigration.cs @@ -33,10 +33,10 @@ namespace Emby.Server.Implementations.Migrations { Task.Run(() => { - var task = _taskManager.ScheduledTasks.Select(i => i.ScheduledTask) - .First(i => string.Equals(i.Key, "RefreshLibrary", StringComparison.OrdinalIgnoreCase)); - - _taskManager.QueueScheduledTask(task); + _taskManager.QueueScheduledTask(_taskManager.ScheduledTasks.Select(i => i.ScheduledTask) + .First(i => string.Equals(i.Key, "RefreshLibrary", StringComparison.OrdinalIgnoreCase))); + _taskManager.QueueScheduledTask(_taskManager.ScheduledTasks.Select(i => i.ScheduledTask) + .First(i => string.Equals(i.Key, "RefreshGuide", StringComparison.OrdinalIgnoreCase))); }); var list = _config.Configuration.Migrations.ToList();