Prechádzať zdrojové kódy

fix search dipping into restricted channels

Luke Pulverenti 9 rokov pred
rodič
commit
1dfe694a77

+ 2 - 4
MediaBrowser.Api/GamesService.cs

@@ -109,8 +109,7 @@ namespace MediaBrowser.Api
             {
                 IncludeItemTypes = new[] { typeof(GameSystem).Name }
             };
-            var parentIds = new string[] { } ;
-            var gameSystems = _libraryManager.GetItemList(query, parentIds)
+            var gameSystems = _libraryManager.GetItemList(query)
                 .Cast<GameSystem>()
                 .ToList();
 
@@ -130,8 +129,7 @@ namespace MediaBrowser.Api
             {
                 IncludeItemTypes = new[] { typeof(Game).Name }
             };
-            var parentIds = new string[] { };
-            var games = _libraryManager.GetItemList(query, parentIds)
+            var games = _libraryManager.GetItemList(query)
                 .Cast<Game>()
                 .ToList();
 

+ 3 - 71
MediaBrowser.Api/LiveTv/LiveTvService.cs

@@ -519,14 +519,6 @@ namespace MediaBrowser.Api.LiveTv
         public string ProviderName { get; set; }
     }
 
-    public class TunerChannelMapping
-    {
-        public string Name { get; set; }
-        public string Number { get; set; }
-        public string ProviderChannelNumber { get; set; }
-        public string ProviderChannelName { get; set; }
-    }
-
     [Route("/LiveTv/Registration", "GET")]
     [Authenticated]
     public class GetLiveTvRegistrationInfo : IReturn<MBRegistrationRecord>
@@ -595,36 +587,7 @@ namespace MediaBrowser.Api.LiveTv
 
         public async Task<object> Post(SetChannelMapping request)
         {
-            var config = GetConfiguration();
-
-            var listingsProviderInfo = config.ListingProviders.First(i => string.Equals(request.ProviderId, i.Id, StringComparison.OrdinalIgnoreCase));
-            listingsProviderInfo.ChannelMappings = listingsProviderInfo.ChannelMappings.Where(i => !string.Equals(i.Name, request.TunerChannelNumber, StringComparison.OrdinalIgnoreCase)).ToArray();
-
-            if (!string.Equals(request.TunerChannelNumber, request.ProviderChannelNumber, StringComparison.OrdinalIgnoreCase))
-            {
-                var list = listingsProviderInfo.ChannelMappings.ToList();
-                list.Add(new NameValuePair
-                {
-                    Name = request.TunerChannelNumber,
-                    Value = request.ProviderChannelNumber
-                });
-                listingsProviderInfo.ChannelMappings = list.ToArray();
-            }
-
-            UpdateConfiguration(config);
-
-            var tunerChannels = await _liveTvManager.GetChannelsForListingsProvider(request.ProviderId, CancellationToken.None)
-                        .ConfigureAwait(false);
-
-            var providerChannels = await _liveTvManager.GetChannelsFromListingsProviderData(request.ProviderId, CancellationToken.None)
-                     .ConfigureAwait(false);
-
-            var mappings = listingsProviderInfo.ChannelMappings.ToList();
-
-            var tunerChannelMappings =
-                tunerChannels.Select(i => GetTunerChannelMapping(i, mappings, providerChannels)).ToList();
-
-            return tunerChannelMappings.First(i => string.Equals(i.Number, request.TunerChannelNumber, StringComparison.OrdinalIgnoreCase));
+            return await _liveTvManager.SetChannelMapping(request.ProviderId, request.TunerChannelNumber, request.ProviderChannelNumber).ConfigureAwait(false);
         }
 
         public async Task<object> Get(GetChannelMappingOptions request)
@@ -645,7 +608,7 @@ namespace MediaBrowser.Api.LiveTv
 
             var result = new ChannelMappingOptions
             {
-                TunerChannels = tunerChannels.Select(i => GetTunerChannelMapping(i, mappings, providerChannels)).ToList(),
+                TunerChannels = tunerChannels.Select(i => _liveTvManager.GetTunerChannelMapping(i, mappings, providerChannels)).ToList(),
 
                 ProviderChannels = providerChannels.Select(i => new NameIdPair
                 {
@@ -662,33 +625,6 @@ namespace MediaBrowser.Api.LiveTv
             return ToOptimizedResult(result);
         }
 
-        private TunerChannelMapping GetTunerChannelMapping(ChannelInfo channel, List<NameValuePair> mappings, List<ChannelInfo> providerChannels)
-        {
-            var result = new TunerChannelMapping
-            {
-                Name = channel.Number + " " + channel.Name,
-                Number = channel.Number
-            };
-
-            var mapping = mappings.FirstOrDefault(i => string.Equals(i.Name, channel.Number, StringComparison.OrdinalIgnoreCase));
-            var providerChannelNumber = channel.Number;
-
-            if (mapping != null)
-            {
-                providerChannelNumber = mapping.Value;
-            }
-
-            var providerChannel = providerChannels.FirstOrDefault(i => string.Equals(i.Number, providerChannelNumber, StringComparison.OrdinalIgnoreCase));
-
-            if (providerChannel != null)
-            {
-                result.ProviderChannelNumber = providerChannel.Number;
-                result.ProviderChannelName = providerChannel.Name;
-            }
-
-            return result;
-        }
-
         public object Get(GetSatIniMappings request)
         {
             return ToOptimizedResult(_liveTvManager.GetSatIniMappings());
@@ -730,11 +666,7 @@ namespace MediaBrowser.Api.LiveTv
 
         public void Delete(DeleteListingProvider request)
         {
-            var config = GetConfiguration();
-
-            config.ListingProviders = config.ListingProviders.Where(i => !string.Equals(request.Id, i.Id, StringComparison.OrdinalIgnoreCase)).ToList();
-
-            _config.SaveConfiguration("livetv", config);
+            _liveTvManager.DeleteListingsProvider(request.Id);
         }
 
         public async Task<object> Post(AddTunerHost request)

+ 10 - 5
MediaBrowser.Api/Movies/MoviesService.cs

@@ -177,7 +177,8 @@ namespace MediaBrowser.Api.Movies
         {
             var categories = new List<RecommendationDto>();
 
-            var parentIds = string.IsNullOrWhiteSpace(parentId) ? new string[] { } : new[] { parentId };
+            var parentIdGuid = string.IsNullOrWhiteSpace(parentId) ? (Guid?)null : new Guid(parentId);
+
             var query = new InternalItemsQuery(user)
             {
                 IncludeItemTypes = new[]
@@ -189,10 +190,12 @@ namespace MediaBrowser.Api.Movies
                 // IsMovie = true
                 SortBy = new[] { ItemSortBy.DatePlayed, ItemSortBy.Random },
                 SortOrder = SortOrder.Descending,
-                Limit = 7
+                Limit = 7,
+                ParentId = parentIdGuid,
+                Recursive = true
             };
 
-            var recentlyPlayedMovies = _libraryManager.GetItemList(query, parentIds).ToList();
+            var recentlyPlayedMovies = _libraryManager.GetItemList(query).ToList();
 
             var likedMovies = _libraryManager.GetItemList(new InternalItemsQuery(user)
             {
@@ -208,9 +211,11 @@ namespace MediaBrowser.Api.Movies
                 Limit = 10,
                 IsFavoriteOrLiked = true,
                 ExcludeItemIds = recentlyPlayedMovies.Select(i => i.Id.ToString("N")).ToArray(),
-                EnableGroupByMetadataKey = true
+                EnableGroupByMetadataKey = true,
+                ParentId = parentIdGuid,
+                Recursive = true
 
-            }, parentIds).ToList();
+            }).ToList();
 
             var mostRecentMovies = recentlyPlayedMovies.Take(6).ToList();
             // Get recently played directors

+ 1 - 1
MediaBrowser.Api/StartupWizardService.cs

@@ -118,7 +118,7 @@ namespace MediaBrowser.Api
             config.EnableStandaloneMusicKeys = true;
             config.EnableCaseSensitiveItemIds = true;
             config.EnableFolderView = true;
-            config.SchemaVersion = 96;
+            config.SchemaVersion = 97;
         }
 
         public void Post(UpdateStartupConfiguration request)

+ 4 - 3
MediaBrowser.Api/TvShowsService.cs

@@ -317,7 +317,7 @@ namespace MediaBrowser.Api
 
             var minPremiereDate = DateTime.Now.Date.ToUniversalTime().AddDays(-1);
 
-            var parentIds = string.IsNullOrWhiteSpace(request.ParentId) ? new string[] { } : new[] { request.ParentId };
+            var parentIdGuid = string.IsNullOrWhiteSpace(request.ParentId) ? (Guid?)null : new Guid(request.ParentId);
 
             var itemsResult = _libraryManager.GetItemList(new InternalItemsQuery(user)
             {
@@ -326,9 +326,10 @@ namespace MediaBrowser.Api
                 SortOrder = SortOrder.Ascending,
                 MinPremiereDate = minPremiereDate,
                 StartIndex = request.StartIndex,
-                Limit = request.Limit
+                Limit = request.Limit,
+                ParentId = parentIdGuid
 
-            }, parentIds).ToList();
+            }).ToList();
 
             var options = GetDtoOptions(request);
 

+ 1 - 1
MediaBrowser.Controller/Entities/BaseItem.cs

@@ -2175,7 +2175,7 @@ namespace MediaBrowser.Controller.Entities
         {
             get
             {
-                if (GetParent() is AggregateFolder || this is BasePluginFolder)
+                if (GetParent() is AggregateFolder || this is BasePluginFolder || this is Channel)
                 {
                     return true;
                 }

+ 7 - 0
MediaBrowser.Controller/LiveTv/ILiveTvManager.cs

@@ -345,6 +345,13 @@ namespace MediaBrowser.Controller.LiveTv
         /// <param name="validateListings">if set to <c>true</c> [validate listings].</param>
         /// <returns>Task.</returns>
         Task<ListingsProviderInfo> SaveListingProvider(ListingsProviderInfo info, bool validateLogin, bool validateListings);
+
+        void DeleteListingsProvider(string id);
+
+        Task<TunerChannelMapping> SetChannelMapping(string providerId, string tunerChannelNumber, string providerChannelNumber);
+
+        TunerChannelMapping GetTunerChannelMapping(ChannelInfo channel, List<NameValuePair> mappings, List<ChannelInfo> providerChannels);
+
         /// <summary>
         /// Gets the lineups.
         /// </summary>

+ 16 - 0
MediaBrowser.Controller/LiveTv/TunerChannelMapping.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MediaBrowser.Controller.LiveTv
+{
+    public class TunerChannelMapping
+    {
+        public string Name { get; set; }
+        public string Number { get; set; }
+        public string ProviderChannelNumber { get; set; }
+        public string ProviderChannelName { get; set; }
+    }
+}

+ 1 - 0
MediaBrowser.Controller/MediaBrowser.Controller.csproj

@@ -220,6 +220,7 @@
     <Compile Include="LiveTv\SeriesTimerInfo.cs" />
     <Compile Include="LiveTv\TimerEventInfo.cs" />
     <Compile Include="LiveTv\TimerInfo.cs" />
+    <Compile Include="LiveTv\TunerChannelMapping.cs" />
     <Compile Include="Localization\ILocalizationManager.cs" />
     <Compile Include="MediaEncoding\ChapterImageRefreshOptions.cs" />
     <Compile Include="MediaEncoding\EncodingJobOptions.cs" />

+ 17 - 18
MediaBrowser.Server.Implementations/Library/LibraryManager.cs

@@ -1295,6 +1295,23 @@ namespace MediaBrowser.Server.Implementations.Library
             return ItemRepository.GetItemList(query);
         }
 
+        public IEnumerable<BaseItem> GetItemList(InternalItemsQuery query, IEnumerable<string> parentIds)
+        {
+            var parents = parentIds.Select(i => GetItemById(new Guid(i))).Where(i => i != null).ToList();
+
+            SetTopParentIdsOrAncestors(query, parents);
+
+            if (query.AncestorIds.Length == 0 && query.TopParentIds.Length == 0)
+            {
+                if (query.User != null)
+                {
+                    AddUserToQuery(query, query.User);
+                }
+            }
+
+            return ItemRepository.GetItemList(query);
+        }
+
         public QueryResult<BaseItem> QueryItems(InternalItemsQuery query)
         {
             if (query.User != null)
@@ -1416,15 +1433,6 @@ namespace MediaBrowser.Server.Implementations.Library
             return ItemRepository.GetAlbumArtists(query);
         }
 
-        public IEnumerable<BaseItem> GetItemList(InternalItemsQuery query, IEnumerable<string> parentIds)
-        {
-            var parents = parentIds.Select(i => GetItemById(new Guid(i))).Where(i => i != null).ToList();
-
-            SetTopParentIdsOrAncestors(query, parents);
-
-            return ItemRepository.GetItemList(query);
-        }
-
         public QueryResult<BaseItem> GetItemsResult(InternalItemsQuery query)
         {
             if (query.Recursive && query.ParentId.HasValue)
@@ -1453,15 +1461,6 @@ namespace MediaBrowser.Server.Implementations.Library
             };
         }
 
-        public QueryResult<BaseItem> GetItemsResult(InternalItemsQuery query, IEnumerable<string> parentIds)
-        {
-            var parents = parentIds.Select(i => GetItemById(new Guid(i))).Where(i => i != null).ToList();
-
-            SetTopParentIdsOrAncestors(query, parents);
-
-            return GetItemsResult(query);
-        }
-
         private void SetTopParentIdsOrAncestors(InternalItemsQuery query, List<BaseItem> parents)
         {
             if (parents.All(i =>

+ 1 - 1
MediaBrowser.Server.Implementations/Library/MusicManager.cs

@@ -98,7 +98,7 @@ namespace MediaBrowser.Server.Implementations.Library
 
                 Genres = genreList.ToArray()
 
-            }, new string[] { });
+            });
 
             var genresDictionary = genreList.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
 

+ 1 - 1
MediaBrowser.Server.Implementations/Library/SearchEngine.cs

@@ -168,7 +168,7 @@ namespace MediaBrowser.Server.Implementations.Library
                 Limit = query.Limit,
                 IncludeItemsByName = true
 
-            }, new string[] { });
+            });
 
             // Add search hints based on item name
             hints.AddRange(mediaItems.Where(IncludeInSearch).Select(item =>

+ 36 - 0
MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTVRegistration.cs

@@ -0,0 +1,36 @@
+using System.Threading.Tasks;
+using MediaBrowser.Common.Security;
+
+namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
+{
+    public class EmbyTVRegistration : IRequiresRegistration
+    {
+        private readonly ISecurityManager _securityManager;
+
+        public static EmbyTVRegistration Instance;
+
+        public EmbyTVRegistration(ISecurityManager securityManager)
+        {
+            _securityManager = securityManager;
+            Instance = this;
+        }
+
+        private bool? _isXmlTvEnabled;
+
+        public Task LoadRegistrationInfoAsync()
+        {
+            _isXmlTvEnabled = null;
+            return Task.FromResult(true);
+        }
+
+        public async Task<bool> EnableXmlTv()
+        {
+            if (!_isXmlTvEnabled.HasValue)
+            {
+                var info = await _securityManager.GetRegistrationStatus("xmltv").ConfigureAwait(false);
+                _isXmlTvEnabled = info.IsValid;
+            }
+            return _isXmlTvEnabled.Value;
+        }
+    }
+}

+ 9 - 0
MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs

@@ -103,6 +103,15 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
 
         public async Task<IEnumerable<ProgramInfo>> GetProgramsAsync(ListingsProviderInfo info, string channelNumber, string channelName, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken)
         {
+            if (!await EmbyTV.EmbyTVRegistration.Instance.EnableXmlTv().ConfigureAwait(false))
+            {
+                var length = endDateUtc - startDateUtc;
+                if (length.TotalDays > 1)
+                {
+                    endDateUtc = startDateUtc.AddDays(1);
+                }
+            }
+
             var path = await GetXml(info.Path, cancellationToken).ConfigureAwait(false);
             var reader = new XmlTvReader(path, GetLanguage(), null);
 

+ 75 - 2
MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs

@@ -1462,7 +1462,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
                 internalQuery.ChannelIds = new[] { query.ChannelId };
             }
 
-            var queryResult = _libraryManager.GetItemList(internalQuery, new string[] { });
+            var queryResult = _libraryManager.GetItemList(internalQuery);
             IEnumerable<ILiveTvRecording> recordings = queryResult.Cast<ILiveTvRecording>();
 
             if (!string.IsNullOrWhiteSpace(query.Id))
@@ -1936,7 +1936,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
                 SortBy = new[] { "StartDate" },
                 TopParentIds = new[] { GetInternalLiveTvFolder(CancellationToken.None).Result.Id.ToString("N") }
 
-            }, new string[] { }).ToList();
+            }).ToList();
 
             foreach (var tuple in tuples)
             {
@@ -2526,6 +2526,79 @@ namespace MediaBrowser.Server.Implementations.LiveTv
             return info;
         }
 
+        public void DeleteListingsProvider(string id)
+        {
+            var config = GetConfiguration();
+
+            config.ListingProviders = config.ListingProviders.Where(i => !string.Equals(id, i.Id, StringComparison.OrdinalIgnoreCase)).ToList();
+
+            _config.SaveConfiguration("livetv", config);
+            _taskManager.CancelIfRunningAndQueue<RefreshChannelsScheduledTask>();
+        }
+
+        public async Task<TunerChannelMapping> SetChannelMapping(string providerId, string tunerChannelNumber, string providerChannelNumber)
+        {
+            var config = GetConfiguration();
+
+            var listingsProviderInfo = config.ListingProviders.First(i => string.Equals(providerId, i.Id, StringComparison.OrdinalIgnoreCase));
+            listingsProviderInfo.ChannelMappings = listingsProviderInfo.ChannelMappings.Where(i => !string.Equals(i.Name, tunerChannelNumber, StringComparison.OrdinalIgnoreCase)).ToArray();
+
+            if (!string.Equals(tunerChannelNumber, providerChannelNumber, StringComparison.OrdinalIgnoreCase))
+            {
+                var list = listingsProviderInfo.ChannelMappings.ToList();
+                list.Add(new NameValuePair
+                {
+                    Name = tunerChannelNumber,
+                    Value = providerChannelNumber
+                });
+                listingsProviderInfo.ChannelMappings = list.ToArray();
+            }
+
+            _config.SaveConfiguration("livetv", config);
+
+            var tunerChannels = await GetChannelsForListingsProvider(providerId, CancellationToken.None)
+                        .ConfigureAwait(false);
+
+            var providerChannels = await GetChannelsFromListingsProviderData(providerId, CancellationToken.None)
+                     .ConfigureAwait(false);
+
+            var mappings = listingsProviderInfo.ChannelMappings.ToList();
+
+            var tunerChannelMappings =
+                tunerChannels.Select(i => GetTunerChannelMapping(i, mappings, providerChannels)).ToList();
+
+            _taskManager.CancelIfRunningAndQueue<RefreshChannelsScheduledTask>();
+
+            return tunerChannelMappings.First(i => string.Equals(i.Number, tunerChannelNumber, StringComparison.OrdinalIgnoreCase));
+        }
+
+        public TunerChannelMapping GetTunerChannelMapping(ChannelInfo channel, List<NameValuePair> mappings, List<ChannelInfo> providerChannels)
+        {
+            var result = new TunerChannelMapping
+            {
+                Name = channel.Number + " " + channel.Name,
+                Number = channel.Number
+            };
+
+            var mapping = mappings.FirstOrDefault(i => string.Equals(i.Name, channel.Number, StringComparison.OrdinalIgnoreCase));
+            var providerChannelNumber = channel.Number;
+
+            if (mapping != null)
+            {
+                providerChannelNumber = mapping.Value;
+            }
+
+            var providerChannel = providerChannels.FirstOrDefault(i => string.Equals(i.Number, providerChannelNumber, StringComparison.OrdinalIgnoreCase));
+
+            if (providerChannel != null)
+            {
+                result.ProviderChannelNumber = providerChannel.Number;
+                result.ProviderChannelName = providerChannel.Name;
+            }
+
+            return result;
+        }
+
         public Task<List<NameIdPair>> GetLineups(string providerType, string providerId, string country, string location)
         {
             var config = GetConfiguration();

+ 1 - 0
MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj

@@ -226,6 +226,7 @@
     <Compile Include="LiveTv\ChannelImageProvider.cs" />
     <Compile Include="LiveTv\EmbyTV\DirectRecorder.cs" />
     <Compile Include="LiveTv\EmbyTV\EmbyTV.cs" />
+    <Compile Include="LiveTv\EmbyTV\EmbyTVRegistration.cs" />
     <Compile Include="LiveTv\EmbyTV\EncodedRecorder.cs" />
     <Compile Include="LiveTv\EmbyTV\EntryPoint.cs" />
     <Compile Include="LiveTv\EmbyTV\IRecorder.cs" />

+ 1 - 1
MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs

@@ -95,7 +95,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
         private IDbCommand _updateInheritedRatingCommand;
         private IDbCommand _updateInheritedTagsCommand;
 
-        public const int LatestSchemaVersion = 96;
+        public const int LatestSchemaVersion = 97;
 
         /// <summary>
         /// Initializes a new instance of the <see cref="SqliteItemRepository"/> class.

+ 0 - 12
MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj

@@ -224,9 +224,6 @@
     <Content Include="dashboard-ui\components\metadataeditor\metadataeditor.template.html">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
-    <Content Include="dashboard-ui\devices\ie\ie.css">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
     <Content Include="dashboard-ui\css\images\ani_equalizer_black.gif">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
@@ -269,9 +266,6 @@
     <Content Include="dashboard-ui\components\imageeditor\imageeditor.template.html">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
-    <Content Include="dashboard-ui\devices\ie\ie.js">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
     <Content Include="dashboard-ui\favorites.html">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
@@ -482,9 +476,6 @@
     <Content Include="dashboard-ui\forgotpasswordpin.html">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
-    <Content Include="dashboard-ui\kids.html">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
     <Content Include="dashboard-ui\livetvitems.html">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
@@ -506,9 +497,6 @@
     <Content Include="dashboard-ui\scripts\forgotpasswordpin.js">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
-    <Content Include="dashboard-ui\scripts\kids.js">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
     <Content Include="dashboard-ui\scripts\livetvcomponents.js">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>