aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MediaBrowser.Api/Reports/ReportsService.cs150
-rw-r--r--MediaBrowser.Api/UserLibrary/ItemsService.cs141
-rw-r--r--MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs11
-rw-r--r--MediaBrowser.Common/ScheduledTasks/ITaskManager.cs3
-rw-r--r--MediaBrowser.Controller/Entities/Folder.cs37
-rw-r--r--MediaBrowser.Controller/Entities/InternalItemsQuery.cs8
-rw-r--r--MediaBrowser.Controller/Entities/UserViewBuilder.cs63
-rw-r--r--MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs18
-rw-r--r--MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs4
-rw-r--r--MediaBrowser.Server.Implementations/Sync/SyncManager.cs11
10 files changed, 188 insertions, 258 deletions
diff --git a/MediaBrowser.Api/Reports/ReportsService.cs b/MediaBrowser.Api/Reports/ReportsService.cs
index 4ff3dcf26..15bdf4be6 100644
--- a/MediaBrowser.Api/Reports/ReportsService.cs
+++ b/MediaBrowser.Api/Reports/ReportsService.cs
@@ -260,7 +260,8 @@ namespace MediaBrowser.Api.Reports
MinCommunityRating = request.MinCommunityRating,
MinCriticRating = request.MinCriticRating,
ParentIndexNumber = request.ParentIndexNumber,
- AiredDuringSeason = request.AiredDuringSeason
+ AiredDuringSeason = request.AiredDuringSeason,
+ AlbumArtistStartsWithOrGreater = request.AlbumArtistStartsWithOrGreater
};
if (!string.IsNullOrWhiteSpace(request.Ids))
@@ -337,152 +338,53 @@ namespace MediaBrowser.Api.Reports
query.LocationTypes = request.LocationTypes.Split(',').Select(d => (LocationType)Enum.Parse(typeof(LocationType), d, true)).ToArray();
}
- if (request.HasQueryLimit == false)
+ // Min official rating
+ if (!string.IsNullOrEmpty(request.MinOfficialRating))
{
- query.StartIndex = null;
- query.Limit = null;
+ query.MinParentalRating = _localization.GetRatingLevel(request.MinOfficialRating);
}
- return query;
- }
-
- private bool ApplyAdditionalFilters(BaseReportRequest request, BaseItem i, User user, ILibraryManager libraryManager)
- {
- // Artists
- if (!string.IsNullOrEmpty(request.ArtistIds))
+ // Max official rating
+ if (!string.IsNullOrEmpty(request.MaxOfficialRating))
{
- var artistIds = request.ArtistIds.Split(new[] { '|', ',' });
-
- var audio = i as IHasArtist;
-
- if (!(audio != null && artistIds.Any(id =>
- {
- var artistItem = libraryManager.GetItemById(id);
- return artistItem != null && audio.HasAnyArtist(artistItem.Name);
- })))
- {
- return false;
- }
+ query.MaxParentalRating = _localization.GetRatingLevel(request.MinOfficialRating);
}
// Artists
if (!string.IsNullOrEmpty(request.Artists))
{
- var artists = request.Artists.Split('|');
-
- var audio = i as IHasArtist;
-
- if (!(audio != null && artists.Any(audio.HasAnyArtist)))
- {
- return false;
- }
+ query.ArtistNames = request.Artists.Split('|');
}
// Albums
if (!string.IsNullOrEmpty(request.Albums))
{
- var albums = request.Albums.Split('|');
-
- var audio = i as Audio;
-
- if (audio != null)
- {
- if (!albums.Any(a => string.Equals(a, audio.Album, StringComparison.OrdinalIgnoreCase)))
- {
- return false;
- }
- }
-
- var album = i as MusicAlbum;
-
- if (album != null)
- {
- if (!albums.Any(a => string.Equals(a, album.Name, StringComparison.OrdinalIgnoreCase)))
- {
- return false;
- }
- }
-
- var musicVideo = i as MusicVideo;
-
- if (musicVideo != null)
- {
- if (!albums.Any(a => string.Equals(a, musicVideo.Album, StringComparison.OrdinalIgnoreCase)))
- {
- return false;
- }
- }
-
- return false;
+ query.AlbumNames = request.Albums.Split('|');
}
- // Min index number
- if (request.MinIndexNumber.HasValue)
+ if (request.HasQueryLimit == false)
{
- if (!(i.IndexNumber.HasValue && i.IndexNumber.Value >= request.MinIndexNumber.Value))
- {
- return false;
- }
+ query.StartIndex = null;
+ query.Limit = null;
}
- // Min official rating
- if (!string.IsNullOrEmpty(request.MinOfficialRating))
- {
- var level = _localization.GetRatingLevel(request.MinOfficialRating);
-
- if (level.HasValue)
- {
- var rating = i.CustomRating;
-
- if (string.IsNullOrEmpty(rating))
- {
- rating = i.OfficialRating;
- }
-
- if (!string.IsNullOrEmpty(rating))
- {
- var itemLevel = _localization.GetRatingLevel(rating);
-
- if (!(!itemLevel.HasValue || itemLevel.Value >= level.Value))
- {
- return false;
- }
- }
- }
- }
+ return query;
+ }
- // Max official rating
- if (!string.IsNullOrEmpty(request.MaxOfficialRating))
+ private bool ApplyAdditionalFilters(BaseReportRequest request, BaseItem i, User user, ILibraryManager libraryManager)
+ {
+ // Artists
+ if (!string.IsNullOrEmpty(request.ArtistIds))
{
- var level = _localization.GetRatingLevel(request.MaxOfficialRating);
-
- if (level.HasValue)
- {
- var rating = i.CustomRating;
-
- if (string.IsNullOrEmpty(rating))
- {
- rating = i.OfficialRating;
- }
-
- if (!string.IsNullOrEmpty(rating))
- {
- var itemLevel = _localization.GetRatingLevel(rating);
-
- if (!(!itemLevel.HasValue || itemLevel.Value <= level.Value))
- {
- return false;
- }
- }
- }
- }
+ var artistIds = request.ArtistIds.Split(new[] { '|', ',' });
- if (!string.IsNullOrEmpty(request.AlbumArtistStartsWithOrGreater))
- {
- var ok = new[] { i }.OfType<IHasAlbumArtist>()
- .Any(p => string.Compare(request.AlbumArtistStartsWithOrGreater, p.AlbumArtists.FirstOrDefault(), StringComparison.CurrentCultureIgnoreCase) < 1);
+ var audio = i as IHasArtist;
- if (!ok)
+ if (!(audio != null && artistIds.Any(id =>
+ {
+ var artistItem = libraryManager.GetItemById(id);
+ return artistItem != null && audio.HasAnyArtist(artistItem.Name);
+ })))
{
return false;
}
diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs
index c54f25973..566b1dfd5 100644
--- a/MediaBrowser.Api/UserLibrary/ItemsService.cs
+++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs
@@ -233,7 +233,8 @@ namespace MediaBrowser.Api.UserLibrary
MinCriticRating = request.MinCriticRating,
ParentId = string.IsNullOrWhiteSpace(request.ParentId) ? (Guid?)null : new Guid(request.ParentId),
ParentIndexNumber = request.ParentIndexNumber,
- AiredDuringSeason = request.AiredDuringSeason
+ AiredDuringSeason = request.AiredDuringSeason,
+ AlbumArtistStartsWithOrGreater = request.AlbumArtistStartsWithOrGreater
};
if (!string.IsNullOrWhiteSpace(request.Ids))
@@ -309,138 +310,48 @@ namespace MediaBrowser.Api.UserLibrary
{
query.LocationTypes = request.LocationTypes.Split(',').Select(d => (LocationType)Enum.Parse(typeof(LocationType), d, true)).ToArray();
}
-
- return query;
- }
-
- private bool ApplyAdditionalFilters(GetItems request, BaseItem i, User user, ILibraryManager libraryManager)
- {
- // Artists
- if (!string.IsNullOrEmpty(request.ArtistIds))
+
+ // Min official rating
+ if (!string.IsNullOrEmpty(request.MinOfficialRating))
{
- var artistIds = request.ArtistIds.Split(new[] { '|', ',' });
-
- var audio = i as IHasArtist;
+ query.MinParentalRating = _localization.GetRatingLevel(request.MinOfficialRating);
+ }
- if (!(audio != null && artistIds.Any(id =>
- {
- var artistItem = libraryManager.GetItemById(id);
- return artistItem != null && audio.HasAnyArtist(artistItem.Name);
- })))
- {
- return false;
- }
+ // Max official rating
+ if (!string.IsNullOrEmpty(request.MaxOfficialRating))
+ {
+ query.MaxParentalRating = _localization.GetRatingLevel(request.MinOfficialRating);
}
// Artists
if (!string.IsNullOrEmpty(request.Artists))
{
- var artists = request.Artists.Split('|');
-
- var audio = i as IHasArtist;
-
- if (!(audio != null && artists.Any(audio.HasAnyArtist)))
- {
- return false;
- }
+ query.ArtistNames = request.Artists.Split('|');
}
// Albums
if (!string.IsNullOrEmpty(request.Albums))
{
- var albums = request.Albums.Split('|');
-
- var audio = i as Audio;
-
- if (audio != null)
- {
- if (!albums.Any(a => string.Equals(a, audio.Album, StringComparison.OrdinalIgnoreCase)))
- {
- return false;
- }
- }
-
- var album = i as MusicAlbum;
-
- if (album != null)
- {
- if (!albums.Any(a => string.Equals(a, album.Name, StringComparison.OrdinalIgnoreCase)))
- {
- return false;
- }
- }
-
- var musicVideo = i as MusicVideo;
-
- if (musicVideo != null)
- {
- if (!albums.Any(a => string.Equals(a, musicVideo.Album, StringComparison.OrdinalIgnoreCase)))
- {
- return false;
- }
- }
-
- return false;
+ query.AlbumNames = request.Albums.Split('|');
}
- // Min official rating
- if (!string.IsNullOrEmpty(request.MinOfficialRating))
- {
- var level = _localization.GetRatingLevel(request.MinOfficialRating);
-
- if (level.HasValue)
- {
- var rating = i.CustomRating;
-
- if (string.IsNullOrEmpty(rating))
- {
- rating = i.OfficialRating;
- }
-
- if (!string.IsNullOrEmpty(rating))
- {
- var itemLevel = _localization.GetRatingLevel(rating);
-
- if (!(!itemLevel.HasValue || itemLevel.Value >= level.Value))
- {
- return false;
- }
- }
- }
- }
+ return query;
+ }
- // Max official rating
- if (!string.IsNullOrEmpty(request.MaxOfficialRating))
+ private bool ApplyAdditionalFilters(GetItems request, BaseItem i, User user, ILibraryManager libraryManager)
+ {
+ // Artists
+ if (!string.IsNullOrEmpty(request.ArtistIds))
{
- var level = _localization.GetRatingLevel(request.MaxOfficialRating);
-
- if (level.HasValue)
- {
- var rating = i.CustomRating;
-
- if (string.IsNullOrEmpty(rating))
- {
- rating = i.OfficialRating;
- }
-
- if (!string.IsNullOrEmpty(rating))
- {
- var itemLevel = _localization.GetRatingLevel(rating);
-
- if (!(!itemLevel.HasValue || itemLevel.Value <= level.Value))
- {
- return false;
- }
- }
- }
- }
+ var artistIds = request.ArtistIds.Split(new[] { '|', ',' });
- if (!string.IsNullOrEmpty(request.AlbumArtistStartsWithOrGreater))
- {
- var ok = new[] { i }.OfType<IHasAlbumArtist>()
- .Any(p => string.Compare(request.AlbumArtistStartsWithOrGreater, p.AlbumArtists.FirstOrDefault(), StringComparison.CurrentCultureIgnoreCase) < 1);
+ var audio = i as IHasArtist;
- if (!ok)
+ if (!(audio != null && artistIds.Any(id =>
+ {
+ var artistItem = libraryManager.GetItemById(id);
+ return artistItem != null && audio.HasAnyArtist(artistItem.Name);
+ })))
{
return false;
}
diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs
index b5566650c..f3316646b 100644
--- a/MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs
+++ b/MediaBrowser.Common.Implementations/ScheduledTasks/TaskManager.cs
@@ -170,6 +170,17 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
QueueScheduledTask<T>(new TaskExecutionOptions());
}
+ public void QueueIfNotRunning<T>()
+ where T : IScheduledTask
+ {
+ var task = ScheduledTasks.First(t => t.ScheduledTask.GetType() == typeof(T));
+
+ if (task.State != TaskState.Running)
+ {
+ QueueScheduledTask<T>(new TaskExecutionOptions());
+ }
+ }
+
public void Execute<T>()
where T : IScheduledTask
{
diff --git a/MediaBrowser.Common/ScheduledTasks/ITaskManager.cs b/MediaBrowser.Common/ScheduledTasks/ITaskManager.cs
index c1dc304f6..f1809c451 100644
--- a/MediaBrowser.Common/ScheduledTasks/ITaskManager.cs
+++ b/MediaBrowser.Common/ScheduledTasks/ITaskManager.cs
@@ -50,6 +50,9 @@ namespace MediaBrowser.Common.ScheduledTasks
void QueueScheduledTask<T>()
where T : IScheduledTask;
+ void QueueIfNotRunning<T>()
+ where T : IScheduledTask;
+
/// <summary>
/// Queues the scheduled task.
/// </summary>
diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs
index dc0a8d0aa..fa96ba4e5 100644
--- a/MediaBrowser.Controller/Entities/Folder.cs
+++ b/MediaBrowser.Controller/Entities/Folder.cs
@@ -979,12 +979,6 @@ namespace MediaBrowser.Controller.Entities
return true;
}
- if (query.HasOverview.HasValue)
- {
- Logger.Debug("Query requires post-filtering due to HasOverview");
- return true;
- }
-
if (query.HasImdbId.HasValue)
{
Logger.Debug("Query requires post-filtering due to HasImdbId");
@@ -1078,13 +1072,6 @@ namespace MediaBrowser.Controller.Entities
return true;
}
- // Apply official rating filter
- if (query.OfficialRatings.Length > 0)
- {
- Logger.Debug("Query requires post-filtering due to OfficialRatings");
- return true;
- }
-
// Apply person filter
if (query.ItemIdsFromPersonFilters != null)
{
@@ -1104,12 +1091,6 @@ namespace MediaBrowser.Controller.Entities
return true;
}
- if (query.MinIndexNumber.HasValue)
- {
- Logger.Debug("Query requires post-filtering due to MinIndexNumber");
- return true;
- }
-
if (query.OfficialRatings.Length > 0)
{
Logger.Debug("Query requires post-filtering due to OfficialRatings");
@@ -1188,6 +1169,24 @@ namespace MediaBrowser.Controller.Entities
return true;
}
+ if (!string.IsNullOrWhiteSpace(query.AlbumArtistStartsWithOrGreater))
+ {
+ Logger.Debug("Query requires post-filtering due to AlbumArtistStartsWithOrGreater");
+ return true;
+ }
+
+ if (query.AlbumNames.Length > 0)
+ {
+ Logger.Debug("Query requires post-filtering due to AlbumNames");
+ return true;
+ }
+
+ if (query.ArtistNames.Length > 0)
+ {
+ Logger.Debug("Query requires post-filtering due to ArtistNames");
+ return true;
+ }
+
return false;
}
diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
index 2f98ac70d..b568aec18 100644
--- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
+++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs
@@ -105,6 +105,7 @@ namespace MediaBrowser.Controller.Entities
internal List<Guid> ItemIdsFromPersonFilters { get; set; }
public int? ParentIndexNumber { get; set; }
+ public int? MinParentalRating { get; set; }
public int? MaxParentalRating { get; set; }
public bool? IsCurrentSchema { get; set; }
@@ -125,9 +126,16 @@ namespace MediaBrowser.Controller.Entities
public DayOfWeek[] AirDays { get; set; }
public SeriesStatus[] SeriesStatuses { get; set; }
+ public string AlbumArtistStartsWithOrGreater { get; set; }
+
+ public string[] AlbumNames { get; set; }
+ public string[] ArtistNames { get; set; }
public InternalItemsQuery()
{
+ AlbumNames = new string[] { };
+ ArtistNames = new string[] { };
+
BlockUnratedItems = new UnratedItem[] { };
Tags = new string[] { };
OfficialRatings = new string[] { };
diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs
index 645e6e37d..a74859a46 100644
--- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs
+++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs
@@ -1199,6 +1199,11 @@ namespace MediaBrowser.Controller.Entities
return false;
}
+ if (query.ExcludeLocationTypes.Length > 0 && query.ExcludeLocationTypes.Contains(item.LocationType))
+ {
+ return false;
+ }
+
if (query.IsFolder.HasValue && query.IsFolder.Value != item.IsFolder)
{
return false;
@@ -1752,6 +1757,64 @@ namespace MediaBrowser.Controller.Entities
}
}
+ if (!string.IsNullOrEmpty(query.AlbumArtistStartsWithOrGreater))
+ {
+ var ok = new[] { item }.OfType<IHasAlbumArtist>()
+ .Any(p => string.Compare(query.AlbumArtistStartsWithOrGreater, p.AlbumArtists.FirstOrDefault(), StringComparison.CurrentCultureIgnoreCase) < 1);
+
+ if (!ok)
+ {
+ return false;
+ }
+ }
+
+ // Artists
+ if (query.ArtistNames.Length > 0)
+ {
+ var audio = item as IHasArtist;
+
+ if (!(audio != null && query.ArtistNames.Any(audio.HasAnyArtist)))
+ {
+ return false;
+ }
+ }
+
+ // Albums
+ if (query.AlbumNames.Length > 0)
+ {
+ var audio = item as Audio.Audio;
+
+ if (audio != null)
+ {
+ if (!query.AlbumNames.Any(a => string.Equals(a, audio.Album, StringComparison.OrdinalIgnoreCase)))
+ {
+ return false;
+ }
+ }
+
+ var album = item as MusicAlbum;
+
+ if (album != null)
+ {
+ if (!query.AlbumNames.Any(a => string.Equals(a, album.Name, StringComparison.OrdinalIgnoreCase)))
+ {
+ return false;
+ }
+ }
+
+ var musicVideo = item as MusicVideo;
+
+ if (musicVideo != null)
+ {
+ if (!query.AlbumNames.Any(a => string.Equals(a, musicVideo.Album, StringComparison.OrdinalIgnoreCase)))
+ {
+ return false;
+ }
+ }
+
+ return false;
+ }
+
return true;
}
diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
index e17b7d953..a6e92171f 100644
--- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
+++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
@@ -2062,6 +2062,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
whereClauses.Add(clause);
}
+ if (query.MinParentalRating.HasValue)
+ {
+ whereClauses.Add("InheritedParentalRatingValue<=@MinParentalRating");
+ cmd.Parameters.Add(cmd, "@MinParentalRating", DbType.Int32).Value = query.MinParentalRating.Value;
+ }
+
if (query.MaxParentalRating.HasValue)
{
whereClauses.Add("InheritedParentalRatingValue<=@MaxParentalRating");
@@ -2080,6 +2086,18 @@ namespace MediaBrowser.Server.Implementations.Persistence
}
}
+ if (query.HasOverview.HasValue)
+ {
+ if (query.HasOverview.Value)
+ {
+ whereClauses.Add("(Overview not null AND Overview<>'')");
+ }
+ else
+ {
+ whereClauses.Add("(Overview is null OR Overview='')");
+ }
+ }
+
if (query.HasDeadParentId.HasValue)
{
if (query.HasDeadParentId.Value)
diff --git a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs
index 7086735c0..f553c8ea8 100644
--- a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs
+++ b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs
@@ -641,6 +641,8 @@ namespace MediaBrowser.Server.Implementations.Sync
ReadInputAtNativeFramerate = !syncOptions.EnableFullSpeedTranscoding
}, innerProgress, cancellationToken);
+
+ _syncManager.OnConversionComplete(jobItem, job);
}
catch (OperationCanceledException)
{
@@ -825,6 +827,8 @@ namespace MediaBrowser.Server.Implementations.Sync
CpuCoreLimit = syncOptions.TranscodingCpuCoreLimit
}, innerProgress, cancellationToken);
+
+ _syncManager.OnConversionComplete(jobItem, job);
}
catch (OperationCanceledException)
{
diff --git a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs
index e22f86b11..fbbc6082a 100644
--- a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs
+++ b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs
@@ -1325,5 +1325,16 @@ namespace MediaBrowser.Server.Implementations.Sync
return list;
}
+
+ protected internal void OnConversionComplete(SyncJobItem item, SyncJob job)
+ {
+ var syncProvider = GetSyncProvider(item, job);
+ if (syncProvider is AppSyncProvider)
+ {
+ return;
+ }
+
+ _taskManager.QueueIfNotRunning<ServerSyncScheduledTask>();
+ }
}
}