update validators
This commit is contained in:
parent
407d82ea11
commit
319a956b38
|
@ -11,6 +11,7 @@ using System.Linq;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using CommonIO;
|
||||
using MediaBrowser.Model.Dto;
|
||||
|
||||
namespace MediaBrowser.Api
|
||||
{
|
||||
|
@ -81,11 +82,18 @@ namespace MediaBrowser.Api
|
|||
|
||||
var dtoOptions = GetDtoOptions(request);
|
||||
|
||||
var video = (Video)item;
|
||||
|
||||
var items = video.GetAdditionalParts()
|
||||
var video = item as Video;
|
||||
BaseItemDto[] items;
|
||||
if (video != null)
|
||||
{
|
||||
items = video.GetAdditionalParts()
|
||||
.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, video))
|
||||
.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new BaseItemDto[] { };
|
||||
}
|
||||
|
||||
var result = new ItemsResult
|
||||
{
|
||||
|
|
|
@ -562,5 +562,6 @@ namespace MediaBrowser.Controller.Library
|
|||
QueryResult<Tuple<BaseItem, ItemCounts>> GetStudios(InternalItemsQuery query);
|
||||
QueryResult<Tuple<BaseItem, ItemCounts>> GetArtists(InternalItemsQuery query);
|
||||
QueryResult<Tuple<BaseItem, ItemCounts>> GetAlbumArtists(InternalItemsQuery query);
|
||||
QueryResult<Tuple<BaseItem, ItemCounts>> GetAllArtists(InternalItemsQuery query);
|
||||
}
|
||||
}
|
|
@ -169,6 +169,7 @@ namespace MediaBrowser.Controller.Persistence
|
|||
QueryResult<Tuple<BaseItem, ItemCounts>> GetStudios(InternalItemsQuery query);
|
||||
QueryResult<Tuple<BaseItem, ItemCounts>> GetArtists(InternalItemsQuery query);
|
||||
QueryResult<Tuple<BaseItem, ItemCounts>> GetAlbumArtists(InternalItemsQuery query);
|
||||
QueryResult<Tuple<BaseItem, ItemCounts>> GetAllArtists(InternalItemsQuery query);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1385,6 +1385,17 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
return ItemRepository.GetMusicGenres(query);
|
||||
}
|
||||
|
||||
public QueryResult<Tuple<BaseItem, ItemCounts>> GetAllArtists(InternalItemsQuery query)
|
||||
{
|
||||
if (query.User != null)
|
||||
{
|
||||
AddUserToQuery(query, query.User);
|
||||
}
|
||||
|
||||
SetTopParentOrAncestorIds(query);
|
||||
return ItemRepository.GetAllArtists(query);
|
||||
}
|
||||
|
||||
public QueryResult<Tuple<BaseItem, ItemCounts>> GetArtists(InternalItemsQuery query)
|
||||
{
|
||||
if (query.User != null)
|
||||
|
|
|
@ -6,6 +6,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
{
|
||||
|
@ -43,36 +44,39 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||
/// <returns>Task.</returns>
|
||||
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var allSongs = _libraryManager.RootFolder
|
||||
.GetRecursiveChildren(i => !i.IsFolder && i is IHasArtist)
|
||||
.Cast<IHasArtist>()
|
||||
var items = _libraryManager.GetAllArtists(new InternalItemsQuery())
|
||||
.Items
|
||||
.Select(i => i.Item1)
|
||||
.ToList();
|
||||
|
||||
var allArtists = _libraryManager.GetArtists(allSongs).ToList();
|
||||
|
||||
var numComplete = 0;
|
||||
var numArtists = allArtists.Count;
|
||||
var count = items.Count;
|
||||
|
||||
foreach (var artistItem in allArtists)
|
||||
foreach (var item in items)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
try
|
||||
{
|
||||
await artistItem.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||
await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (IOException ex)
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
_logger.ErrorException("Error validating Artist {0}", ex, artistItem.Name);
|
||||
// Don't clutter the log
|
||||
break;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error refreshing {0}", ex, item.Name);
|
||||
}
|
||||
|
||||
// Update progress
|
||||
numComplete++;
|
||||
double percent = numComplete;
|
||||
percent /= numArtists;
|
||||
percent /= count;
|
||||
percent *= 100;
|
||||
|
||||
progress.Report(100 * percent);
|
||||
}
|
||||
progress.Report(percent);
|
||||
}
|
||||
|
||||
progress.Report(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,21 +34,22 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||
/// <returns>Task.</returns>
|
||||
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var items = _libraryManager.RootFolder.GetRecursiveChildren(i => i is Game)
|
||||
.SelectMany(i => i.Genres)
|
||||
.DistinctNames()
|
||||
var items = _libraryManager.GetGameGenres(new InternalItemsQuery
|
||||
{
|
||||
IncludeItemTypes = new[] { typeof(Game).Name }
|
||||
})
|
||||
.Items
|
||||
.Select(i => i.Item1)
|
||||
.ToList();
|
||||
|
||||
var numComplete = 0;
|
||||
var count = items.Count;
|
||||
|
||||
foreach (var name in items)
|
||||
foreach (var item in items)
|
||||
{
|
||||
try
|
||||
{
|
||||
var itemByName = _libraryManager.GetGameGenre(name);
|
||||
|
||||
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||
await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
@ -57,7 +58,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error refreshing {0}", ex, name);
|
||||
_logger.ErrorException("Error refreshing {0}", ex, item.Name);
|
||||
}
|
||||
|
||||
numComplete++;
|
||||
|
|
|
@ -35,21 +35,22 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||
/// <returns>Task.</returns>
|
||||
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var items = _libraryManager.RootFolder.GetRecursiveChildren(i => !(i is IHasMusicGenres) && !(i is Game))
|
||||
.SelectMany(i => i.Genres)
|
||||
.DistinctNames()
|
||||
var items = _libraryManager.GetGenres(new InternalItemsQuery
|
||||
{
|
||||
ExcludeItemTypes = new[] { typeof(Audio).Name, typeof(MusicArtist).Name, typeof(MusicAlbum).Name, typeof(MusicVideo).Name, typeof(Game).Name }
|
||||
})
|
||||
.Items
|
||||
.Select(i => i.Item1)
|
||||
.ToList();
|
||||
|
||||
var numComplete = 0;
|
||||
var count = items.Count;
|
||||
|
||||
foreach (var name in items)
|
||||
foreach (var item in items)
|
||||
{
|
||||
try
|
||||
{
|
||||
var itemByName = _libraryManager.GetGenre(name);
|
||||
|
||||
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||
await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
@ -58,7 +59,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error refreshing {0}", ex, name);
|
||||
_logger.ErrorException("Error refreshing {0}", ex, item.Name);
|
||||
}
|
||||
|
||||
numComplete++;
|
||||
|
|
|
@ -5,6 +5,7 @@ using System;
|
|||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
{
|
||||
|
@ -34,21 +35,22 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||
/// <returns>Task.</returns>
|
||||
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var items = _libraryManager.RootFolder.GetRecursiveChildren(i => i is IHasMusicGenres)
|
||||
.SelectMany(i => i.Genres)
|
||||
.DistinctNames()
|
||||
var items = _libraryManager.GetMusicGenres(new InternalItemsQuery
|
||||
{
|
||||
IncludeItemTypes = new[] { typeof(Audio).Name, typeof(MusicArtist).Name, typeof(MusicAlbum).Name, typeof(MusicVideo).Name }
|
||||
})
|
||||
.Items
|
||||
.Select(i => i.Item1)
|
||||
.ToList();
|
||||
|
||||
var numComplete = 0;
|
||||
var count = items.Count;
|
||||
|
||||
foreach (var name in items)
|
||||
foreach (var item in items)
|
||||
{
|
||||
try
|
||||
{
|
||||
var itemByName = _libraryManager.GetMusicGenre(name);
|
||||
|
||||
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||
await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
@ -57,7 +59,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error refreshing {0}", ex, name);
|
||||
_logger.ErrorException("Error refreshing {0}", ex, item.Name);
|
||||
}
|
||||
|
||||
numComplete++;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
{
|
||||
|
@ -34,21 +34,19 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||
/// <returns>Task.</returns>
|
||||
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var items = _libraryManager.RootFolder.GetRecursiveChildren(i => true)
|
||||
.SelectMany(i => i.Studios)
|
||||
.DistinctNames()
|
||||
var items = _libraryManager.GetStudios(new InternalItemsQuery())
|
||||
.Items
|
||||
.Select(i => i.Item1)
|
||||
.ToList();
|
||||
|
||||
var numComplete = 0;
|
||||
var count = items.Count;
|
||||
|
||||
foreach (var name in items)
|
||||
foreach (var item in items)
|
||||
{
|
||||
try
|
||||
{
|
||||
var itemByName = _libraryManager.GetStudio(name);
|
||||
|
||||
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||
await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
@ -57,7 +55,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error refreshing {0}", ex, name);
|
||||
_logger.ErrorException("Error refreshing {0}", ex, item.Name);
|
||||
}
|
||||
|
||||
numComplete++;
|
||||
|
|
|
@ -3817,37 +3817,42 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
}
|
||||
}
|
||||
|
||||
public QueryResult<Tuple<BaseItem, ItemCounts>> GetAllArtists(InternalItemsQuery query)
|
||||
{
|
||||
return GetItemValues(query, new[] { 0, 1 }, typeof(MusicArtist).FullName);
|
||||
}
|
||||
|
||||
public QueryResult<Tuple<BaseItem, ItemCounts>> GetArtists(InternalItemsQuery query)
|
||||
{
|
||||
return GetItemValues(query, 0, typeof(MusicArtist).FullName);
|
||||
return GetItemValues(query, new[] { 0 }, typeof(MusicArtist).FullName);
|
||||
}
|
||||
|
||||
public QueryResult<Tuple<BaseItem, ItemCounts>> GetAlbumArtists(InternalItemsQuery query)
|
||||
{
|
||||
return GetItemValues(query, 1, typeof(MusicArtist).FullName);
|
||||
return GetItemValues(query, new[] { 1 }, typeof(MusicArtist).FullName);
|
||||
}
|
||||
|
||||
public QueryResult<Tuple<BaseItem, ItemCounts>> GetStudios(InternalItemsQuery query)
|
||||
{
|
||||
return GetItemValues(query, 3, typeof(Studio).FullName);
|
||||
return GetItemValues(query, new[] { 3 }, typeof(Studio).FullName);
|
||||
}
|
||||
|
||||
public QueryResult<Tuple<BaseItem, ItemCounts>> GetGenres(InternalItemsQuery query)
|
||||
{
|
||||
return GetItemValues(query, 2, typeof(Genre).FullName);
|
||||
return GetItemValues(query, new[] { 2 }, typeof(Genre).FullName);
|
||||
}
|
||||
|
||||
public QueryResult<Tuple<BaseItem, ItemCounts>> GetGameGenres(InternalItemsQuery query)
|
||||
{
|
||||
return GetItemValues(query, 2, typeof(GameGenre).FullName);
|
||||
return GetItemValues(query, new[] { 2 }, typeof(GameGenre).FullName);
|
||||
}
|
||||
|
||||
public QueryResult<Tuple<BaseItem, ItemCounts>> GetMusicGenres(InternalItemsQuery query)
|
||||
{
|
||||
return GetItemValues(query, 2, typeof(MusicGenre).FullName);
|
||||
return GetItemValues(query, new[] { 2 }, typeof(MusicGenre).FullName);
|
||||
}
|
||||
|
||||
private QueryResult<Tuple<BaseItem, ItemCounts>> GetItemValues(InternalItemsQuery query, int itemValueType, string returnType)
|
||||
private QueryResult<Tuple<BaseItem, ItemCounts>> GetItemValues(InternalItemsQuery query, int[] itemValueTypes, string returnType)
|
||||
{
|
||||
if (query == null)
|
||||
{
|
||||
|
@ -3863,6 +3868,10 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
|
||||
var now = DateTime.UtcNow;
|
||||
|
||||
var typeClause = itemValueTypes.Length == 1 ?
|
||||
("Type=" + itemValueTypes[0].ToString(CultureInfo.InvariantCulture)) :
|
||||
("Type in (" + string.Join(",", itemValueTypes.Select(i => i.ToString(CultureInfo.InvariantCulture)).ToArray()) + ")");
|
||||
|
||||
using (var cmd = _connection.CreateCommand())
|
||||
{
|
||||
var itemCountColumns = new List<Tuple<string, string>>();
|
||||
|
@ -3887,7 +3896,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
};
|
||||
var whereClauses = GetWhereClauses(typeSubQuery, cmd, "itemTypes");
|
||||
|
||||
whereClauses.Add("guid in (select ItemId from ItemValues where ItemValues.CleanValue=A.CleanName AND Type=@ItemValueType)");
|
||||
whereClauses.Add("guid in (select ItemId from ItemValues where ItemValues.CleanValue=A.CleanName AND " + typeClause + ")");
|
||||
|
||||
var typeWhereText = whereClauses.Count == 0 ?
|
||||
string.Empty :
|
||||
|
@ -3929,12 +3938,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
|
||||
if (typesToCount.Count == 0)
|
||||
{
|
||||
whereText += " And CleanName In (Select CleanValue from ItemValues where Type=@ItemValueType AND ItemId in (select guid from TypedBaseItems" + innerWhereText + "))";
|
||||
whereText += " And CleanName In (Select CleanValue from ItemValues where " + typeClause + " AND ItemId in (select guid from TypedBaseItems" + innerWhereText + "))";
|
||||
}
|
||||
else
|
||||
{
|
||||
//whereText += " And itemTypes not null";
|
||||
whereText += " And CleanName In (Select CleanValue from ItemValues where Type=@ItemValueType AND ItemId in (select guid from TypedBaseItems" + innerWhereText + "))";
|
||||
whereText += " And CleanName In (Select CleanValue from ItemValues where " + typeClause + " AND ItemId in (select guid from TypedBaseItems" + innerWhereText + "))";
|
||||
}
|
||||
|
||||
var outerQuery = new InternalItemsQuery(query.User)
|
||||
|
@ -3964,7 +3973,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
cmd.CommandText += " group by PresentationUniqueKey";
|
||||
|
||||
cmd.Parameters.Add(cmd, "@SelectType", DbType.String).Value = returnType;
|
||||
cmd.Parameters.Add(cmd, "@ItemValueType", DbType.Int32).Value = itemValueType;
|
||||
|
||||
if (EnableJoinUserData(query))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user