Merge pull request #2017 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-08-04 00:42:17 -04:00 committed by GitHub
commit 8e3178ec0f
13 changed files with 21 additions and 154 deletions

View File

@ -1,11 +1,9 @@
using System;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Querying;
using System.Collections.Generic;
using System.Threading.Tasks;
using MediaBrowser.Controller.Sync;
using MediaBrowser.Model.Sync;
namespace MediaBrowser.Controller.Dto
{
@ -45,14 +43,6 @@ namespace MediaBrowser.Controller.Dto
/// <returns>Task{BaseItemDto}.</returns>
BaseItemDto GetBaseItemDto(BaseItem item, List<ItemFields> fields, User user = null, BaseItem owner = null);
/// <summary>
/// Fills the synchronize information.
/// </summary>
/// <param name="tuples">The tuples.</param>
/// <param name="options">The options.</param>
/// <param name="user">The user.</param>
void FillSyncInfo(IEnumerable<Tuple<BaseItem, BaseItemDto>> tuples, DtoOptions options, User user);
/// <summary>
/// Gets the base item dto.
/// </summary>

View File

@ -11,11 +11,13 @@ namespace MediaBrowser.Controller.Entities
public int? MaxListOrder { get; set; }
public Guid AppearsInItemId { get; set; }
public string NameContains { get; set; }
public SourceType[] SourceTypes { get; set; }
public InternalPeopleQuery()
{
PersonTypes = new List<string>();
ExcludePersonTypes = new List<string>();
SourceTypes = new SourceType[] { };
}
}
}

View File

@ -474,12 +474,6 @@ namespace MediaBrowser.Controller.Library
/// <returns>List&lt;Person&gt;.</returns>
List<Person> GetPeopleItems(InternalPeopleQuery query);
/// <summary>
/// Gets all people names.
/// </summary>
/// <returns>List&lt;System.String&gt;.</returns>
List<PersonInfo> GetAllPeople();
/// <summary>
/// Updates the people.
/// </summary>

View File

@ -138,7 +138,7 @@ namespace MediaBrowser.Providers.Manager
}
}
var isFirstRefresh = GetLastRefreshDate(item) == default(DateTime);
var isFirstRefresh = item.DateLastRefreshed == default(DateTime);
var beforeSaveResult = await BeforeSave(itemOfType, isFirstRefresh || refreshOptions.ReplaceAllMetadata || refreshOptions.MetadataRefreshMode == MetadataRefreshMode.FullRefresh || requiresRefresh, updateType).ConfigureAwait(false);
updateType = updateType | beforeSaveResult;
@ -193,11 +193,6 @@ namespace MediaBrowser.Providers.Manager
lookupInfo.Year = result.ProductionYear;
}
private DateTime GetLastRefreshDate(IHasMetadata item)
{
return item.DateLastRefreshed;
}
protected async Task SaveItem(MetadataResult<TItemType> result, ItemUpdateType reason, CancellationToken cancellationToken)
{
if (result.Item.SupportsPeople && result.People != null)
@ -652,7 +647,6 @@ namespace MediaBrowser.Providers.Manager
}
else
{
refreshResult.Failures++;
Logger.Debug("{0} returned no metadata for {1}", providerName, logName);
}
}

View File

@ -2605,13 +2605,6 @@ namespace MediaBrowser.Server.Implementations.Library
return ItemRepository.GetPeopleNames(query);
}
public List<PersonInfo> GetAllPeople()
{
return GetPeople(new InternalPeopleQuery())
.DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
.ToList();
}
public Task UpdatePeople(BaseItem item, List<PersonInfo> people)
{
if (!item.SupportsPeople)

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
using System;
@ -43,16 +42,12 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
var numComplete = 0;
var count = items.Count;
var validIds = new List<Guid>();
foreach (var name in items)
{
try
{
var itemByName = _libraryManager.GetGameGenre(name);
validIds.Add(itemByName.Id);
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
@ -73,28 +68,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
progress.Report(percent);
}
var allIds = _libraryManager.GetItemIds(new InternalItemsQuery
{
IncludeItemTypes = new[] { typeof(GameGenre).Name }
});
var invalidIds = allIds
.Except(validIds)
.ToList();
foreach (var id in invalidIds)
{
cancellationToken.ThrowIfCancellationRequested();
var item = _libraryManager.GetItemById(id);
await _libraryManager.DeleteItem(item, new DeleteOptions
{
DeleteFileLocation = false
}).ConfigureAwait(false);
}
progress.Report(100);
}
}

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
@ -44,16 +43,12 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
var numComplete = 0;
var count = items.Count;
var validIds = new List<Guid>();
foreach (var name in items)
{
try
{
var itemByName = _libraryManager.GetGenre(name);
validIds.Add(itemByName.Id);
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
@ -74,28 +69,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
progress.Report(percent);
}
var allIds = _libraryManager.GetItemIds(new InternalItemsQuery
{
IncludeItemTypes = new[] { typeof(Genre).Name }
});
var invalidIds = allIds
.Except(validIds)
.ToList();
foreach (var id in invalidIds)
{
cancellationToken.ThrowIfCancellationRequested();
var item = _libraryManager.GetItemById(id);
await _libraryManager.DeleteItem(item, new DeleteOptions
{
DeleteFileLocation = false
}).ConfigureAwait(false);
}
progress.Report(100);
}
}

View File

@ -1,6 +1,4 @@
using System.Collections.Generic;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
using System;
@ -44,16 +42,12 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
var numComplete = 0;
var count = items.Count;
var validIds = new List<Guid>();
foreach (var name in items)
{
try
{
var itemByName = _libraryManager.GetMusicGenre(name);
validIds.Add(itemByName.Id);
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)
@ -74,28 +68,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
progress.Report(percent);
}
var allIds = _libraryManager.GetItemIds(new InternalItemsQuery
{
IncludeItemTypes = new[] { typeof(MusicGenre).Name }
});
var invalidIds = allIds
.Except(validIds)
.ToList();
foreach (var id in invalidIds)
{
cancellationToken.ThrowIfCancellationRequested();
var item = _libraryManager.GetItemById(id);
await _libraryManager.DeleteItem(item, new DeleteOptions
{
DeleteFileLocation = false
}).ConfigureAwait(false);
}
progress.Report(100);
}
}

View File

@ -89,7 +89,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
var peopleOptions = _config.Configuration.PeopleMetadataOptions;
var people = _libraryManager.GetAllPeople();
var people = _libraryManager.GetPeople(new InternalPeopleQuery());
var dict = new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
@ -112,8 +112,9 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
}
var numComplete = 0;
var validIds = new List<Guid>();
_logger.Debug("Will refresh {0} people", dict.Count);
foreach (var person in dict)
{
cancellationToken.ThrowIfCancellationRequested();
@ -122,10 +123,9 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
{
var item = _libraryManager.GetPerson(person.Key);
validIds.Add(item.Id);
var hasMetdata = !string.IsNullOrWhiteSpace(item.Overview);
var performFullRefresh = !hasMetdata && (DateTime.UtcNow - item.DateLastRefreshed).TotalDays >= 30;
var performFullRefresh = !hasMetdata && (DateTime.UtcNow - item.DateLastRefreshed).TotalDays >= 90;
performFullRefresh = false;
var defaultMetadataRefreshMode = performFullRefresh
? MetadataRefreshMode.FullRefresh
@ -160,31 +160,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
progress.Report(100 * percent);
}
var allIds = _libraryManager.GetItemIds(new InternalItemsQuery
{
IncludeItemTypes = new[] { typeof(Person).Name }
});
var invalidIds = allIds
.Except(validIds)
.ToList();
foreach (var id in invalidIds)
{
cancellationToken.ThrowIfCancellationRequested();
var item = _libraryManager.GetItemById(id);
if (item != null)
{
await _libraryManager.DeleteItem(item, new DeleteOptions
{
DeleteFileLocation = false
}).ConfigureAwait(false);
}
}
progress.Report(100);
_logger.Info("People validation complete");

View File

@ -42,16 +42,12 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
var numComplete = 0;
var count = items.Count;
var validIds = new List<Guid>();
foreach (var name in items)
{
try
{
var itemByName = _libraryManager.GetStudio(name);
validIds.Add(itemByName.Id);
await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException)

View File

@ -56,8 +56,8 @@
<Reference Include="Interfaces.IO">
<HintPath>..\packages\Interfaces.IO.1.0.0.5\lib\portable-net45+sl4+wp71+win8+wpa81\Interfaces.IO.dll</HintPath>
</Reference>
<Reference Include="MediaBrowser.Naming, Version=1.0.6046.41603, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MediaBrowser.Naming.1.0.0.54\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll</HintPath>
<Reference Include="MediaBrowser.Naming, Version=1.0.6059.24054, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MediaBrowser.Naming.1.0.0.55\lib\portable-net45+sl4+wp71+win8+wpa81\MediaBrowser.Naming.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MoreLinq">

View File

@ -3776,6 +3776,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
whereClauses.Add("Name like @NameContains");
cmd.Parameters.Add(cmd, "@NameContains", DbType.String).Value = "%" + query.NameContains + "%";
}
if (query.SourceTypes.Length == 1)
{
whereClauses.Add("(select sourcetype from typedbaseitems where guid=ItemId) = @SourceTypes");
cmd.Parameters.Add(cmd, "@SourceTypes", DbType.String).Value = query.SourceTypes[0].ToString();
}
return whereClauses;
}

View File

@ -4,7 +4,7 @@
<package id="Emby.XmlTv" version="1.0.0.55" targetFramework="net45" />
<package id="ini-parser" version="2.3.0" targetFramework="net45" />
<package id="Interfaces.IO" version="1.0.0.5" targetFramework="net45" />
<package id="MediaBrowser.Naming" version="1.0.0.54" targetFramework="net45" />
<package id="MediaBrowser.Naming" version="1.0.0.55" targetFramework="net45" />
<package id="Mono.Nat" version="1.2.24.0" targetFramework="net45" />
<package id="morelinq" version="1.4.0" targetFramework="net45" />
<package id="Patterns.Logging" version="1.0.0.2" targetFramework="net45" />