aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MediaBrowser.Api/Movies/MoviesService.cs16
-rw-r--r--MediaBrowser.Controller/Entities/InternalItemsQuery.cs2
-rw-r--r--MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs63
-rw-r--r--MediaBrowser.Server.Mono/Native/BaseMonoApp.cs5
4 files changed, 68 insertions, 18 deletions
diff --git a/MediaBrowser.Api/Movies/MoviesService.cs b/MediaBrowser.Api/Movies/MoviesService.cs
index a2a935b12..1d86cd9e7 100644
--- a/MediaBrowser.Api/Movies/MoviesService.cs
+++ b/MediaBrowser.Api/Movies/MoviesService.cs
@@ -156,7 +156,9 @@ namespace MediaBrowser.Api.Movies
typeof(LiveTvProgram).Name
},
IsMovie = true,
- SimilarTo = item
+ SimilarTo = item,
+ EnableGroupByMetadataKey = true
+
}).ToList();
var dtoOptions = GetDtoOptions(request);
@@ -205,7 +207,8 @@ namespace MediaBrowser.Api.Movies
SortOrder = SortOrder.Descending,
Limit = 10,
IsFavoriteOrLiked = true,
- ExcludeItemIds = recentlyPlayedMovies.Select(i => i.Id.ToString("N")).ToArray()
+ ExcludeItemIds = recentlyPlayedMovies.Select(i => i.Id.ToString("N")).ToArray(),
+ EnableGroupByMetadataKey = true
}, parentIds).ToList();
@@ -283,7 +286,8 @@ namespace MediaBrowser.Api.Movies
typeof(Trailer).Name,
typeof(LiveTvProgram).Name
},
- IsMovie = true
+ IsMovie = true,
+ EnableGroupByMetadataKey = true
}).DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString("N"))
.Take(itemLimit)
@@ -317,7 +321,8 @@ namespace MediaBrowser.Api.Movies
typeof(Trailer).Name,
typeof(LiveTvProgram).Name
},
- IsMovie = true
+ IsMovie = true,
+ EnableGroupByMetadataKey = true
}).DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString("N"))
.Take(itemLimit)
@@ -350,7 +355,8 @@ namespace MediaBrowser.Api.Movies
typeof(LiveTvProgram).Name
},
IsMovie = true,
- SimilarTo = item
+ SimilarTo = item,
+ EnableGroupByMetadataKey = true
}).ToList();
diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
index e193a9dad..43a1b9eaa 100644
--- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
+++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
@@ -143,7 +143,7 @@ namespace MediaBrowser.Controller.Entities
public bool EnableTotalRecordCount { get; set; }
public bool ForceDirect { get; set; }
public Dictionary<string, string> ExcludeProviderIds { get; set; }
- public string GroupByAncestorOfType { get; set; }
+ public bool EnableGroupByMetadataKey { get; set; }
public InternalItemsQuery()
{
diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
index 9338a8706..096cdf880 100644
--- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
+++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
@@ -1622,7 +1622,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
return false;
}
- if (query.SimilarTo != null)
+ if (query.SimilarTo != null && query.User != null)
{
return true;
}
@@ -1757,11 +1757,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
{
var groups = new List<string>();
- if (!string.IsNullOrWhiteSpace(query.GroupByAncestorOfType))
- {
- groups.Add("(Select PresentationUniqueKey from TypedBaseItems B where B.Type = 'MediaBrowser.Controller.Entities.TV.Series' And B.Guid in (Select AncestorId from AncestorIds where ItemId=A.Guid))");
- }
-
if (EnableGroupByPresentationUniqueKey(query))
{
groups.Add("PresentationUniqueKey");
@@ -1793,6 +1788,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
var list = new List<BaseItem>();
+ // Hack for right now since we currently don't support filtering out these duplicates within a query
+ if (query.Limit.HasValue && query.EnableGroupByMetadataKey)
+ {
+ query.Limit = query.Limit.Value + 4;
+ }
+
using (var cmd = _connection.CreateCommand())
{
cmd.CommandText = "select " + string.Join(",", GetFinalColumnsToSelect(query, _retriveItemColumns, cmd)) + GetFromText();
@@ -1845,9 +1846,57 @@ namespace MediaBrowser.Server.Implementations.Persistence
}
}
+ // Hack for right now since we currently don't support filtering out these duplicates within a query
+ if (query.EnableGroupByMetadataKey)
+ {
+ var limit = query.Limit ?? int.MaxValue;
+ limit -= 4;
+ var newList = new List<BaseItem>();
+
+ foreach (var item in list)
+ {
+ AddItem(newList, item);
+
+ if (newList.Count >= limit)
+ {
+ break;
+ }
+ }
+
+ list = newList;
+ }
+
return list;
}
+ private void AddItem(List<BaseItem> items, BaseItem newItem)
+ {
+ var providerIds = newItem.ProviderIds.ToList();
+
+ for (var i = 0; i < items.Count; i++)
+ {
+ var item = items[i];
+
+ foreach (var providerId in providerIds)
+ {
+ if (providerId.Key == MetadataProviders.TmdbCollection.ToString())
+ {
+ continue;
+ }
+ if (item.GetProviderId(providerId.Key) == providerId.Value)
+ {
+ if (newItem.SourceType == SourceType.Library)
+ {
+ items[i] = newItem;
+ }
+ return;
+ }
+ }
+ }
+
+ items.Add(newItem);
+ }
+
private void LogQueryTime(string methodName, IDbCommand cmd, DateTime startDate)
{
var elapsed = (DateTime.UtcNow - startDate).TotalMilliseconds;
@@ -3869,7 +3918,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
return counts;
}
- var allTypes = typeString.Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries)
+ var allTypes = typeString.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries)
.ToLookup(i => i).ToList();
foreach (var type in allTypes)
diff --git a/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs b/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs
index ebddbe077..19ae7b4d2 100644
--- a/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs
+++ b/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs
@@ -276,11 +276,6 @@ namespace MediaBrowser.Server.Mono.Native
{
"https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-git-20160215-64bit-static.7z"
};
- case Architecture.X86:
- return new[]
- {
- "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-git-20160215-32bit-static.7z"
- };
}
break;
}