Browse Source

update playlist query

Luke Pulverenti 9 năm trước cách đây
mục cha
commit
72a0c2afeb

+ 5 - 0
MediaBrowser.Api/UserLibrary/ItemsService.cs

@@ -112,6 +112,11 @@ namespace MediaBrowser.Api.UserLibrary
                 user == null ? _libraryManager.RootFolder : user.RootFolder :
                 parentItem;
 
+            if (string.Equals(request.IncludeItemTypes, "Playlist", StringComparison.OrdinalIgnoreCase))
+            {
+                item = user == null ? _libraryManager.RootFolder : user.RootFolder;
+            }
+
             // Default list type = children
 
             if (!string.IsNullOrEmpty(request.Ids))

+ 9 - 0
MediaBrowser.Controller/Entities/InternalItemsQuery.cs

@@ -31,6 +31,7 @@ namespace MediaBrowser.Controller.Entities
         public string[] MediaTypes { get; set; }
         public string[] IncludeItemTypes { get; set; }
         public string[] ExcludeItemTypes { get; set; }
+        public string[] ExcludeTags { get; set; }
         public string[] Genres { get; set; }
 
         public bool? IsMissing { get; set; }
@@ -133,6 +134,7 @@ namespace MediaBrowser.Controller.Entities
             ItemIds = new string[] { };
             AncestorIds = new string[] { };
             TopParentIds = new string[] { };
+            ExcludeTags = new string[] { };
             ExcludeLocationTypes = new LocationType[] { };
         }
 
@@ -144,6 +146,13 @@ namespace MediaBrowser.Controller.Entities
                 var policy = user.Policy;
                 MaxParentalRating = policy.MaxParentalRating;
 
+                if (policy.MaxParentalRating.HasValue)
+                {
+                    BlockUnratedItems = policy.BlockUnratedItems;
+                }
+
+                ExcludeTags = policy.BlockedTags;
+                
                 User = user;
             }
         }

+ 15 - 1
MediaBrowser.Providers/TV/TvdbSeriesProvider.cs

@@ -175,6 +175,11 @@ namespace MediaBrowser.Providers.TV
         /// <returns>Task.</returns>
         internal async Task DownloadSeriesZip(string seriesId, string seriesDataPath, long? lastTvDbUpdateTime, string preferredMetadataLanguage, CancellationToken cancellationToken)
         {
+            if (string.IsNullOrWhiteSpace(seriesId))
+            {
+                throw new ArgumentNullException("seriesId");
+            }
+            
             try
             {
                 await DownloadSeriesZip(seriesId, seriesDataPath, lastTvDbUpdateTime, preferredMetadataLanguage, preferredMetadataLanguage, cancellationToken).ConfigureAwait(false);
@@ -196,6 +201,11 @@ namespace MediaBrowser.Providers.TV
 
         private async Task DownloadSeriesZip(string seriesId, string seriesDataPath, long? lastTvDbUpdateTime, string preferredMetadataLanguage, string saveAsMetadataLanguage, CancellationToken cancellationToken)
         {
+            if (string.IsNullOrWhiteSpace(seriesId))
+            {
+                throw new ArgumentNullException("seriesId");
+            }
+
             var url = string.Format(SeriesGetZip, TVUtils.TvdbApiKey, seriesId, preferredMetadataLanguage);
 
             using (var zipStream = await _httpClient.Get(new HttpRequestOptions
@@ -247,7 +257,11 @@ namespace MediaBrowser.Providers.TV
             string id;
             if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out id))
             {
-                return true;
+                // This check should ideally never be necessary but we're seeing some cases of this and haven't tracked them down yet.
+                if (string.IsNullOrWhiteSpace(id))
+                {
+                    return true;
+                }
             }
             //if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out id))
             //{

+ 1 - 10
MediaBrowser.Server.Implementations/Library/LibraryManager.cs

@@ -1345,16 +1345,7 @@ namespace MediaBrowser.Server.Implementations.Library
 
                 }, CancellationToken.None).Result.ToList();
 
-                query.TopParentIds = userViews.SelectMany(GetTopParentsForQuery).Select(i => i.Id.ToString("N")).ToArray();
-            }
-
-            // TODO: handle blocking by tags
-
-            query.MaxParentalRating = user.Policy.MaxParentalRating;
-
-            if (user.Policy.MaxParentalRating.HasValue)
-            {
-                query.BlockUnratedItems = user.Policy.BlockUnratedItems;
+                //query.TopParentIds = userViews.SelectMany(GetTopParentsForQuery).Select(i => i.Id.ToString("N")).ToArray();
             }
         }
 

+ 8 - 0
MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs

@@ -1985,6 +1985,14 @@ namespace MediaBrowser.Server.Implementations.Persistence
                 var inClause = string.Join(",", query.BlockUnratedItems.Select(i => "'" + i.ToString() + "'").ToArray());
                 whereClauses.Add(string.Format("(InheritedParentalRatingValue > 0 or UnratedType not in ({0}))", inClause));
             }
+
+            //var excludeTagIndex = 0;
+            //foreach (var excludeTag in query.ExcludeTags)
+            //{
+            //    whereClauses.Add("Tags not like @excludeTag" + excludeTagIndex);
+            //    cmd.Parameters.Add(cmd, "@excludeTag" + excludeTagIndex, DbType.String).Value = "%" + excludeTag + "%";
+            //    excludeTagIndex++;
+            //}
             
             if (addPaging)
             {