From e91f569c154e571f52ea6a86fc3920700c317a56 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 3 Jun 2017 03:36:32 -0400 Subject: [PATCH] update live tv startup --- .../Channels/ChannelManager.cs | 6 - .../Data/SqliteItemRepository.cs | 72 +-- Emby.Server.Implementations/Dto/DtoService.cs | 5 - .../Library/LibraryManager.cs | 14 +- .../Library/UserViewManager.cs | 11 +- .../LiveTv/EmbyTV/EmbyTV.cs | 5 - .../LiveTv/LiveStreamHelper.cs | 2 +- .../TunerHosts/HdHomerun/HdHomerunHost.cs | 2 + MediaBrowser.Api/ItemUpdateService.cs | 1 - MediaBrowser.Api/Library/LibraryService.cs | 1 - MediaBrowser.Api/Playback/MediaInfoService.cs | 37 +- MediaBrowser.Api/StartupWizardService.cs | 1 - MediaBrowser.Controller/Channels/Channel.cs | 1 - .../Entities/AggregateFolder.cs | 2 +- .../Entities/Audio/Audio.cs | 2 +- .../Entities/Audio/MusicArtist.cs | 4 +- MediaBrowser.Controller/Entities/BaseItem.cs | 121 +--- .../Entities/CollectionFolder.cs | 4 +- MediaBrowser.Controller/Entities/Folder.cs | 26 +- .../Entities/IHasMetadata.cs | 2 +- .../Entities/InternalItemsQuery.cs | 4 - .../Entities/InternalPeopleQuery.cs | 2 - .../Entities/Movies/BoxSet.cs | 2 +- .../Entities/TV/Episode.cs | 574 +++++++++--------- MediaBrowser.Controller/Entities/TV/Season.cs | 2 +- .../Entities/UserRootFolder.cs | 2 +- .../Library/ILibraryManager.cs | 2 + .../LiveTv/LiveTvAudioRecording.cs | 1 - .../LiveTv/LiveTvChannel.cs | 3 +- .../LiveTv/LiveTvProgram.cs | 1 - .../LiveTv/LiveTvVideoRecording.cs | 1 - .../LiveTv/RecordingGroup.cs | 1 - .../MediaEncoding/EncodingHelper.cs | 2 +- MediaBrowser.Controller/Playlists/Playlist.cs | 2 +- .../Parsers/BaseItemXmlParser.cs | 14 - .../Savers/BaseXmlSaver.cs | 5 - .../Configuration/ServerConfiguration.cs | 2 - MediaBrowser.Model/Dto/BaseItemDto.cs | 6 - .../MediaInfo/PlaybackInfoRequest.cs | 1 + MediaBrowser.Model/Querying/ItemFields.cs | 5 - .../Manager/ProviderUtils.cs | 36 +- .../Movies/GenericMovieDbInfo.cs | 2 +- MediaBrowser.Providers/Omdb/OmdbProvider.cs | 4 +- .../TV/TheMovieDb/MovieDbEpisodeProvider.cs | 2 +- .../TV/TheMovieDb/MovieDbSeriesProvider.cs | 2 +- .../TV/TheTVDB/TvdbEpisodeProvider.cs | 2 +- .../TV/TheTVDB/TvdbSeriesProvider.cs | 2 +- .../Parsers/BaseNfoParser.cs | 15 - .../Savers/BaseNfoSaver.cs | 6 - 49 files changed, 446 insertions(+), 576 deletions(-) diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index 809771b04..66ec57dba 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -1378,12 +1378,6 @@ namespace Emby.Server.Implementations.Channels item.SetImagePath(ImageType.Primary, info.ImageUrl); } - if (item.SourceType != SourceType.Channel) - { - item.SourceType = SourceType.Channel; - forceUpdate = true; - } - if (isNew) { await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false); diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 49ba6c9f3..df3cecbf9 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -199,10 +199,11 @@ namespace Emby.Server.Implementations.Data AddColumn(db, "TypedBaseItems", "ParentId", "GUID", existingColumnNames); AddColumn(db, "TypedBaseItems", "Genres", "Text", existingColumnNames); AddColumn(db, "TypedBaseItems", "SortName", "Text", existingColumnNames); + AddColumn(db, "TypedBaseItems", "ForcedSortName", "Text", existingColumnNames); + AddColumn(db, "TypedBaseItems", "RunTimeTicks", "BIGINT", existingColumnNames); AddColumn(db, "TypedBaseItems", "HomePageUrl", "Text", existingColumnNames); - AddColumn(db, "TypedBaseItems", "VoteCount", "INT", existingColumnNames); AddColumn(db, "TypedBaseItems", "DisplayMediaType", "Text", existingColumnNames); AddColumn(db, "TypedBaseItems", "DateCreated", "DATETIME", existingColumnNames); AddColumn(db, "TypedBaseItems", "DateModified", "DATETIME", existingColumnNames); @@ -233,7 +234,6 @@ namespace Emby.Server.Implementations.Data AddColumn(db, "TypedBaseItems", "UnratedType", "Text", existingColumnNames); AddColumn(db, "TypedBaseItems", "TopParentId", "Text", existingColumnNames); AddColumn(db, "TypedBaseItems", "IsItemByName", "BIT", existingColumnNames); - AddColumn(db, "TypedBaseItems", "SourceType", "Text", existingColumnNames); AddColumn(db, "TypedBaseItems", "TrailerTypes", "Text", existingColumnNames); AddColumn(db, "TypedBaseItems", "CriticRating", "Float", existingColumnNames); AddColumn(db, "TypedBaseItems", "InheritedTags", "Text", existingColumnNames); @@ -424,9 +424,8 @@ namespace Emby.Server.Implementations.Data "OfficialRating", "HomePageUrl", "DisplayMediaType", - "SortName", + "ForcedSortName", "RunTimeTicks", - "VoteCount", "DateCreated", "DateModified", "guid", @@ -439,7 +438,6 @@ namespace Emby.Server.Implementations.Data "LockedFields", "Studios", "Tags", - "SourceType", "TrailerTypes", "OriginalTitle", "PrimaryVersionId", @@ -541,9 +539,9 @@ namespace Emby.Server.Implementations.Data "Genres", "InheritedParentalRatingValue", "SortName", + "ForcedSortName", "RunTimeTicks", "HomePageUrl", - "VoteCount", "DisplayMediaType", "DateCreated", "DateModified", @@ -563,7 +561,6 @@ namespace Emby.Server.Implementations.Data "UnratedType", "TopParentId", "IsItemByName", - "SourceType", "TrailerTypes", "CriticRating", "InheritedTags", @@ -815,10 +812,12 @@ namespace Emby.Server.Implementations.Data saveItemStatement.TryBind("@InheritedParentalRatingValue", item.InheritedParentalRatingValue); saveItemStatement.TryBind("@SortName", item.SortName); + + saveItemStatement.TryBind("@ForcedSortName", item.ForcedSortName); + saveItemStatement.TryBind("@RunTimeTicks", item.RunTimeTicks); saveItemStatement.TryBind("@HomePageUrl", item.HomePageUrl); - saveItemStatement.TryBind("@VoteCount", item.VoteCount); saveItemStatement.TryBind("@DisplayMediaType", item.DisplayMediaType); saveItemStatement.TryBind("@DateCreated", item.DateCreated); saveItemStatement.TryBind("@DateModified", item.DateModified); @@ -909,7 +908,6 @@ namespace Emby.Server.Implementations.Data isByName = dualAccess == null || dualAccess.IsAccessedByName; } saveItemStatement.TryBind("@IsItemByName", isByName); - saveItemStatement.TryBind("@SourceType", item.SourceType.ToString()); var trailer = item as Trailer; if (trailer != null && trailer.TrailerTypes.Count > 0) @@ -1624,7 +1622,7 @@ namespace Emby.Server.Implementations.Data { if (!reader.IsDBNull(index)) { - item.SortName = reader.GetString(index); + item.ForcedSortName = reader.GetString(index); } index++; } @@ -1635,15 +1633,6 @@ namespace Emby.Server.Implementations.Data } index++; - if (HasField(query, ItemFields.VoteCount)) - { - if (!reader.IsDBNull(index)) - { - item.VoteCount = reader.GetInt32(index); - } - index++; - } - if (HasField(query, ItemFields.DateCreated)) { if (!reader.IsDBNull(index)) @@ -1733,12 +1722,6 @@ namespace Emby.Server.Implementations.Data index++; } - if (!reader.IsDBNull(index)) - { - item.SourceType = (SourceType)Enum.Parse(typeof(SourceType), reader.GetString(index), true); - } - index++; - if (hasTrailerTypes) { var trailer = item as Trailer; @@ -2283,7 +2266,7 @@ namespace Emby.Server.Implementations.Data } if (field == ItemFields.SortName) { - return new[] { "SortName" }; + return new[] { "ForcedSortName" }; } if (field == ItemFields.Taglines) { @@ -2306,7 +2289,6 @@ namespace Emby.Server.Implementations.Data case ItemFields.HomePageUrl: case ItemFields.Keywords: case ItemFields.DisplayMediaType: - case ItemFields.VoteCount: case ItemFields.CustomRating: case ItemFields.ProductionLocations: case ItemFields.Settings: @@ -3872,34 +3854,6 @@ namespace Emby.Server.Implementations.Data } } - if (query.SourceTypes.Length == 1) - { - whereClauses.Add("SourceType=@SourceType"); - if (statement != null) - { - statement.TryBind("@SourceType", query.SourceTypes[0].ToString()); - } - } - else if (query.SourceTypes.Length > 1) - { - var inClause = string.Join(",", query.SourceTypes.Select(i => "'" + i + "'").ToArray()); - whereClauses.Add(string.Format("SourceType in ({0})", inClause)); - } - - if (query.ExcludeSourceTypes.Length == 1) - { - whereClauses.Add("SourceType<>@ExcludeSourceTypes"); - if (statement != null) - { - statement.TryBind("@ExcludeSourceTypes", query.ExcludeSourceTypes[0].ToString()); - } - } - else if (query.ExcludeSourceTypes.Length > 1) - { - var inClause = string.Join(",", query.ExcludeSourceTypes.Select(i => "'" + i + "'").ToArray()); - whereClauses.Add(string.Format("SourceType not in ({0})", inClause)); - } - if (query.TrailerTypes.Length > 0) { var clauses = new List(); @@ -5017,14 +4971,6 @@ namespace Emby.Server.Implementations.Data statement.TryBind("@NameContains", "%" + query.NameContains + "%"); } } - if (query.SourceTypes.Length == 1) - { - whereClauses.Add("(select sourcetype from typedbaseitems where guid=ItemId) = @SourceTypes"); - if (statement != null) - { - statement.TryBind("@SourceTypes", query.SourceTypes[0].ToString()); - } - } return whereClauses; } diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index 45fbd69dc..58621f8c1 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -1058,11 +1058,6 @@ namespace Emby.Server.Implementations.Dto dto.CommunityRating = item.CommunityRating; } - if (fields.Contains(ItemFields.VoteCount)) - { - dto.VoteCount = item.VoteCount; - } - //if (item.IsFolder) //{ // var folder = (Folder)item; diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 42eda00b7..a08c74474 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -1292,7 +1292,7 @@ namespace Emby.Server.Implementations.Library return item; } - public IEnumerable GetItemList(InternalItemsQuery query) + public IEnumerable GetItemList(InternalItemsQuery query, bool allowExternalContent) { if (query.Recursive && query.ParentId.HasValue) { @@ -1305,12 +1305,17 @@ namespace Emby.Server.Implementations.Library if (query.User != null) { - AddUserToQuery(query, query.User); + AddUserToQuery(query, query.User, allowExternalContent); } return ItemRepository.GetItemList(query); } + public IEnumerable GetItemList(InternalItemsQuery query) + { + return GetItemList(query, true); + } + public int GetCount(InternalItemsQuery query) { if (query.Recursive && query.ParentId.HasValue) @@ -1548,7 +1553,7 @@ namespace Emby.Server.Implementations.Library query.Parent = null; } - private void AddUserToQuery(InternalItemsQuery query, User user) + private void AddUserToQuery(InternalItemsQuery query, User user, bool allowExternalContent = true) { if (query.AncestorIds.Length == 0 && !query.ParentId.HasValue && @@ -1561,7 +1566,8 @@ namespace Emby.Server.Implementations.Library var userViews = _userviewManager().GetUserViews(new UserViewQuery { UserId = user.Id.ToString("N"), - IncludeHidden = true + IncludeHidden = true, + IncludeExternalContent = allowExternalContent }, CancellationToken.None).Result.ToList(); diff --git a/Emby.Server.Implementations/Library/UserViewManager.cs b/Emby.Server.Implementations/Library/UserViewManager.cs index f403ca266..a6ed84f29 100644 --- a/Emby.Server.Implementations/Library/UserViewManager.cs +++ b/Emby.Server.Implementations/Library/UserViewManager.cs @@ -280,7 +280,7 @@ namespace Emby.Server.Implementations.Library } : new string[] { }; - return _libraryManager.GetItemList(new InternalItemsQuery(user) + var query = new InternalItemsQuery(user) { IncludeItemTypes = includeItemTypes, SortOrder = SortOrder.Descending, @@ -289,11 +289,16 @@ namespace Emby.Server.Implementations.Library ExcludeItemTypes = excludeItemTypes, IsVirtualItem = false, Limit = limit * 5, - SourceTypes = parents.Count == 0 ? new[] { SourceType.Library } : new SourceType[] { }, IsPlayed = isPlayed, DtoOptions = options + }; - }, parents); + if (parents.Count == 0) + { + return _libraryManager.GetItemList(query, false); + } + + return _libraryManager.GetItemList(query, parents); } } } diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 6ce2b88f1..a4c5b338e 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -2270,11 +2270,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV writer.WriteElementString("studio", studio); } - if (item.VoteCount.HasValue) - { - writer.WriteElementString("votes", item.VoteCount.Value.ToString(CultureInfo.InvariantCulture)); - } - writer.WriteEndElement(); writer.WriteEndDocument(); } diff --git a/Emby.Server.Implementations/LiveTv/LiveStreamHelper.cs b/Emby.Server.Implementations/LiveTv/LiveStreamHelper.cs index d56ddc57d..12da1464b 100644 --- a/Emby.Server.Implementations/LiveTv/LiveStreamHelper.cs +++ b/Emby.Server.Implementations/LiveTv/LiveStreamHelper.cs @@ -16,7 +16,7 @@ namespace Emby.Server.Implementations.LiveTv private readonly IMediaEncoder _mediaEncoder; private readonly ILogger _logger; - const int AnalyzeDurationMs = 2000; + const int AnalyzeDurationMs = 1000; public LiveStreamHelper(IMediaEncoder mediaEncoder, ILogger logger) { diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index 2afc3744f..153f86aed 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -422,6 +422,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun SupportsTranscoding = true, IsInfiniteStream = true, IgnoreDts = true, + //SupportsProbing = false, + //AnalyzeDurationMs = 2000000 //IgnoreIndex = true, //ReadAtNativeFramerate = true }; diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index cdc33dfd4..58bce3856 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -243,7 +243,6 @@ namespace MediaBrowser.Api item.DisplayMediaType = request.DisplayMediaType; item.CommunityRating = request.CommunityRating; - item.VoteCount = request.VoteCount; item.HomePageUrl = request.HomePageUrl; item.IndexNumber = request.IndexNumber; item.ParentIndexNumber = request.ParentIndexNumber; diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index 4e0bdc8a9..4112eb444 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -675,7 +675,6 @@ namespace MediaBrowser.Api.Library Limit = 0, Recursive = true, IsVirtualItem = false, - SourceTypes = new[] { SourceType.Library }, IsFavorite = request.IsFavorite, DtoOptions = new DtoOptions(false) { diff --git a/MediaBrowser.Api/Playback/MediaInfoService.cs b/MediaBrowser.Api/Playback/MediaInfoService.cs index 55fe738e8..911d92555 100644 --- a/MediaBrowser.Api/Playback/MediaInfoService.cs +++ b/MediaBrowser.Api/Playback/MediaInfoService.cs @@ -106,6 +106,13 @@ namespace MediaBrowser.Api.Playback } public async Task Post(OpenMediaSource request) + { + var result = await OpenMediaSource(request).ConfigureAwait(false); + + return ToOptimizedResult(result); + } + + private async Task OpenMediaSource(OpenMediaSource request) { var authInfo = _authContext.GetAuthorizationInfo(Request); @@ -137,7 +144,7 @@ namespace MediaBrowser.Api.Playback } } - return ToOptimizedResult(result); + return result; } public void Post(CloseMediaSource request) @@ -172,6 +179,34 @@ namespace MediaBrowser.Api.Playback SetDeviceSpecificData(request.Id, info, profile, authInfo, request.MaxStreamingBitrate ?? profile.MaxStreamingBitrate, request.StartTimeTicks ?? 0, mediaSourceId, request.AudioStreamIndex, request.SubtitleStreamIndex, request.MaxAudioChannels, request.UserId, request.EnableDirectPlay, request.ForceDirectPlayRemoteMediaSource, request.EnableDirectStream, request.EnableTranscoding, request.AllowVideoStreamCopy, request.AllowAudioStreamCopy); } + if (request.AutoOpenLiveStream) + { + var mediaSource = string.IsNullOrWhiteSpace(request.MediaSourceId) ? info.MediaSources.FirstOrDefault() : info.MediaSources.FirstOrDefault(i => string.Equals(i.Id, request.MediaSourceId, StringComparison.Ordinal)); + + if (mediaSource != null && mediaSource.RequiresOpening && string.IsNullOrWhiteSpace(mediaSource.LiveStreamId)) + { + var openStreamResult = await OpenMediaSource(new OpenMediaSource + { + AudioStreamIndex = request.AudioStreamIndex, + DeviceProfile = request.DeviceProfile, + EnableDirectPlay = request.EnableDirectPlay, + EnableDirectStream = request.EnableDirectStream, + ForceDirectPlayRemoteMediaSource = request.ForceDirectPlayRemoteMediaSource, + ItemId = request.Id, + MaxAudioChannels = request.MaxAudioChannels, + MaxStreamingBitrate = request.MaxStreamingBitrate, + PlaySessionId = info.PlaySessionId, + StartTimeTicks = request.StartTimeTicks, + SubtitleStreamIndex = request.SubtitleStreamIndex, + UserId = request.UserId, + OpenToken = mediaSource.OpenToken + + }).ConfigureAwait(false); + + info.MediaSources = new List { openStreamResult.MediaSource }; + } + } + return info; } diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.cs index 2df6d225b..cd56b69bd 100644 --- a/MediaBrowser.Api/StartupWizardService.cs +++ b/MediaBrowser.Api/StartupWizardService.cs @@ -100,7 +100,6 @@ namespace MediaBrowser.Api config.EnableSimpleArtistDetection = true; config.EnableNormalizedItemByNameIds = true; config.DisableLiveTvChannelUserDataName = true; - config.EnableSimpleSortNameHandling = true; } public void Post(UpdateStartupConfiguration request) diff --git a/MediaBrowser.Controller/Channels/Channel.cs b/MediaBrowser.Controller/Channels/Channel.cs index 35c2ea1aa..862c8e5ac 100644 --- a/MediaBrowser.Controller/Channels/Channel.cs +++ b/MediaBrowser.Controller/Channels/Channel.cs @@ -35,7 +35,6 @@ namespace MediaBrowser.Controller.Channels public override SourceType SourceType { get { return SourceType.Channel; } - set { } } protected override QueryResult GetItemsInternal(InternalItemsQuery query) diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs index fe8ac0919..e8ebbdb70 100644 --- a/MediaBrowser.Controller/Entities/AggregateFolder.cs +++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs @@ -87,7 +87,7 @@ namespace MediaBrowser.Controller.Entities private List _childrenIds = null; private readonly object _childIdsLock = new object(); - protected override IEnumerable LoadChildren() + protected override List LoadChildren() { lock (_childIdsLock) { diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index 4d35531cb..873ac3104 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -131,7 +131,7 @@ namespace MediaBrowser.Controller.Entities.Audio /// Creates the name of the sort. /// /// System.String. - protected override string CreateSortNameInternal() + protected override string CreateSortName() { return (ParentIndexNumber != null ? ParentIndexNumber.Value.ToString("0000 - ") : "") + (IndexNumber != null ? IndexNumber.Value.ToString("0000 - ") : "") + Name; diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index b0b9493a5..4b232de49 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -90,7 +90,7 @@ namespace MediaBrowser.Controller.Entities.Audio } [IgnoreDataMember] - protected override IEnumerable ActualChildren + public override IEnumerable Children { get { @@ -99,7 +99,7 @@ namespace MediaBrowser.Controller.Entities.Audio return new List(); } - return base.ActualChildren; + return base.Children; } } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 346442f59..4efea94d8 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -54,7 +54,6 @@ namespace MediaBrowser.Controller.Entities ImageInfos = new List(); InheritedTags = new List(); ProductionLocations = new List(); - SourceType = SourceType.Library; } public static readonly char[] SlugReplaceChars = { '?', '/', '&' }; @@ -187,15 +186,10 @@ namespace MediaBrowser.Controller.Entities } set { - var isSortNameDefault = IsSortNameDefault(SortName); - _name = value; - if (isSortNameDefault) - { - // lazy load this again - SortName = null; - } + // lazy load this again + _sortName = null; } } @@ -279,7 +273,18 @@ namespace MediaBrowser.Controller.Entities public virtual string Path { get; set; } [IgnoreDataMember] - public virtual SourceType SourceType { get; set; } + public virtual SourceType SourceType + { + get + { + if (!string.IsNullOrWhiteSpace(ChannelId)) + { + return SourceType.Channel; + } + + return SourceType.Library; + } + } /// /// Returns the folder containing the item. @@ -586,6 +591,7 @@ namespace MediaBrowser.Controller.Entities } } + private string _forcedSortName; /// /// Gets or sets the name of the forced sort. /// @@ -593,42 +599,8 @@ namespace MediaBrowser.Controller.Entities [IgnoreDataMember] public string ForcedSortName { - get - { - var sortName = SortName; - - if (string.IsNullOrWhiteSpace(sortName)) - { - return null; - } - - if (string.Equals(sortName, CreateSortName(), StringComparison.OrdinalIgnoreCase)) - { - return null; - } - - return sortName; - } - set - { - if (string.IsNullOrWhiteSpace(value)) - { - SortName = null; - } - else - { - var newValue = CreateSortNameFromCustomValue(value); - - if (string.Equals(newValue, CreateSortName(), StringComparison.OrdinalIgnoreCase)) - { - SortName = null; - } - else - { - SortName = newValue; - } - } - } + get { return _forcedSortName; } + set { _forcedSortName = value; _sortName = null; } } private string _sortName; @@ -643,7 +615,15 @@ namespace MediaBrowser.Controller.Entities { if (_sortName == null) { - _sortName = CreateSortName(); + if (!string.IsNullOrWhiteSpace(ForcedSortName)) + { + // Need the ToLower because that's what CreateSortName does + _sortName = ModifySortChunks(ForcedSortName).ToLower(); + } + else + { + _sortName = CreateSortName(); + } } return _sortName; } @@ -653,31 +633,6 @@ namespace MediaBrowser.Controller.Entities } } - private string CreateSortNameFromCustomValue(string value) - { - return string.IsNullOrWhiteSpace(value) ? null : NormalizeCustomSortName(value); - } - - protected virtual string NormalizeCustomSortName(string value) - { - if (ConfigurationManager.Configuration.EnableSimpleSortNameHandling) - { - return value.RemoveDiacritics().ToLower(); - } - - return ModifySortChunks(value).ToLower(); - } - - public bool IsSortNameDefault(string value) - { - if (string.IsNullOrWhiteSpace(value)) - { - return true; - } - - return string.Equals(CreateSortNameFromCustomValue(value), CreateSortName(), StringComparison.OrdinalIgnoreCase); - } - public string GetInternalMetadataPath() { var basePath = ConfigurationManager.ApplicationPaths.InternalMetadataPath; @@ -699,22 +654,14 @@ namespace MediaBrowser.Controller.Entities return System.IO.Path.Combine(basePath, idString.Substring(0, 2), idString); } - protected string CreateSortName() - { - if (string.IsNullOrWhiteSpace(Name)) - { - return null; - } - - return CreateSortNameInternal(); - } - /// /// Creates the name of the sort. /// /// System.String. - protected virtual string CreateSortNameInternal() + protected virtual string CreateSortName() { + if (Name == null) return null; //some items may not have name filled in properly + if (!EnableAlphaNumericSorting) { return Name.TrimStart(); @@ -951,13 +898,6 @@ namespace MediaBrowser.Controller.Entities [IgnoreDataMember] public float? CommunityRating { get; set; } - /// - /// Gets or sets the community rating vote count. - /// - /// The community rating vote count. - [IgnoreDataMember] - public int? VoteCount { get; set; } - /// /// Gets or sets the run time ticks. /// @@ -1367,6 +1307,7 @@ namespace MediaBrowser.Controller.Entities public void AfterMetadataRefresh() { + _sortName = null; } /// @@ -2253,6 +2194,8 @@ namespace MediaBrowser.Controller.Entities /// public virtual bool BeforeMetadataRefresh() { + _sortName = null; + var hasChanges = false; if (string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Path)) diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index 0a5faa727..8bc23a581 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -311,12 +311,12 @@ namespace MediaBrowser.Controller.Entities /// /// The actual children. [IgnoreDataMember] - protected override IEnumerable ActualChildren + public override IEnumerable Children { get { return GetActualChildren(); } } - private IEnumerable GetActualChildren() + public IEnumerable GetActualChildren() { return GetPhysicalFolders(true).SelectMany(c => c.Children); } diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 7566911a1..48c9b83aa 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -185,7 +185,7 @@ namespace MediaBrowser.Controller.Entities item.Id = LibraryManager.GetNewItemId(item.Path, item.GetType()); } - if (ActualChildren.Any(i => i.Id == item.Id)) + if (Children.Any(i => i.Id == item.Id)) { throw new ArgumentException(string.Format("A child with the Id {0} already exists.", item.Id)); } @@ -243,7 +243,7 @@ namespace MediaBrowser.Controller.Entities /// /// The actual children. [IgnoreDataMember] - protected virtual IEnumerable ActualChildren + public virtual IEnumerable Children { get { @@ -251,16 +251,6 @@ namespace MediaBrowser.Controller.Entities } } - /// - /// thread-safe access to the actual children of this folder - without regard to user - /// - /// The children. - [IgnoreDataMember] - public IEnumerable Children - { - get { return ActualChildren.ToList(); } - } - /// /// thread-safe access to all recursive children of this folder - without regard to user /// @@ -301,7 +291,7 @@ namespace MediaBrowser.Controller.Entities /// Loads our children. Validation will occur externally. /// We want this sychronous. /// - protected virtual IEnumerable LoadChildren() + protected virtual List LoadChildren() { //Logger.Debug("Loading children from {0} {1} {2}", GetType().Name, Id, Path); //just load our children from the repo - the library will be validated and maintained in other processes @@ -330,7 +320,9 @@ namespace MediaBrowser.Controller.Entities { var dictionary = new Dictionary(); - foreach (var child in ActualChildren) + var childrenList = Children.ToList(); + + foreach (var child in childrenList) { var id = child.Id; if (dictionary.ContainsKey(id)) @@ -466,7 +458,7 @@ namespace MediaBrowser.Controller.Entities if (recursive) { - await ValidateSubFolders(ActualChildren.OfType().ToList(), directoryService, progress, cancellationToken).ConfigureAwait(false); + await ValidateSubFolders(Children.ToList().OfType().ToList(), directoryService, progress, cancellationToken).ConfigureAwait(false); } progress.Report(20); @@ -494,7 +486,7 @@ namespace MediaBrowser.Controller.Entities private async Task RefreshMetadataRecursive(MetadataRefreshOptions refreshOptions, bool recursive, IProgress progress, CancellationToken cancellationToken) { - var children = ActualChildren.ToList(); + var children = Children.ToList(); var percentages = new Dictionary(children.Count); var numComplete = 0; @@ -668,7 +660,7 @@ namespace MediaBrowser.Controller.Entities /// Get our children from the repo - stubbed for now /// /// IEnumerable{BaseItem}. - protected IEnumerable GetCachedChildren() + protected List GetCachedChildren() { return ItemRepository.GetItemList(new InternalItemsQuery { diff --git a/MediaBrowser.Controller/Entities/IHasMetadata.cs b/MediaBrowser.Controller/Entities/IHasMetadata.cs index aee58b445..62c67336c 100644 --- a/MediaBrowser.Controller/Entities/IHasMetadata.cs +++ b/MediaBrowser.Controller/Entities/IHasMetadata.cs @@ -26,7 +26,7 @@ namespace MediaBrowser.Controller.Entities /// The date last saved. DateTime DateLastSaved { get; set; } - SourceType SourceType { get; set; } + SourceType SourceType { get; } /// /// Gets or sets the date last refreshed. diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index 743e7642e..f3caac492 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -148,8 +148,6 @@ namespace MediaBrowser.Controller.Entities } public string[] PresetViews { get; set; } - public SourceType[] SourceTypes { get; set; } - public SourceType[] ExcludeSourceTypes { get; set; } public TrailerType[] TrailerTypes { get; set; } public DayOfWeek[] AirDays { get; set; } @@ -215,8 +213,6 @@ namespace MediaBrowser.Controller.Entities ExcludeTags = new string[] { }; ExcludeInheritedTags = new string[] { }; PresetViews = new string[] { }; - SourceTypes = new SourceType[] { }; - ExcludeSourceTypes = new SourceType[] { }; TrailerTypes = new TrailerType[] { }; AirDays = new DayOfWeek[] { }; SeriesStatuses = new SeriesStatus[] { }; diff --git a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs index 2ba6842ca..05d23d986 100644 --- a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs @@ -11,13 +11,11 @@ namespace MediaBrowser.Controller.Entities public int? MaxListOrder { get; set; } public Guid AppearsInItemId { get; set; } public string NameContains { get; set; } - public SourceType[] SourceTypes { get; set; } public InternalPeopleQuery() { PersonTypes = new List(); ExcludePersonTypes = new List(); - SourceTypes = new SourceType[] { }; } } } diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index efa85f3ae..406a99f8b 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -79,7 +79,7 @@ namespace MediaBrowser.Controller.Entities.Movies return new List(); } - protected override IEnumerable LoadChildren() + protected override List LoadChildren() { if (IsLegacyBoxSet) { diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs index e963ab184..45b4de1b3 100644 --- a/MediaBrowser.Controller/Entities/TV/Episode.cs +++ b/MediaBrowser.Controller/Entities/TV/Episode.cs @@ -1,19 +1,19 @@ -using MediaBrowser.Controller.Providers; -using MediaBrowser.Model.Configuration; -using MediaBrowser.Model.Entities; -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using MediaBrowser.Model.IO; -using MediaBrowser.Model.Serialization; - -namespace MediaBrowser.Controller.Entities.TV -{ - /// - /// Class Episode - /// - public class Episode : Video, IHasTrailers, IHasLookupInfo, IHasSeries +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Configuration; +using MediaBrowser.Model.Entities; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using MediaBrowser.Model.IO; +using MediaBrowser.Model.Serialization; + +namespace MediaBrowser.Controller.Entities.TV +{ + /// + /// Class Episode + /// + public class Episode : Video, IHasTrailers, IHasLookupInfo, IHasSeries { public Episode() { @@ -26,35 +26,35 @@ namespace MediaBrowser.Controller.Entities.TV public List RemoteTrailerIds { get; set; } public List RemoteTrailers { get; set; } - /// - /// Gets the season in which it aired. - /// - /// The aired season. - public int? AirsBeforeSeasonNumber { get; set; } - public int? AirsAfterSeasonNumber { get; set; } - public int? AirsBeforeEpisodeNumber { get; set; } - - /// - /// Gets or sets the DVD season number. - /// - /// The DVD season number. - public int? DvdSeasonNumber { get; set; } - /// - /// Gets or sets the DVD episode number. - /// - /// The DVD episode number. - public float? DvdEpisodeNumber { get; set; } - - /// - /// Gets or sets the absolute episode number. - /// - /// The absolute episode number. - public int? AbsoluteEpisodeNumber { get; set; } - - /// - /// This is the ending episode number for double episodes. - /// - /// The index number. + /// + /// Gets the season in which it aired. + /// + /// The aired season. + public int? AirsBeforeSeasonNumber { get; set; } + public int? AirsAfterSeasonNumber { get; set; } + public int? AirsBeforeEpisodeNumber { get; set; } + + /// + /// Gets or sets the DVD season number. + /// + /// The DVD season number. + public int? DvdSeasonNumber { get; set; } + /// + /// Gets or sets the DVD episode number. + /// + /// The DVD episode number. + public float? DvdEpisodeNumber { get; set; } + + /// + /// Gets or sets the absolute episode number. + /// + /// The absolute episode number. + public int? AbsoluteEpisodeNumber { get; set; } + + /// + /// This is the ending episode number for double episodes. + /// + /// The index number. public int? IndexNumberEnd { get; set; } public string FindSeriesSortName() @@ -62,56 +62,56 @@ namespace MediaBrowser.Controller.Entities.TV var series = Series; return series == null ? SeriesName : series.SortName; } - - [IgnoreDataMember] - protected override bool SupportsOwnedItems - { - get - { - return IsStacked || MediaSourceCount > 1; - } + + [IgnoreDataMember] + protected override bool SupportsOwnedItems + { + get + { + return IsStacked || MediaSourceCount > 1; + } } [IgnoreDataMember] public override bool SupportsInheritedParentImages { get { return true; } - } - - [IgnoreDataMember] - public int? AiredSeasonNumber - { - get - { - return AirsAfterSeasonNumber ?? AirsBeforeSeasonNumber ?? ParentIndexNumber; - } - } - - [IgnoreDataMember] - public override Folder LatestItemsIndexContainer - { - get - { - return Series; - } - } - - [IgnoreDataMember] - public override Guid? DisplayParentId - { - get - { - return SeasonId; - } - } - - [IgnoreDataMember] - protected override bool EnableDefaultVideoUserDataKeys - { - get - { - return false; - } + } + + [IgnoreDataMember] + public int? AiredSeasonNumber + { + get + { + return AirsAfterSeasonNumber ?? AirsBeforeSeasonNumber ?? ParentIndexNumber; + } + } + + [IgnoreDataMember] + public override Folder LatestItemsIndexContainer + { + get + { + return Series; + } + } + + [IgnoreDataMember] + public override Guid? DisplayParentId + { + get + { + return SeasonId; + } + } + + [IgnoreDataMember] + protected override bool EnableDefaultVideoUserDataKeys + { + get + { + return false; + } } public override double? GetDefaultPrimaryImageAspectRatio() @@ -120,64 +120,64 @@ namespace MediaBrowser.Controller.Entities.TV value /= 9; return value; - } - - public override List GetUserDataKeys() - { - var list = base.GetUserDataKeys(); - - var series = Series; - if (series != null && ParentIndexNumber.HasValue && IndexNumber.HasValue) - { - var seriesUserDataKeys = series.GetUserDataKeys(); - var take = seriesUserDataKeys.Count; - if (seriesUserDataKeys.Count > 1) - { - take--; - } - list.InsertRange(0, seriesUserDataKeys.Take(take).Select(i => i + ParentIndexNumber.Value.ToString("000") + IndexNumber.Value.ToString("000"))); - } - - return list; - } - - /// - /// This Episode's Series Instance - /// - /// The series. - [IgnoreDataMember] - public Series Series - { - get - { + } + + public override List GetUserDataKeys() + { + var list = base.GetUserDataKeys(); + + var series = Series; + if (series != null && ParentIndexNumber.HasValue && IndexNumber.HasValue) + { + var seriesUserDataKeys = series.GetUserDataKeys(); + var take = seriesUserDataKeys.Count; + if (seriesUserDataKeys.Count > 1) + { + take--; + } + list.InsertRange(0, seriesUserDataKeys.Take(take).Select(i => i + ParentIndexNumber.Value.ToString("000") + IndexNumber.Value.ToString("000"))); + } + + return list; + } + + /// + /// This Episode's Series Instance + /// + /// The series. + [IgnoreDataMember] + public Series Series + { + get + { var seriesId = SeriesId ?? FindSeriesId(); - return seriesId.HasValue ? (LibraryManager.GetItemById(seriesId.Value) as Series) : null; - } - } - - [IgnoreDataMember] - public Season Season - { - get - { + return seriesId.HasValue ? (LibraryManager.GetItemById(seriesId.Value) as Series) : null; + } + } + + [IgnoreDataMember] + public Season Season + { + get + { var seasonId = SeasonId ?? FindSeasonId(); - return seasonId.HasValue ? (LibraryManager.GetItemById(seasonId.Value) as Season) : null; - } - } - - [IgnoreDataMember] - public bool IsInSeasonFolder - { - get - { - return FindParent() != null; - } + return seasonId.HasValue ? (LibraryManager.GetItemById(seasonId.Value) as Season) : null; + } + } + + [IgnoreDataMember] + public bool IsInSeasonFolder + { + get + { + return FindParent() != null; + } } [IgnoreDataMember] public string SeriesPresentationUniqueKey { get; set; } - - [IgnoreDataMember] + + [IgnoreDataMember] public string SeriesName { get; set; } [IgnoreDataMember] @@ -187,17 +187,17 @@ namespace MediaBrowser.Controller.Entities.TV { var series = Series; return series == null ? null : series.PresentationUniqueKey; - } - - public string FindSeasonName() + } + + public string FindSeasonName() { - var season = Season; - - if (season == null) - { - if (ParentIndexNumber.HasValue) - { - return "Season " + ParentIndexNumber.Value.ToString(CultureInfo.InvariantCulture); + var season = Season; + + if (season == null) + { + if (ParentIndexNumber.HasValue) + { + return "Season " + ParentIndexNumber.Value.ToString(CultureInfo.InvariantCulture); } return "Season Unknown"; } @@ -231,92 +231,92 @@ namespace MediaBrowser.Controller.Entities.TV } return season == null ? (Guid?)null : season.Id; - } - - /// - /// Creates the name of the sort. - /// - /// System.String. - protected override string CreateSortNameInternal() - { - return (ParentIndexNumber != null ? ParentIndexNumber.Value.ToString("000 - ") : "") - + (IndexNumber != null ? IndexNumber.Value.ToString("0000 - ") : "") + Name; - } - - /// - /// Determines whether [contains episode number] [the specified number]. - /// - /// The number. - /// true if [contains episode number] [the specified number]; otherwise, false. - public bool ContainsEpisodeNumber(int number) - { - if (IndexNumber.HasValue) - { - if (IndexNumberEnd.HasValue) - { - return number >= IndexNumber.Value && number <= IndexNumberEnd.Value; - } - - return IndexNumber.Value == number; - } - - return false; - } - - [IgnoreDataMember] - public override bool SupportsRemoteImageDownloading - { - get - { - if (IsMissingEpisode) - { - return false; - } - - return true; - } - } - - [IgnoreDataMember] - public bool IsMissingEpisode - { - get - { - return LocationType == LocationType.Virtual && !IsUnaired; - } - } - - [IgnoreDataMember] - public bool IsVirtualUnaired - { - get { return LocationType == LocationType.Virtual && IsUnaired; } - } - - [IgnoreDataMember] + } + + /// + /// Creates the name of the sort. + /// + /// System.String. + protected override string CreateSortName() + { + return (ParentIndexNumber != null ? ParentIndexNumber.Value.ToString("000 - ") : "") + + (IndexNumber != null ? IndexNumber.Value.ToString("0000 - ") : "") + Name; + } + + /// + /// Determines whether [contains episode number] [the specified number]. + /// + /// The number. + /// true if [contains episode number] [the specified number]; otherwise, false. + public bool ContainsEpisodeNumber(int number) + { + if (IndexNumber.HasValue) + { + if (IndexNumberEnd.HasValue) + { + return number >= IndexNumber.Value && number <= IndexNumberEnd.Value; + } + + return IndexNumber.Value == number; + } + + return false; + } + + [IgnoreDataMember] + public override bool SupportsRemoteImageDownloading + { + get + { + if (IsMissingEpisode) + { + return false; + } + + return true; + } + } + + [IgnoreDataMember] + public bool IsMissingEpisode + { + get + { + return LocationType == LocationType.Virtual && !IsUnaired; + } + } + + [IgnoreDataMember] + public bool IsVirtualUnaired + { + get { return LocationType == LocationType.Virtual && IsUnaired; } + } + + [IgnoreDataMember] public Guid? SeasonId { get; set; } [IgnoreDataMember] public Guid? SeriesId { get; set; } public Guid? FindSeriesId() { - var series = FindParent(); + var series = FindParent(); return series == null ? (Guid?)null : series.Id; - } - - public override IEnumerable GetAncestorIds() - { - var list = base.GetAncestorIds().ToList(); - - var seasonId = SeasonId; - - if (seasonId.HasValue && !list.Contains(seasonId.Value)) - { - list.Add(seasonId.Value); - } - - return list; - } - + } + + public override IEnumerable GetAncestorIds() + { + var list = base.GetAncestorIds().ToList(); + + var seasonId = SeasonId; + + if (seasonId.HasValue && !list.Contains(seasonId.Value)) + { + list.Add(seasonId.Value); + } + + return list; + } + public override IEnumerable GetDeletePaths() { return new[] { @@ -327,60 +327,60 @@ namespace MediaBrowser.Controller.Entities.TV } }.Concat(GetLocalMetadataFilesToDelete()); } - - public override UnratedItem GetBlockUnratedType() - { - return UnratedItem.Series; - } - - public EpisodeInfo GetLookupInfo() - { - var id = GetItemLookupInfo(); - - var series = Series; - - if (series != null) - { - id.SeriesProviderIds = series.ProviderIds; - } - - id.IsMissingEpisode = IsMissingEpisode; - id.IndexNumberEnd = IndexNumberEnd; - id.IsVirtualUnaired = IsVirtualUnaired; - - return id; - } - - public override bool BeforeMetadataRefresh() - { - var hasChanges = base.BeforeMetadataRefresh(); - - try - { - if (LibraryManager.FillMissingEpisodeNumbersFromPath(this)) - { - hasChanges = true; - } - } - catch (Exception ex) - { - Logger.ErrorException("Error in FillMissingEpisodeNumbersFromPath. Episode: {0}", ex, Path ?? Name ?? Id.ToString()); - } - - if (!ParentIndexNumber.HasValue) - { - var season = Season; - if (season != null) - { - if (season.ParentIndexNumber.HasValue) - { - ParentIndexNumber = season.ParentIndexNumber; - hasChanges = true; - } - } - } - - return hasChanges; - } - } -} + + public override UnratedItem GetBlockUnratedType() + { + return UnratedItem.Series; + } + + public EpisodeInfo GetLookupInfo() + { + var id = GetItemLookupInfo(); + + var series = Series; + + if (series != null) + { + id.SeriesProviderIds = series.ProviderIds; + } + + id.IsMissingEpisode = IsMissingEpisode; + id.IndexNumberEnd = IndexNumberEnd; + id.IsVirtualUnaired = IsVirtualUnaired; + + return id; + } + + public override bool BeforeMetadataRefresh() + { + var hasChanges = base.BeforeMetadataRefresh(); + + try + { + if (LibraryManager.FillMissingEpisodeNumbersFromPath(this)) + { + hasChanges = true; + } + } + catch (Exception ex) + { + Logger.ErrorException("Error in FillMissingEpisodeNumbersFromPath. Episode: {0}", ex, Path ?? Name ?? Id.ToString()); + } + + if (!ParentIndexNumber.HasValue) + { + var season = Season; + if (season != null) + { + if (season.ParentIndexNumber.HasValue) + { + ParentIndexNumber = season.ParentIndexNumber; + hasChanges = true; + } + } + } + + return hasChanges; + } + } +} diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index 4ccf6d623..17494eb08 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -145,7 +145,7 @@ namespace MediaBrowser.Controller.Entities.TV /// Creates the name of the sort. /// /// System.String. - protected override string CreateSortNameInternal() + protected override string CreateSortName() { return IndexNumber != null ? IndexNumber.Value.ToString("0000") : Name; } diff --git a/MediaBrowser.Controller/Entities/UserRootFolder.cs b/MediaBrowser.Controller/Entities/UserRootFolder.cs index c93c81401..3e4931e77 100644 --- a/MediaBrowser.Controller/Entities/UserRootFolder.cs +++ b/MediaBrowser.Controller/Entities/UserRootFolder.cs @@ -18,7 +18,7 @@ namespace MediaBrowser.Controller.Entities { private List _childrenIds = null; private readonly object _childIdsLock = new object(); - protected override IEnumerable LoadChildren() + protected override List LoadChildren() { lock (_childIdsLock) { diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 3f6b5a806..5a702b4f0 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -527,6 +527,8 @@ namespace MediaBrowser.Controller.Library /// QueryResult<BaseItem>. IEnumerable GetItemList(InternalItemsQuery query); + IEnumerable GetItemList(InternalItemsQuery query, bool allowExternalContent); + /// /// Gets the items. /// diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs index 8501f1580..45786e795 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs @@ -43,7 +43,6 @@ namespace MediaBrowser.Controller.LiveTv public override SourceType SourceType { get { return SourceType.LiveTV; } - set { } } [IgnoreDataMember] diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs index 34a9103f8..898ea9ff4 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs @@ -55,7 +55,6 @@ namespace MediaBrowser.Controller.LiveTv public override SourceType SourceType { get { return SourceType.LiveTV; } - set { } } [IgnoreDataMember] @@ -89,7 +88,7 @@ namespace MediaBrowser.Controller.LiveTv } } - protected override string CreateSortNameInternal() + protected override string CreateSortName() { if (!string.IsNullOrEmpty(Number)) { diff --git a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs index 5919d87fd..665640dfd 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs @@ -65,7 +65,6 @@ namespace MediaBrowser.Controller.LiveTv public override SourceType SourceType { get { return SourceType.LiveTV; } - set { } } /// diff --git a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs index 18894120a..2b527c4b0 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs @@ -42,7 +42,6 @@ namespace MediaBrowser.Controller.LiveTv public override SourceType SourceType { get { return SourceType.LiveTV; } - set { } } [IgnoreDataMember] diff --git a/MediaBrowser.Controller/LiveTv/RecordingGroup.cs b/MediaBrowser.Controller/LiveTv/RecordingGroup.cs index 8093b5a76..b54ca8974 100644 --- a/MediaBrowser.Controller/LiveTv/RecordingGroup.cs +++ b/MediaBrowser.Controller/LiveTv/RecordingGroup.cs @@ -30,7 +30,6 @@ namespace MediaBrowser.Controller.LiveTv public override SourceType SourceType { get { return SourceType.LiveTV; } - set { } } } } diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 54a361ff7..82d18a373 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -1604,7 +1604,7 @@ namespace MediaBrowser.Controller.MediaEncoding } // Only do this for video files due to sometimes unpredictable codec names coming from BDInfo - if (state.RunTimeTicks.HasValue && state.VideoType == VideoType.VideoFile && string.IsNullOrWhiteSpace(encodingOptions.HardwareAccelerationType)) + if (state.VideoType == VideoType.VideoFile && string.IsNullOrWhiteSpace(encodingOptions.HardwareAccelerationType)) { foreach (var stream in state.MediaSource.MediaStreams) { diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index 790e8e824..854f8d7a2 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -74,7 +74,7 @@ namespace MediaBrowser.Controller.Playlists return true; } - protected override IEnumerable LoadChildren() + protected override List LoadChildren() { // Save a trip to the database return new List(); diff --git a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs index 53327deca..2edccf8c8 100644 --- a/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs +++ b/MediaBrowser.LocalMetadata/Parsers/BaseItemXmlParser.cs @@ -598,20 +598,6 @@ namespace MediaBrowser.LocalMetadata.Parsers break; } - case "VoteCount": - { - var val = reader.ReadElementContentAsString(); - if (!string.IsNullOrWhiteSpace(val)) - { - int num; - - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out num)) - { - item.VoteCount = num; - } - } - break; - } case "CollectionNumber": var tmdbCollection = reader.ReadElementContentAsString(); if (!string.IsNullOrWhiteSpace(tmdbCollection)) diff --git a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs index dab637a34..4eec33003 100644 --- a/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs +++ b/MediaBrowser.LocalMetadata/Savers/BaseXmlSaver.cs @@ -109,7 +109,6 @@ namespace MediaBrowser.LocalMetadata.Savers "TvDbId", "Type", "TVRageId", - "VoteCount", "Website", "Zap2ItId", "CollectionItems", @@ -407,10 +406,6 @@ namespace MediaBrowser.LocalMetadata.Savers { writer.WriteElementString("Rating", item.CommunityRating.Value.ToString(UsCulture)); } - if (item.VoteCount.HasValue) - { - writer.WriteElementString("VoteCount", item.VoteCount.Value.ToString(UsCulture)); - } if (item.ProductionYear.HasValue && !(item is Person)) { diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index e30364de9..4529de59a 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -17,8 +17,6 @@ namespace MediaBrowser.Model.Configuration /// true if [enable u pn p]; otherwise, false. public bool EnableUPnP { get; set; } - public bool EnableSimpleSortNameHandling { get; set; } - /// /// Gets or sets the public mapped port. /// diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs index d44659705..f53e3ae65 100644 --- a/MediaBrowser.Model/Dto/BaseItemDto.cs +++ b/MediaBrowser.Model/Dto/BaseItemDto.cs @@ -221,12 +221,6 @@ namespace MediaBrowser.Model.Dto /// The community rating. public float? CommunityRating { get; set; } - /// - /// Gets or sets the vote count. - /// - /// The vote count. - public int? VoteCount { get; set; } - /// /// Gets or sets the cumulative run time ticks. /// diff --git a/MediaBrowser.Model/MediaInfo/PlaybackInfoRequest.cs b/MediaBrowser.Model/MediaInfo/PlaybackInfoRequest.cs index 0518064c9..1843fb69a 100644 --- a/MediaBrowser.Model/MediaInfo/PlaybackInfoRequest.cs +++ b/MediaBrowser.Model/MediaInfo/PlaybackInfoRequest.cs @@ -30,6 +30,7 @@ namespace MediaBrowser.Model.MediaInfo public bool ForceDirectPlayRemoteMediaSource { get; set; } public bool AllowVideoStreamCopy { get; set; } public bool AllowAudioStreamCopy { get; set; } + public bool AutoOpenLiveStream { get; set; } public PlaybackInfoRequest() { diff --git a/MediaBrowser.Model/Querying/ItemFields.cs b/MediaBrowser.Model/Querying/ItemFields.cs index 9a7052089..85d0a0baf 100644 --- a/MediaBrowser.Model/Querying/ItemFields.cs +++ b/MediaBrowser.Model/Querying/ItemFields.cs @@ -206,11 +206,6 @@ /// Tags, - /// - /// The vote count - /// - VoteCount, - /// /// The trailer url of the item /// diff --git a/MediaBrowser.Providers/Manager/ProviderUtils.cs b/MediaBrowser.Providers/Manager/ProviderUtils.cs index 1e107d0be..042b7241b 100644 --- a/MediaBrowser.Providers/Manager/ProviderUtils.cs +++ b/MediaBrowser.Providers/Manager/ProviderUtils.cs @@ -180,11 +180,6 @@ namespace MediaBrowser.Providers.Manager } } - if (replaceData || !target.VoteCount.HasValue) - { - target.VoteCount = source.VoteCount; - } - foreach (var id in source.ProviderIds) { var key = id.Key; @@ -200,6 +195,32 @@ namespace MediaBrowser.Providers.Manager MergeCriticRating(source, target, lockedFields, replaceData); MergeTrailers(source, target, lockedFields, replaceData); MergeVideoInfo(source, target, lockedFields, replaceData); + MergeDisplayOrder(source, target, lockedFields, replaceData); + + //if (!lockedFields.Contains(MetadataFields.SortName)) + { + if (replaceData || string.IsNullOrEmpty(target.ForcedSortName)) + { + var forcedSortName = source.ForcedSortName; + + if (!string.IsNullOrWhiteSpace(forcedSortName)) + { + target.ForcedSortName = forcedSortName; + } + } + } + + //if (!lockedFields.Contains(MetadataFields.DisplayMediaType)) + { + if (replaceData || string.IsNullOrEmpty(target.DisplayMediaType)) + { + // Safeguard against incoming data having an emtpy name + if (!string.IsNullOrWhiteSpace(source.DisplayMediaType)) + { + target.DisplayMediaType = source.DisplayMediaType; + } + } + } if (mergeMetadataSettings) { @@ -235,10 +256,8 @@ namespace MediaBrowser.Providers.Manager public static void MergeMetadataSettings(BaseItem source, BaseItem target) { - target.ForcedSortName = source.ForcedSortName; target.LockedFields = source.LockedFields; target.IsLocked = source.IsLocked; - target.DisplayMediaType = source.DisplayMediaType; // Grab the value if it's there, but if not then don't overwrite the default if (source.DateCreated != default(DateTime)) @@ -248,7 +267,10 @@ namespace MediaBrowser.Providers.Manager target.PreferredMetadataCountryCode = source.PreferredMetadataCountryCode; target.PreferredMetadataLanguage = source.PreferredMetadataLanguage; + } + private static void MergeDisplayOrder(BaseItem source, BaseItem target, List lockedFields, bool replaceData) + { var sourceHasDisplayOrder = source as IHasDisplayOrder; var targetHasDisplayOrder = target as IHasDisplayOrder; diff --git a/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs b/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs index 6a1af9272..b40e4a120 100644 --- a/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs +++ b/MediaBrowser.Providers/Movies/GenericMovieDbInfo.cs @@ -173,7 +173,7 @@ namespace MediaBrowser.Providers.Movies movie.CommunityRating = rating; } - movie.VoteCount = movieData.vote_count; + //movie.VoteCount = movieData.vote_count; //release date and certification are retrieved based on configured country and we fall back on US if not there and to minimun release date if still no match if (movieData.releases != null && movieData.releases.countries != null) diff --git a/MediaBrowser.Providers/Omdb/OmdbProvider.cs b/MediaBrowser.Providers/Omdb/OmdbProvider.cs index 41ff71070..0a95b449c 100644 --- a/MediaBrowser.Providers/Omdb/OmdbProvider.cs +++ b/MediaBrowser.Providers/Omdb/OmdbProvider.cs @@ -78,7 +78,7 @@ namespace MediaBrowser.Providers.Omdb && int.TryParse(result.imdbVotes, NumberStyles.Number, _usCulture, out voteCount) && voteCount >= 0) { - item.VoteCount = voteCount; + //item.VoteCount = voteCount; } float imdbRating; @@ -185,7 +185,7 @@ namespace MediaBrowser.Providers.Omdb && int.TryParse(result.imdbVotes, NumberStyles.Number, _usCulture, out voteCount) && voteCount >= 0) { - item.VoteCount = voteCount; + //item.VoteCount = voteCount; } float imdbRating; diff --git a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbEpisodeProvider.cs b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbEpisodeProvider.cs index 1938f7ff0..2e549f610 100644 --- a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbEpisodeProvider.cs @@ -122,7 +122,7 @@ namespace MediaBrowser.Providers.TV item.Overview = response.overview; item.CommunityRating = (float)response.vote_average; - item.VoteCount = response.vote_count; + //item.VoteCount = response.vote_count; if (response.videos != null && response.videos.results != null) { diff --git a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs index fe3d7d78c..0b5708b56 100644 --- a/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TheMovieDb/MovieDbSeriesProvider.cs @@ -217,7 +217,7 @@ namespace MediaBrowser.Providers.TV series.Name = seriesInfo.name; series.SetProviderId(MetadataProviders.Tmdb, seriesInfo.id.ToString(_usCulture)); - series.VoteCount = seriesInfo.vote_count; + //series.VoteCount = seriesInfo.vote_count; string voteAvg = seriesInfo.vote_average.ToString(CultureInfo.InvariantCulture); float rating; diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs index 686bacfe1..d823de786 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeProvider.cs @@ -680,7 +680,7 @@ namespace MediaBrowser.Providers.TV // int.TryParse is local aware, so it can be probamatic, force us culture if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval)) { - item.VoteCount = rval; + //item.VoteCount = rval; } } diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs index 4c5e57a94..8a10affb9 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs @@ -1150,7 +1150,7 @@ namespace MediaBrowser.Providers.TV // int.TryParse is local aware, so it can be probamatic, force us culture if (int.TryParse(val, NumberStyles.Integer, _usCulture, out rval)) { - item.VoteCount = rval; + //item.VoteCount = rval; } } diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs index c9ec195d9..d424cc0ca 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs @@ -704,21 +704,6 @@ namespace MediaBrowser.XbmcMetadata.Parsers break; } - case "votes": - { - var val = reader.ReadElementContentAsString(); - if (!string.IsNullOrWhiteSpace(val)) - { - int num; - - if (int.TryParse(val, NumberStyles.Integer, _usCulture, out num)) - { - item.VoteCount = num; - } - } - break; - } - case "genre": { var val = reader.ReadElementContentAsString(); diff --git a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs index a5955e14d..cf7c25584 100644 --- a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs @@ -63,7 +63,6 @@ namespace MediaBrowser.XbmcMetadata.Savers "releasedate", "outline", "id", - "votes", "credits", "originaltitle", "watched", @@ -659,11 +658,6 @@ namespace MediaBrowser.XbmcMetadata.Savers } } - if (item.VoteCount.HasValue) - { - writer.WriteElementString("votes", item.VoteCount.Value.ToString(UsCulture)); - } - // Use original runtime here, actual file runtime later in MediaInfo var runTimeTicks = item.RunTimeTicks;