aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-03-09 18:14:44 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-03-09 18:14:44 -0400
commitd49494476770b3c0a091841bd3bbd44862fb8137 (patch)
treef0bf4bffa8b4d8a91de9e9096941aa34082a8e91 /MediaBrowser.Server.Implementations
parent1ead63b0d1a532cf828a4ed7c5310eef9c255740 (diff)
calculate item by name counts on the fly
Diffstat (limited to 'MediaBrowser.Server.Implementations')
-rw-r--r--MediaBrowser.Server.Implementations/Dto/DtoService.cs62
-rw-r--r--MediaBrowser.Server.Implementations/Library/LibraryManager.cs9
-rw-r--r--MediaBrowser.Server.Implementations/Library/SearchEngine.cs4
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs45
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs62
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs62
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs73
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/PeoplePostScanTask.cs103
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs6
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs65
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs118
-rw-r--r--MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj7
-rw-r--r--MediaBrowser.Server.Implementations/Sorting/AlbumCountComparer.cs71
-rw-r--r--MediaBrowser.Server.Implementations/Sorting/EpisodeCountComparer.cs71
-rw-r--r--MediaBrowser.Server.Implementations/Sorting/MovieCountComparer.cs71
-rw-r--r--MediaBrowser.Server.Implementations/Sorting/MusicVideoCountComparer.cs71
-rw-r--r--MediaBrowser.Server.Implementations/Sorting/SeriesCountComparer.cs71
-rw-r--r--MediaBrowser.Server.Implementations/Sorting/SongCountComparer.cs71
-rw-r--r--MediaBrowser.Server.Implementations/Sorting/TrailerCountComparer.cs71
19 files changed, 181 insertions, 932 deletions
diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs
index 7bf87875e..641bf0a6a 100644
--- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs
+++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs
@@ -121,41 +121,51 @@ namespace MediaBrowser.Server.Implementations.Dto
}
}
- var itemByName = item as IItemByName;
- if (itemByName != null)
- {
- AttachItemByNameCounts(dto, itemByName, user);
- }
-
return dto;
}
- /// <summary>
- /// Attaches the item by name counts.
- /// </summary>
- /// <param name="dto">The dto.</param>
- /// <param name="item">The item.</param>
- /// <param name="user">The user.</param>
- private void AttachItemByNameCounts(BaseItemDto dto, IItemByName item, User user)
+ public BaseItemDto GetItemByNameDto<T>(T item, List<ItemFields> fields, User user = null)
+ where T : BaseItem, IItemByName
{
- if (user == null)
+ var libraryItems = user != null ? user.RootFolder.GetRecursiveChildren(user) :
+ _libraryManager.RootFolder.RecursiveChildren;
+
+ return GetItemByNameDto(item, fields, item.GetTaggedItems(libraryItems).ToList(), user);
+ }
+
+ public BaseItemDto GetItemByNameDto<T>(T item, List<ItemFields> fields, List<BaseItem> taggedItems, User user = null)
+ where T : BaseItem, IItemByName
+ {
+ var dto = GetBaseItemDto(item, fields, user);
+
+ if (item is MusicArtist || item is MusicGenre)
{
- return;
+ dto.AlbumCount = taggedItems.Count(i => i is MusicAlbum);
+ dto.MusicVideoCount = taggedItems.Count(i => i is MusicVideo);
+ dto.SongCount = taggedItems.Count(i => i is Audio);
+ }
+ else if (item is GameGenre)
+ {
+ dto.GameCount = taggedItems.Count(i => i is Game);
}
+ else
+ {
+ // This populates them all and covers Genre, Person, Studio, Year
- var counts = item.GetItemByNameCounts(user.Id) ?? new ItemByNameCounts();
+ dto.AdultVideoCount = taggedItems.Count(i => i is AdultVideo);
+ dto.AlbumCount = taggedItems.Count(i => i is MusicAlbum);
+ dto.EpisodeCount = taggedItems.Count(i => i is Episode);
+ dto.GameCount = taggedItems.Count(i => i is Game);
+ dto.MovieCount = taggedItems.Count(i => i is Movie);
+ dto.MusicVideoCount = taggedItems.Count(i => i is MusicVideo);
+ dto.SeriesCount = taggedItems.Count(i => i is Series);
+ dto.SongCount = taggedItems.Count(i => i is Audio);
+ dto.TrailerCount = taggedItems.Count(i => i is Trailer);
+ }
- dto.ChildCount = counts.TotalCount;
+ dto.ChildCount = taggedItems.Count;
- dto.AdultVideoCount = counts.AdultVideoCount;
- dto.AlbumCount = counts.AlbumCount;
- dto.EpisodeCount = counts.EpisodeCount;
- dto.GameCount = counts.GameCount;
- dto.MovieCount = counts.MovieCount;
- dto.MusicVideoCount = counts.MusicVideoCount;
- dto.SeriesCount = counts.SeriesCount;
- dto.SongCount = counts.SongCount;
- dto.TrailerCount = counts.TrailerCount;
+ return dto;
}
/// <summary>
diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
index 6e9d803bf..b190b8947 100644
--- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
+++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs
@@ -484,6 +484,9 @@ namespace MediaBrowser.Server.Implementations.Library
await ItemRepository.DeleteItem(child.Id, CancellationToken.None).ConfigureAwait(false);
}
+ BaseItem removed;
+ _libraryItemsCache.TryRemove(item.Id, out removed);
+
ReportItemRemoved(item);
}
@@ -922,10 +925,10 @@ namespace MediaBrowser.Server.Implementations.Library
/// <returns>Task.</returns>
public Task ValidatePeople(CancellationToken cancellationToken, IProgress<double> progress)
{
- // Ensure the location is unavailable.
+ // Ensure the location is available.
Directory.CreateDirectory(ConfigurationManager.ApplicationPaths.PeoplePath);
- return new PeopleValidator(this, _logger).ValidatePeople(cancellationToken, progress);
+ return new PeopleValidator(this, _logger).ValidatePeople(cancellationToken, new MetadataRefreshOptions(), progress);
}
/// <summary>
@@ -953,7 +956,7 @@ namespace MediaBrowser.Server.Implementations.Library
// Ensure the location is unavailable.
Directory.CreateDirectory(ConfigurationManager.ApplicationPaths.MusicGenrePath);
- return new MusicGenresValidator(this, _userManager, _logger).Run(progress, cancellationToken);
+ return new MusicGenresValidator(this, _logger).Run(progress, cancellationToken);
}
/// <summary>
diff --git a/MediaBrowser.Server.Implementations/Library/SearchEngine.cs b/MediaBrowser.Server.Implementations/Library/SearchEngine.cs
index b22fd343b..aaafd35a9 100644
--- a/MediaBrowser.Server.Implementations/Library/SearchEngine.cs
+++ b/MediaBrowser.Server.Implementations/Library/SearchEngine.cs
@@ -102,7 +102,9 @@ namespace MediaBrowser.Server.Implementations.Library
if (query.IncludeArtists)
{
// Find artists
- var artists = _libraryManager.GetAllArtists(items)
+ var artists = items.OfType<Audio>()
+ .SelectMany(i => i.AllArtists)
+ .Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
foreach (var item in artists)
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs
index 1d9eea866..5968d847e 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs
@@ -1,8 +1,6 @@
using MediaBrowser.Common.Progress;
-using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
-using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using System;
@@ -69,10 +67,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
var numComplete = 0;
- var userLibraries = _userManager.Users
- .Select(i => new Tuple<Guid, List<IHasArtist>>(i.Id, i.RootFolder.GetRecursiveChildren(i).OfType<IHasArtist>().ToList()))
- .ToList();
-
var numArtists = allArtists.Count;
foreach (var artist in allArtists)
@@ -91,11 +85,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
.ToList();
}
- foreach (var lib in userLibraries)
- {
- SetItemCounts(artist, lib.Item1, lib.Item2);
- }
-
numComplete++;
double percent = numComplete;
percent /= numArtists;
@@ -108,37 +97,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
}
/// <summary>
- /// Sets the item counts.
- /// </summary>
- /// <param name="artist">The artist.</param>
- /// <param name="userId">The user id.</param>
- /// <param name="allItems">All items.</param>
- private void SetItemCounts(MusicArtist artist, Guid? userId, IEnumerable<IHasArtist> allItems)
- {
- var name = artist.Name;
-
- var items = allItems
- .Where(i => i.HasArtist(name))
- .ToList();
-
- var counts = new ItemByNameCounts
- {
- TotalCount = items.Count,
-
- SongCount = items.OfType<Audio>().Count(),
-
- AlbumCount = items.OfType<MusicAlbum>().Count(),
-
- MusicVideoCount = items.OfType<MusicVideo>().Count()
- };
-
- if (userId.HasValue)
- {
- artist.SetItemByNameCounts(userId.Value, counts);
- }
- }
-
- /// <summary>
/// Gets all artists.
/// </summary>
/// <param name="allSongs">All songs.</param>
@@ -147,7 +105,8 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// <returns>Task{Artist[]}.</returns>
private async Task<List<MusicArtist>> GetAllArtists(IEnumerable<Audio> allSongs, CancellationToken cancellationToken, IProgress<double> progress)
{
- var allArtists = _libraryManager.GetAllArtists(allSongs)
+ var allArtists = allSongs.SelectMany(i => i.AllArtists)
+ .Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
var returnArtists = new List<MusicArtist>(allArtists.Count);
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs
index 9e64c7810..6b658e175 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs
@@ -2,7 +2,6 @@
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
using System;
-using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -41,38 +40,24 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// <returns>Task.</returns>
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
- var userLibraries = _userManager.Users
- .Select(i => new Tuple<Guid, List<Game>>(i.Id, i.RootFolder.GetRecursiveChildren(i).OfType<Game>().ToList()))
+ var items = _libraryManager.RootFolder.RecursiveChildren.Where(i => (i is Game))
+ .SelectMany(i => i.Genres)
+ .Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
- var masterDictionary = new Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>>(StringComparer.OrdinalIgnoreCase);
-
progress.Report(2);
-
var numComplete = 0;
+ var count = items.Count;
- foreach (var lib in userLibraries)
+ foreach (var name in items)
{
- SetItemCounts(lib.Item1, lib.Item2, masterDictionary);
-
- numComplete++;
- double percent = numComplete;
- percent /= userLibraries.Count;
- percent *= 8;
-
- progress.Report(percent);
- }
+ cancellationToken.ThrowIfCancellationRequested();
- progress.Report(10);
-
- var count = masterDictionary.Count;
- numComplete = 0;
-
- foreach (var name in masterDictionary.Keys)
- {
try
{
- await UpdateItemByNameCounts(name, cancellationToken, masterDictionary[name]).ConfigureAwait(false);
+ var itemByName = _libraryManager.GetGameGenre(name);
+
+ await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
@@ -81,7 +66,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
}
catch (Exception ex)
{
- _logger.ErrorException("Error updating counts for {0}", ex, name);
+ _logger.ErrorException("Error refreshing {0}", ex, name);
}
numComplete++;
@@ -94,32 +79,5 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
progress.Report(100);
}
-
- private Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary<Guid, Dictionary<CountType, int>> counts)
- {
- var itemByName = _libraryManager.GetGameGenre(name);
-
- foreach (var libraryId in counts.Keys)
- {
- var itemCounts = CountHelpers.GetCounts(counts[libraryId]);
-
- itemByName.SetItemByNameCounts(libraryId, itemCounts);
- }
-
- return itemByName.RefreshMetadata(cancellationToken);
- }
-
- private void SetItemCounts(Guid userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>> masterDictionary)
- {
- foreach (var media in allItems)
- {
- var names = media
- .Genres
- .Distinct(StringComparer.OrdinalIgnoreCase)
- .ToList();
-
- CountHelpers.SetItemCounts(userId, media, names, masterDictionary);
- }
- }
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs
index e0a9e2ce8..b0dee9aaf 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs
@@ -3,7 +3,6 @@ using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
using System;
-using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -42,38 +41,24 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// <returns>Task.</returns>
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
- var userLibraries = _userManager.Users
- .Select(i => new Tuple<Guid, IList<BaseItem>>(i.Id, i.RootFolder.GetRecursiveChildren(i, m => !(m is IHasMusicGenres) && !(m is Game))))
+ var items = _libraryManager.RootFolder.RecursiveChildren.Where(i => !(i is IHasMusicGenres) && !(i is Game))
+ .SelectMany(i => i.Genres)
+ .Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
- var masterDictionary = new Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>>(StringComparer.OrdinalIgnoreCase);
-
progress.Report(2);
-
var numComplete = 0;
+ var count = items.Count;
- foreach (var lib in userLibraries)
+ foreach (var name in items)
{
- SetItemCounts(lib.Item1, lib.Item2, masterDictionary);
-
- numComplete++;
- double percent = numComplete;
- percent /= userLibraries.Count;
- percent *= 8;
-
- progress.Report(percent);
- }
+ cancellationToken.ThrowIfCancellationRequested();
- progress.Report(10);
-
- var count = masterDictionary.Count;
- numComplete = 0;
-
- foreach (var name in masterDictionary.Keys)
- {
try
{
- await UpdateItemByNameCounts(name, cancellationToken, masterDictionary[name]).ConfigureAwait(false);
+ var itemByName = _libraryManager.GetGenre(name);
+
+ await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
@@ -82,7 +67,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
}
catch (Exception ex)
{
- _logger.ErrorException("Error updating counts for {0}", ex, name);
+ _logger.ErrorException("Error refreshing {0}", ex, name);
}
numComplete++;
@@ -95,32 +80,5 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
progress.Report(100);
}
-
- private Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary<Guid, Dictionary<CountType, int>> counts)
- {
- var itemByName = _libraryManager.GetGenre(name);
-
- foreach (var libraryId in counts.Keys)
- {
- var itemCounts = CountHelpers.GetCounts(counts[libraryId]);
-
- itemByName.SetItemByNameCounts(libraryId, itemCounts);
- }
-
- return itemByName.RefreshMetadata(cancellationToken);
- }
-
- private void SetItemCounts(Guid userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>> masterDictionary)
- {
- foreach (var media in allItems)
- {
- var names = media
- .Genres
- .Distinct(StringComparer.OrdinalIgnoreCase)
- .ToList();
-
- CountHelpers.SetItemCounts(userId, media, names, masterDictionary);
- }
- }
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs
index b55ab1cbe..aa6c6281e 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs
@@ -1,9 +1,7 @@
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Entities.Audio;
+using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
using System;
-using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -18,19 +16,13 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
private readonly ILibraryManager _libraryManager;
/// <summary>
- /// The _user manager
- /// </summary>
- private readonly IUserManager _userManager;
-
- /// <summary>
/// The _logger
/// </summary>
private readonly ILogger _logger;
- public MusicGenresValidator(ILibraryManager libraryManager, IUserManager userManager, ILogger logger)
+ public MusicGenresValidator(ILibraryManager libraryManager, ILogger logger)
{
_libraryManager = libraryManager;
- _userManager = userManager;
_logger = logger;
}
@@ -42,38 +34,24 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// <returns>Task.</returns>
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
- var userLibraries = _userManager.Users
- .Select(i => new Tuple<Guid, IList<BaseItem>>(i.Id, i.RootFolder.GetRecursiveChildren(i, m => m is IHasMusicGenres)))
+ var items = _libraryManager.RootFolder.RecursiveChildren.Where(i => (i is IHasMusicGenres))
+ .SelectMany(i => i.Genres)
+ .Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
- var masterDictionary = new Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>>(StringComparer.OrdinalIgnoreCase);
-
progress.Report(2);
-
var numComplete = 0;
+ var count = items.Count;
- foreach (var lib in userLibraries)
+ foreach (var name in items)
{
- SetItemCounts(lib.Item1, lib.Item2, masterDictionary);
-
- numComplete++;
- double percent = numComplete;
- percent /= userLibraries.Count;
- percent *= 8;
-
- progress.Report(percent);
- }
-
- progress.Report(10);
+ cancellationToken.ThrowIfCancellationRequested();
- var count = masterDictionary.Count;
- numComplete = 0;
-
- foreach (var name in masterDictionary.Keys)
- {
try
{
- await UpdateItemByNameCounts(name, cancellationToken, masterDictionary[name]).ConfigureAwait(false);
+ var itemByName = _libraryManager.GetMusicGenre(name);
+
+ await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
@@ -82,7 +60,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
}
catch (Exception ex)
{
- _logger.ErrorException("Error updating counts for {0}", ex, name);
+ _logger.ErrorException("Error refreshing {0}", ex, name);
}
numComplete++;
@@ -95,32 +73,5 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
progress.Report(100);
}
-
- private Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary<Guid, Dictionary<CountType, int>> counts)
- {
- var itemByName = _libraryManager.GetMusicGenre(name);
-
- foreach (var libraryId in counts.Keys)
- {
- var itemCounts = CountHelpers.GetCounts(counts[libraryId]);
-
- itemByName.SetItemByNameCounts(libraryId, itemCounts);
- }
-
- return itemByName.RefreshMetadata(cancellationToken);
- }
-
- private void SetItemCounts(Guid userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>> masterDictionary)
- {
- foreach (var media in allItems)
- {
- var names = media
- .Genres
- .Distinct(StringComparer.OrdinalIgnoreCase)
- .ToList();
-
- CountHelpers.SetItemCounts(userId, media, names, masterDictionary);
- }
- }
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/PeoplePostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/PeoplePostScanTask.cs
index 86c5dbc4c..d11e62a1a 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/PeoplePostScanTask.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/PeoplePostScanTask.cs
@@ -1,10 +1,7 @@
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Logging;
using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -18,19 +15,13 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
private readonly ILibraryManager _libraryManager;
/// <summary>
- /// The _user manager
- /// </summary>
- private readonly IUserManager _userManager;
-
- /// <summary>
/// The _logger
/// </summary>
private readonly ILogger _logger;
- public PeoplePostScanTask(ILibraryManager libraryManager, IUserManager userManager, ILogger logger)
+ public PeoplePostScanTask(ILibraryManager libraryManager, ILogger logger)
{
_libraryManager = libraryManager;
- _userManager = userManager;
_logger = logger;
}
@@ -42,94 +33,12 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// <returns>Task.</returns>
public Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
- return RunInternal(progress, cancellationToken);
- }
-
- private async Task RunInternal(IProgress<double> progress, CancellationToken cancellationToken)
- {
- var userLibraries = _userManager.Users
- .Select(i => new Tuple<Guid, IList<BaseItem>>(i.Id, i.RootFolder.GetRecursiveChildren(i, null)))
- .ToList();
-
- var masterDictionary = new Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>>(StringComparer.OrdinalIgnoreCase);
-
- progress.Report(2);
-
- var numComplete = 0;
-
- foreach (var lib in userLibraries)
+ return new PeopleValidator(_libraryManager, _logger).ValidatePeople(cancellationToken, new MetadataRefreshOptions
{
- cancellationToken.ThrowIfCancellationRequested();
-
- SetItemCounts(lib.Item1, lib.Item2, masterDictionary);
-
- numComplete++;
- double percent = numComplete;
- percent /= userLibraries.Count;
- percent *= 8;
+ ImageRefreshMode = ImageRefreshMode.ValidationOnly,
+ MetadataRefreshMode = MetadataRefreshMode.None
- progress.Report(percent);
- }
-
- progress.Report(10);
-
- var count = masterDictionary.Count;
- numComplete = 0;
-
- foreach (var name in masterDictionary.Keys)
- {
- cancellationToken.ThrowIfCancellationRequested();
-
- try
- {
- var counts = masterDictionary[name];
-
- var itemByName = _libraryManager.GetPerson(name);
-
- // The only purpose here is to be able to react to image changes without running the people task.
- // All other metadata can wait for that.
- await itemByName.RefreshMetadata(new MetadataRefreshOptions
- {
- ImageRefreshMode = ImageRefreshMode.ValidationOnly,
- MetadataRefreshMode = MetadataRefreshMode.None
-
- }, cancellationToken).ConfigureAwait(false);
-
- foreach (var libraryId in counts.Keys)
- {
- var itemCounts = CountHelpers.GetCounts(counts[libraryId]);
-
- itemByName.SetItemByNameCounts(libraryId, itemCounts);
- }
- }
- catch (Exception ex)
- {
- _logger.ErrorException("Error updating counts for {0}", ex, name);
- }
-
- numComplete++;
- double percent = numComplete;
- percent /= count;
- percent *= 90;
-
- progress.Report(percent + 10);
- }
-
- progress.Report(100);
+ }, progress);
}
-
- private void SetItemCounts(Guid userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>> masterDictionary)
- {
- foreach (var media in allItems)
- {
- var names = media
- .People.Select(i => i.Name)
- .Distinct(StringComparer.OrdinalIgnoreCase)
- .ToList();
-
- CountHelpers.SetItemCounts(userId, media, names, masterDictionary);
- }
- }
-
}
}
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs
index 268bccd7a..722c24a10 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/PeopleValidator.cs
@@ -1,5 +1,6 @@
using MediaBrowser.Common.Progress;
using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Logging;
using MoreLinq;
using System;
@@ -38,9 +39,10 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// Validates the people.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
+ /// <param name="options">The options.</param>
/// <param name="progress">The progress.</param>
/// <returns>Task.</returns>
- public async Task ValidatePeople(CancellationToken cancellationToken, IProgress<double> progress)
+ public async Task ValidatePeople(CancellationToken cancellationToken, MetadataRefreshOptions options, IProgress<double> progress)
{
var innerProgress = new ActionableProgress<double>();
@@ -61,7 +63,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
{
var item = _libraryManager.GetPerson(person.Name);
- await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
+ await item.RefreshMetadata(options, cancellationToken).ConfigureAwait(false);
}
catch (Exception ex)
{
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs
index 54fadfb77..a2ec9788c 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs
@@ -1,8 +1,6 @@
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
using System;
-using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -41,38 +39,24 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
/// <returns>Task.</returns>
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
{
- var userLibraries = _userManager.Users
- .Select(i => new Tuple<Guid, IList<BaseItem>>(i.Id, i.RootFolder.GetRecursiveChildren(i, null)))
+ var items = _libraryManager.RootFolder.RecursiveChildren
+ .SelectMany(i => i.Studios)
+ .Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
- var masterDictionary = new Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>>(StringComparer.OrdinalIgnoreCase);
-
progress.Report(2);
-
var numComplete = 0;
+ var count = items.Count;
- foreach (var lib in userLibraries)
+ foreach (var name in items)
{
- SetItemCounts(lib.Item1, lib.Item2, masterDictionary);
-
- numComplete++;
- double percent = numComplete;
- percent /= userLibraries.Count;
- percent *= 8;
-
- progress.Report(percent);
- }
+ cancellationToken.ThrowIfCancellationRequested();
- progress.Report(10);
-
- var count = masterDictionary.Count;
- numComplete = 0;
-
- foreach (var name in masterDictionary.Keys)
- {
try
{
- await UpdateItemByNameCounts(name, cancellationToken, masterDictionary[name]).ConfigureAwait(false);
+ var itemByName = _libraryManager.GetStudio(name);
+
+ await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
{
@@ -81,7 +65,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
}
catch (Exception ex)
{
- _logger.ErrorException("Error updating counts for {0}", ex, name);
+ _logger.ErrorException("Error refreshing {0}", ex, name);
}
numComplete++;
@@ -94,32 +78,5 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
progress.Report(100);
}
-
- private Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary<Guid, Dictionary<CountType, int>> counts)
- {
- var itemByName = _libraryManager.GetStudio(name);
-
- foreach (var libraryId in counts.Keys)
- {
- var itemCounts = CountHelpers.GetCounts(counts[libraryId]);
-
- itemByName.SetItemByNameCounts(libraryId, itemCounts);
- }
-
- return itemByName.RefreshMetadata(cancellationToken);
- }
-
- private void SetItemCounts(Guid userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>> masterDictionary)
- {
- foreach (var media in allItems)
- {
- var names = media
- .Studios
- .Distinct(StringComparer.OrdinalIgnoreCase)
- .ToList();
-
- CountHelpers.SetItemCounts(userId, media, names, masterDictionary);
- }
- }
}
}
diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
index 7c0361a1f..6cd782140 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -47,6 +47,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
private List<Guid> _channelIdList = new List<Guid>();
private Dictionary<Guid, LiveTvProgram> _programs = new Dictionary<Guid, LiveTvProgram>();
+ private readonly ConcurrentDictionary<Guid, bool> _refreshedPrograms = new ConcurrentDictionary<Guid, bool>();
private readonly SemaphoreSlim _refreshSemaphore = new SemaphoreSlim(1, 1);
@@ -106,7 +107,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
_taskManager.CancelIfRunningAndQueue<RefreshChannelsScheduledTask>();
}
- public Task<QueryResult<ChannelInfoDto>> GetChannels(ChannelQuery query, CancellationToken cancellationToken)
+ public async Task<QueryResult<ChannelInfoDto>> GetChannels(ChannelQuery query, CancellationToken cancellationToken)
{
var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(new Guid(query.UserId));
@@ -161,17 +162,22 @@ namespace MediaBrowser.Server.Implementations.LiveTv
allEnumerable = allEnumerable.Take(query.Limit.Value);
}
- var returnChannels = allEnumerable
- .Select(i => _tvDtoService.GetChannelInfoDto(i, GetCurrentProgram(i.ExternalId), user))
- .ToArray();
+ var returnList = new List<ChannelInfoDto>();
+
+ foreach (var channel in allEnumerable)
+ {
+ var currentProgram = await GetCurrentProgram(channel.ExternalId, cancellationToken).ConfigureAwait(false);
+
+ returnList.Add(_tvDtoService.GetChannelInfoDto(channel, currentProgram, user));
+ }
var result = new QueryResult<ChannelInfoDto>
{
- Items = returnChannels,
- TotalRecordCount = allChannels.Count
+ Items = returnList.ToArray(),
+ TotalRecordCount = returnList.Count
};
- return Task.FromResult(result);
+ return result;
}
public LiveTvChannel GetInternalChannel(string id)
@@ -184,16 +190,41 @@ namespace MediaBrowser.Server.Implementations.LiveTv
return _libraryManager.GetItemById(id) as LiveTvChannel;
}
- public LiveTvProgram GetInternalProgram(string id)
+ public async Task<LiveTvProgram> GetInternalProgram(string id, CancellationToken cancellationToken)
{
var guid = new Guid(id);
LiveTvProgram obj = null;
_programs.TryGetValue(guid, out obj);
+
+ if (obj != null)
+ {
+ await RefreshIfNeeded(obj, cancellationToken).ConfigureAwait(false);
+ }
return obj;
}
+ private async Task RefreshIfNeeded(IEnumerable<LiveTvProgram> programs, CancellationToken cancellationToken)
+ {
+ foreach (var program in programs)
+ {
+ await RefreshIfNeeded(program, cancellationToken).ConfigureAwait(false);
+ }
+ }
+
+ private async Task RefreshIfNeeded(LiveTvProgram program, CancellationToken cancellationToken)
+ {
+ if (_refreshedPrograms.ContainsKey(program.Id))
+ {
+ return;
+ }
+
+ await program.RefreshMetadata(CancellationToken.None).ConfigureAwait(false);
+
+ _refreshedPrograms.TryAdd(program.Id, true);
+ }
+
public async Task<ILiveTvRecording> GetInternalRecording(string id, CancellationToken cancellationToken)
{
var service = ActiveService;
@@ -336,10 +367,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
return item;
}
- private async Task<LiveTvProgram> GetProgram(ProgramInfo info, ChannelType channelType, string serviceName, CancellationToken cancellationToken)
+ private LiveTvProgram GetProgram(ProgramInfo info, ChannelType channelType, string serviceName, CancellationToken cancellationToken)
{
- var isNew = false;
-
var id = _tvDtoService.GetInternalProgramId(serviceName, info.Id);
var item = _itemRepo.RetrieveItem(id) as LiveTvProgram;
@@ -353,8 +382,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv
DateCreated = DateTime.UtcNow,
DateModified = DateTime.UtcNow
};
-
- isNew = true;
}
item.ChannelType = channelType;
@@ -386,12 +413,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv
item.RunTimeTicks = (info.EndDate - info.StartDate).Ticks;
item.StartDate = info.StartDate;
- await item.RefreshMetadata(new MetadataRefreshOptions
- {
- ForceSave = isNew
-
- }, cancellationToken);
-
return item;
}
@@ -464,7 +485,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
public async Task<ProgramInfoDto> GetProgram(string id, CancellationToken cancellationToken, User user = null)
{
- var program = GetInternalProgram(id);
+ var program = await GetInternalProgram(id, cancellationToken).ConfigureAwait(false);
var channel = GetChannel(program);
@@ -531,7 +552,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv
programs = programs.Where(i => i.IsParentalAllowed(currentUser));
}
- var returnArray = programs
+ var programList = programs.ToList();
+
+ var returnArray = programList
.Select(i =>
{
var channel = GetChannel(i);
@@ -540,6 +563,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
})
.ToArray();
+ await RefreshIfNeeded(programList, cancellationToken).ConfigureAwait(false);
+
await AddRecordingInfo(returnArray, cancellationToken).ConfigureAwait(false);
var result = new QueryResult<ProgramInfoDto>
@@ -592,7 +617,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv
.OrderBy(i => i.StartDate);
}
- var returnArray = programs
+ programList = programs.ToList();
+
+ await RefreshIfNeeded(programList, cancellationToken).ConfigureAwait(false);
+
+ var returnArray = programList
.Select(i =>
{
var channel = GetChannel(i);
@@ -791,8 +820,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
var channelPrograms = await service.GetProgramsAsync(currentChannel.ExternalId, start, end, cancellationToken).ConfigureAwait(false);
- var programTasks = channelPrograms.Select(program => GetProgram(program, currentChannel.ChannelType, service.Name, cancellationToken));
- var programEntities = await Task.WhenAll(programTasks).ConfigureAwait(false);
+ var programEntities = channelPrograms.Select(program => GetProgram(program, currentChannel.ChannelType, service.Name, cancellationToken));
programs.AddRange(programEntities);
}
@@ -813,6 +841,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
}
_programs = programs.ToDictionary(i => i.Id);
+ _refreshedPrograms.Clear();
progress.Report(90);
// Load these now which will prefetch metadata
@@ -1031,14 +1060,20 @@ namespace MediaBrowser.Server.Implementations.LiveTv
.Where(i => _tvDtoService.GetInternalSeriesTimerId(currentServiceName, i.SeriesTimerId) == guid);
}
- var returnArray = timers
- .Select(i =>
- {
- var program = string.IsNullOrEmpty(i.ProgramId) ? null : GetInternalProgram(_tvDtoService.GetInternalProgramId(service.Name, i.ProgramId).ToString("N"));
- var channel = string.IsNullOrEmpty(i.ChannelId) ? null : GetInternalChannel(_tvDtoService.GetInternalChannelId(service.Name, i.ChannelId));
+ var returnList = new List<TimerInfoDto>();
- return _tvDtoService.GetTimerInfoDto(i, service, program, channel);
- })
+ foreach (var i in timers)
+ {
+ var program = string.IsNullOrEmpty(i.ProgramId) ?
+ null :
+ await GetInternalProgram(_tvDtoService.GetInternalProgramId(service.Name, i.ProgramId).ToString("N"), cancellationToken).ConfigureAwait(false);
+
+ var channel = string.IsNullOrEmpty(i.ChannelId) ? null : GetInternalChannel(_tvDtoService.GetInternalChannelId(service.Name, i.ChannelId));
+
+ returnList.Add(_tvDtoService.GetTimerInfoDto(i, service, program, channel));
+ }
+
+ var returnArray = returnList
.OrderBy(i => i.StartDate)
.ToArray();
@@ -1163,24 +1198,33 @@ namespace MediaBrowser.Server.Implementations.LiveTv
};
}
- public Task<ChannelInfoDto> GetChannel(string id, CancellationToken cancellationToken, User user = null)
+ public async Task<ChannelInfoDto> GetChannel(string id, CancellationToken cancellationToken, User user = null)
{
var channel = GetInternalChannel(id);
- var dto = _tvDtoService.GetChannelInfoDto(channel, GetCurrentProgram(channel.ExternalId), user);
+ var currentProgram = await GetCurrentProgram(channel.ExternalId, cancellationToken).ConfigureAwait(false);
+
+ var dto = _tvDtoService.GetChannelInfoDto(channel, currentProgram, user);
- return Task.FromResult(dto);
+ return dto;
}
- private LiveTvProgram GetCurrentProgram(string externalChannelId)
+ private async Task<LiveTvProgram> GetCurrentProgram(string externalChannelId, CancellationToken cancellationToken)
{
var now = DateTime.UtcNow;
- return _programs.Values
+ var program = _programs.Values
.Where(i => string.Equals(externalChannelId, i.ExternalChannelId, StringComparison.OrdinalIgnoreCase))
.OrderBy(i => i.StartDate)
.SkipWhile(i => now >= (i.EndDate ?? DateTime.MinValue))
.FirstOrDefault();
+
+ if (program != null)
+ {
+ await RefreshIfNeeded(program, cancellationToken).ConfigureAwait(false);
+ }
+
+ return program;
}
private async Task<SeriesTimerInfo> GetNewTimerDefaultsInternal(CancellationToken cancellationToken, LiveTvProgram program = null)
@@ -1236,7 +1280,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
public async Task<SeriesTimerInfoDto> GetNewTimerDefaults(string programId, CancellationToken cancellationToken)
{
- var program = GetInternalProgram(programId);
+ var program = await GetInternalProgram(programId, cancellationToken).ConfigureAwait(false);
var programDto = await GetProgram(programId, cancellationToken).ConfigureAwait(false);
var defaults = await GetNewTimerDefaultsInternal(cancellationToken, program).ConfigureAwait(false);
diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
index 78902f0dc..c44b60845 100644
--- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
+++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
@@ -216,7 +216,6 @@
<Compile Include="Sorting\AirTimeComparer.cs" />
<Compile Include="Sorting\AlbumArtistComparer.cs" />
<Compile Include="Sorting\AlbumComparer.cs" />
- <Compile Include="Sorting\AlbumCountComparer.cs" />
<Compile Include="Sorting\AlphanumComparator.cs" />
<Compile Include="Sorting\ArtistComparer.cs" />
<Compile Include="Sorting\BudgetComparer.cs" />
@@ -224,13 +223,10 @@
<Compile Include="Sorting\CriticRatingComparer.cs" />
<Compile Include="Sorting\DateCreatedComparer.cs" />
<Compile Include="Sorting\DatePlayedComparer.cs" />
- <Compile Include="Sorting\EpisodeCountComparer.cs" />
<Compile Include="Sorting\GameSystemComparer.cs" />
<Compile Include="Sorting\IsFolderComparer.cs" />
<Compile Include="Sorting\IsUnplayedComparer.cs" />
<Compile Include="Sorting\MetascoreComparer.cs" />
- <Compile Include="Sorting\MovieCountComparer.cs" />
- <Compile Include="Sorting\MusicVideoCountComparer.cs" />
<Compile Include="Sorting\NameComparer.cs" />
<Compile Include="Sorting\OfficialRatingComparer.cs" />
<Compile Include="Sorting\PlayCountComparer.cs" />
@@ -240,16 +236,13 @@
<Compile Include="Sorting\RandomComparer.cs" />
<Compile Include="Sorting\RevenueComparer.cs" />
<Compile Include="Sorting\RuntimeComparer.cs" />
- <Compile Include="Sorting\SeriesCountComparer.cs" />
<Compile Include="Sorting\SeriesSortNameComparer.cs" />
- <Compile Include="Sorting\SongCountComparer.cs" />
<Compile Include="Sorting\SortNameComparer.cs" />
<Compile Include="Persistence\SqliteDisplayPreferencesRepository.cs" />
<Compile Include="Persistence\SqliteItemRepository.cs" />
<Compile Include="Persistence\SqliteUserDataRepository.cs" />
<Compile Include="Persistence\SqliteUserRepository.cs" />
<Compile Include="Sorting\StudioComparer.cs" />
- <Compile Include="Sorting\TrailerCountComparer.cs" />
<Compile Include="Sorting\VideoBitRateComparer.cs" />
<Compile Include="Themes\AppThemeManager.cs" />
<Compile Include="Udp\UdpMessageReceivedEventArgs.cs" />
diff --git a/MediaBrowser.Server.Implementations/Sorting/AlbumCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/AlbumCountComparer.cs
deleted file mode 100644
index e35ba00f2..000000000
--- a/MediaBrowser.Server.Implementations/Sorting/AlbumCountComparer.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Library;
-using MediaBrowser.Controller.Persistence;
-using MediaBrowser.Controller.Sorting;
-using MediaBrowser.Model.Querying;
-
-namespace MediaBrowser.Server.Implementations.Sorting
-{
- class AlbumCountComparer : IUserBaseItemComparer
- {
- /// <summary>
- /// Gets or sets the user.
- /// </summary>
- /// <value>The user.</value>
- public User User { get; set; }
-
- /// <summary>
- /// Gets or sets the user manager.
- /// </summary>
- /// <value>The user manager.</value>
- public IUserManager UserManager { get; set; }
-
- /// <summary>
- /// Gets or sets the user data repository.
- /// </summary>
- /// <value>The user data repository.</value>
- public IUserDataManager UserDataRepository { get; set; }
-
- /// <summary>
- /// Compares the specified x.
- /// </summary>
- /// <param name="x">The x.</param>
- /// <param name="y">The y.</param>
- /// <returns>System.Int32.</returns>
- public int Compare(BaseItem x, BaseItem y)
- {
- return GetValue(x).CompareTo(GetValue(y));
- }
-
- /// <summary>
- /// Gets the date.
- /// </summary>
- /// <param name="x">The x.</param>
- /// <returns>DateTime.</returns>
- private int GetValue(BaseItem x)
- {
- var itemByName = x as IItemByName;
-
- if (itemByName != null)
- {
- var counts = itemByName.GetItemByNameCounts(User.Id);
-
- if (counts != null)
- {
- return counts.AlbumCount;
- }
- }
-
- return 0;
- }
-
- /// <summary>
- /// Gets the name.
- /// </summary>
- /// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.AlbumCount; }
- }
- }
-}
diff --git a/MediaBrowser.Server.Implementations/Sorting/EpisodeCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/EpisodeCountComparer.cs
deleted file mode 100644
index b3fd8a023..000000000
--- a/MediaBrowser.Server.Implementations/Sorting/EpisodeCountComparer.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Library;
-using MediaBrowser.Controller.Persistence;
-using MediaBrowser.Controller.Sorting;
-using MediaBrowser.Model.Querying;
-
-namespace MediaBrowser.Server.Implementations.Sorting
-{
- class EpisodeCountComparer : IUserBaseItemComparer
- {
- /// <summary>
- /// Gets or sets the user.
- /// </summary>
- /// <value>The user.</value>
- public User User { get; set; }
-
- /// <summary>
- /// Gets or sets the user manager.
- /// </summary>
- /// <value>The user manager.</value>
- public IUserManager UserManager { get; set; }
-
- /// <summary>
- /// Gets or sets the user data repository.
- /// </summary>
- /// <value>The user data repository.</value>
- public IUserDataManager UserDataRepository { get; set; }
-
- /// <summary>
- /// Compares the specified x.
- /// </summary>
- /// <param name="x">The x.</param>
- /// <param name="y">The y.</param>
- /// <returns>System.Int32.</returns>
- public int Compare(BaseItem x, BaseItem y)
- {
- return GetValue(x).CompareTo(GetValue(y));
- }
-
- /// <summary>
- /// Gets the date.
- /// </summary>
- /// <param name="x">The x.</param>
- /// <returns>DateTime.</returns>
- private int GetValue(BaseItem x)
- {
- var itemByName = x as IItemByName;
-
- if (itemByName != null)
- {
- var counts = itemByName.GetItemByNameCounts(User.Id);
-
- if (counts != null)
- {
- return counts.EpisodeCount;
- }
- }
-
- return 0;
- }
-
- /// <summary>
- /// Gets the name.
- /// </summary>
- /// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.EpisodeCount; }
- }
- }
-}
diff --git a/MediaBrowser.Server.Implementations/Sorting/MovieCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/MovieCountComparer.cs
deleted file mode 100644
index 605f4d1af..000000000
--- a/MediaBrowser.Server.Implementations/Sorting/MovieCountComparer.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Library;
-using MediaBrowser.Controller.Persistence;
-using MediaBrowser.Controller.Sorting;
-using MediaBrowser.Model.Querying;
-
-namespace MediaBrowser.Server.Implementations.Sorting
-{
- public class MovieCountComparer : IUserBaseItemComparer
- {
- /// <summary>
- /// Gets or sets the user.
- /// </summary>
- /// <value>The user.</value>
- public User User { get; set; }
-
- /// <summary>
- /// Gets or sets the user manager.
- /// </summary>
- /// <value>The user manager.</value>
- public IUserManager UserManager { get; set; }
-
- /// <summary>
- /// Gets or sets the user data repository.
- /// </summary>
- /// <value>The user data repository.</value>
- public IUserDataManager UserDataRepository { get; set; }
-
- /// <summary>
- /// Compares the specified x.
- /// </summary>
- /// <param name="x">The x.</param>
- /// <param name="y">The y.</param>
- /// <returns>System.Int32.</returns>
- public int Compare(BaseItem x, BaseItem y)
- {
- return GetValue(x).CompareTo(GetValue(y));
- }
-
- /// <summary>
- /// Gets the date.
- /// </summary>
- /// <param name="x">The x.</param>
- /// <returns>DateTime.</returns>
- private int GetValue(BaseItem x)
- {
- var itemByName = x as IItemByName;
-
- if (itemByName != null)
- {
- var counts = itemByName.GetItemByNameCounts(User.Id);
-
- if (counts != null)
- {
- return counts.MovieCount;
- }
- }
-
- return 0;
- }
-
- /// <summary>
- /// Gets the name.
- /// </summary>
- /// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.MovieCount; }
- }
- }
-}
diff --git a/MediaBrowser.Server.Implementations/Sorting/MusicVideoCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/MusicVideoCountComparer.cs
deleted file mode 100644
index 6c9c5534d..000000000
--- a/MediaBrowser.Server.Implementations/Sorting/MusicVideoCountComparer.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Library;
-using MediaBrowser.Controller.Persistence;
-using MediaBrowser.Controller.Sorting;
-using MediaBrowser.Model.Querying;
-
-namespace MediaBrowser.Server.Implementations.Sorting
-{
- class MusicVideoCountComparer : IUserBaseItemComparer
- {
- /// <summary>
- /// Gets or sets the user.
- /// </summary>
- /// <value>The user.</value>
- public User User { get; set; }
-
- /// <summary>
- /// Gets or sets the user manager.
- /// </summary>
- /// <value>The user manager.</value>
- public IUserManager UserManager { get; set; }
-
- /// <summary>
- /// Gets or sets the user data repository.
- /// </summary>
- /// <value>The user data repository.</value>
- public IUserDataManager UserDataRepository { get; set; }
-
- /// <summary>
- /// Compares the specified x.
- /// </summary>
- /// <param name="x">The x.</param>
- /// <param name="y">The y.</param>
- /// <returns>System.Int32.</returns>
- public int Compare(BaseItem x, BaseItem y)
- {
- return GetValue(x).CompareTo(GetValue(y));
- }
-
- /// <summary>
- /// Gets the date.
- /// </summary>
- /// <param name="x">The x.</param>
- /// <returns>DateTime.</returns>
- private int GetValue(BaseItem x)
- {
- var itemByName = x as IItemByName;
-
- if (itemByName != null)
- {
- var counts = itemByName.GetItemByNameCounts(User.Id);
-
- if (counts != null)
- {
- return counts.MusicVideoCount;
- }
- }
-
- return 0;
- }
-
- /// <summary>
- /// Gets the name.
- /// </summary>
- /// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.MusicVideoCount; }
- }
- }
-}
diff --git a/MediaBrowser.Server.Implementations/Sorting/SeriesCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/SeriesCountComparer.cs
deleted file mode 100644
index 8567e400c..000000000
--- a/MediaBrowser.Server.Implementations/Sorting/SeriesCountComparer.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Library;
-using MediaBrowser.Controller.Persistence;
-using MediaBrowser.Controller.Sorting;
-using MediaBrowser.Model.Querying;
-
-namespace MediaBrowser.Server.Implementations.Sorting
-{
- class SeriesCountComparer : IUserBaseItemComparer
- {
- /// <summary>
- /// Gets or sets the user.
- /// </summary>
- /// <value>The user.</value>
- public User User { get; set; }
-
- /// <summary>
- /// Gets or sets the user manager.
- /// </summary>
- /// <value>The user manager.</value>
- public IUserManager UserManager { get; set; }
-
- /// <summary>
- /// Gets or sets the user data repository.
- /// </summary>
- /// <value>The user data repository.</value>
- public IUserDataManager UserDataRepository { get; set; }
-
- /// <summary>
- /// Compares the specified x.
- /// </summary>
- /// <param name="x">The x.</param>
- /// <param name="y">The y.</param>
- /// <returns>System.Int32.</returns>
- public int Compare(BaseItem x, BaseItem y)
- {
- return GetValue(x).CompareTo(GetValue(y));
- }
-
- /// <summary>
- /// Gets the date.
- /// </summary>
- /// <param name="x">The x.</param>
- /// <returns>DateTime.</returns>
- private int GetValue(BaseItem x)
- {
- var itemByName = x as IItemByName;
-
- if (itemByName != null)
- {
- var counts = itemByName.GetItemByNameCounts(User.Id);
-
- if (counts != null)
- {
- return counts.SeriesCount;
- }
- }
-
- return 0;
- }
-
- /// <summary>
- /// Gets the name.
- /// </summary>
- /// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.SeriesCount; }
- }
- }
-}
diff --git a/MediaBrowser.Server.Implementations/Sorting/SongCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/SongCountComparer.cs
deleted file mode 100644
index 85b849a21..000000000
--- a/MediaBrowser.Server.Implementations/Sorting/SongCountComparer.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Library;
-using MediaBrowser.Controller.Persistence;
-using MediaBrowser.Controller.Sorting;
-using MediaBrowser.Model.Querying;
-
-namespace MediaBrowser.Server.Implementations.Sorting
-{
- class SongCountComparer : IUserBaseItemComparer
- {
- /// <summary>
- /// Gets or sets the user.
- /// </summary>
- /// <value>The user.</value>
- public User User { get; set; }
-
- /// <summary>
- /// Gets or sets the user manager.
- /// </summary>
- /// <value>The user manager.</value>
- public IUserManager UserManager { get; set; }
-
- /// <summary>
- /// Gets or sets the user data repository.
- /// </summary>
- /// <value>The user data repository.</value>
- public IUserDataManager UserDataRepository { get; set; }
-
- /// <summary>
- /// Compares the specified x.
- /// </summary>
- /// <param name="x">The x.</param>
- /// <param name="y">The y.</param>
- /// <returns>System.Int32.</returns>
- public int Compare(BaseItem x, BaseItem y)
- {
- return GetValue(x).CompareTo(GetValue(y));
- }
-
- /// <summary>
- /// Gets the date.
- /// </summary>
- /// <param name="x">The x.</param>
- /// <returns>DateTime.</returns>
- private int GetValue(BaseItem x)
- {
- var itemByName = x as IItemByName;
-
- if (itemByName != null)
- {
- var counts = itemByName.GetItemByNameCounts(User.Id);
-
- if (counts != null)
- {
- return counts.SongCount;
- }
- }
-
- return 0;
- }
-
- /// <summary>
- /// Gets the name.
- /// </summary>
- /// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.SongCount; }
- }
- }
-}
diff --git a/MediaBrowser.Server.Implementations/Sorting/TrailerCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/TrailerCountComparer.cs
deleted file mode 100644
index a13875674..000000000
--- a/MediaBrowser.Server.Implementations/Sorting/TrailerCountComparer.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Library;
-using MediaBrowser.Controller.Persistence;
-using MediaBrowser.Controller.Sorting;
-using MediaBrowser.Model.Querying;
-
-namespace MediaBrowser.Server.Implementations.Sorting
-{
- public class TrailerCountComparer : IUserBaseItemComparer
- {
- /// <summary>
- /// Gets or sets the user.
- /// </summary>
- /// <value>The user.</value>
- public User User { get; set; }
-
- /// <summary>
- /// Gets or sets the user manager.
- /// </summary>
- /// <value>The user manager.</value>
- public IUserManager UserManager { get; set; }
-
- /// <summary>
- /// Gets or sets the user data repository.
- /// </summary>
- /// <value>The user data repository.</value>
- public IUserDataManager UserDataRepository { get; set; }
-
- /// <summary>
- /// Compares the specified x.
- /// </summary>
- /// <param name="x">The x.</param>
- /// <param name="y">The y.</param>
- /// <returns>System.Int32.</returns>
- public int Compare(BaseItem x, BaseItem y)
- {
- return GetValue(x).CompareTo(GetValue(y));
- }
-
- /// <summary>
- /// Gets the date.
- /// </summary>
- /// <param name="x">The x.</param>
- /// <returns>DateTime.</returns>
- private int GetValue(BaseItem x)
- {
- var itemByName = x as IItemByName;
-
- if (itemByName != null)
- {
- var counts = itemByName.GetItemByNameCounts(User.Id);
-
- if (counts != null)
- {
- return counts.TrailerCount;
- }
- }
-
- return 0;
- }
-
- /// <summary>
- /// Gets the name.
- /// </summary>
- /// <value>The name.</value>
- public string Name
- {
- get { return ItemSortBy.TrailerCount; }
- }
- }
-}