Merge pull request #2048 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-08-12 15:32:26 -04:00 committed by GitHub
commit 1802943f6b
17 changed files with 87 additions and 90 deletions

View File

@ -169,13 +169,9 @@ namespace MediaBrowser.Controller.Entities.Audio
list.Add("Artist-" + (item.Name ?? string.Empty).RemoveDiacritics());
return list;
}
public override string PresentationUniqueKey
public override string CreatePresentationUniqueKey()
{
get
{
return "Artist-" + (Name ?? string.Empty).RemoveDiacritics();
}
return "Artist-" + (Name ?? string.Empty).RemoveDiacritics();
}
protected override bool GetBlockUnratedValue(UserPolicy config)
{

View File

@ -18,13 +18,9 @@ namespace MediaBrowser.Controller.Entities.Audio
list.Insert(0, GetType().Name + "-" + (Name ?? string.Empty).RemoveDiacritics());
return list;
}
public override string PresentationUniqueKey
public override string CreatePresentationUniqueKey()
{
get
{
return GetUserDataKeys()[0];
}
return GetUserDataKeys()[0];
}
[IgnoreDataMember]

View File

@ -1194,10 +1194,17 @@ namespace MediaBrowser.Controller.Entities
get { return null; }
}
[IgnoreDataMember]
public virtual string PresentationUniqueKey
public virtual string CreatePresentationUniqueKey()
{
get { return Id.ToString("N"); }
return Id.ToString("N");
}
[IgnoreDataMember]
public string PresentationUniqueKey { get; set; }
public string GetPresentationUniqueKey()
{
return PresentationUniqueKey ?? CreatePresentationUniqueKey();
}
public virtual bool RequiresRefresh()

View File

@ -16,12 +16,9 @@ namespace MediaBrowser.Controller.Entities
return list;
}
public override string PresentationUniqueKey
public override string CreatePresentationUniqueKey()
{
get
{
return GetUserDataKeys()[0];
}
return GetUserDataKeys()[0];
}
/// <summary>

View File

@ -19,13 +19,9 @@ namespace MediaBrowser.Controller.Entities
list.Insert(0, GetType().Name + "-" + (Name ?? string.Empty).RemoveDiacritics());
return list;
}
public override string PresentationUniqueKey
public override string CreatePresentationUniqueKey()
{
get
{
return GetUserDataKeys()[0];
}
return GetUserDataKeys()[0];
}
/// <summary>

View File

@ -32,7 +32,7 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
/// <value>The date last refreshed.</value>
DateTime DateLastRefreshed { get; set; }
/// <summary>
/// This is called before any metadata refresh and returns true or false indicating if changes were made
/// </summary>
@ -53,5 +53,11 @@ namespace MediaBrowser.Controller.Entities
bool RequiresRefresh();
bool EnableForceSaveOnDateModifiedChange { get; }
string PresentationUniqueKey { get; set; }
string GetPresentationUniqueKey();
string CreatePresentationUniqueKey();
}
}

View File

@ -26,13 +26,9 @@ namespace MediaBrowser.Controller.Entities
list.Insert(0, GetType().Name + "-" + (Name ?? string.Empty).RemoveDiacritics());
return list;
}
public override string PresentationUniqueKey
public override string CreatePresentationUniqueKey()
{
get
{
return GetUserDataKeys()[0];
}
return GetUserDataKeys()[0];
}
public PersonLookupInfo GetLookupInfo()

View File

@ -18,13 +18,9 @@ namespace MediaBrowser.Controller.Entities
list.Insert(0, GetType().Name + "-" + (Name ?? string.Empty).RemoveDiacritics());
return list;
}
public override string PresentationUniqueKey
public override string CreatePresentationUniqueKey()
{
get
{
return GetUserDataKeys()[0];
}
return GetUserDataKeys()[0];
}
/// <summary>

View File

@ -114,22 +114,18 @@ namespace MediaBrowser.Controller.Entities.TV
}
}
[IgnoreDataMember]
public override string PresentationUniqueKey
public override string CreatePresentationUniqueKey()
{
get
if (IndexNumber.HasValue)
{
if (IndexNumber.HasValue)
var series = Series;
if (series != null)
{
var series = Series;
if (series != null)
{
return series.PresentationUniqueKey + "-" + (IndexNumber ?? 0).ToString("000");
}
return series.PresentationUniqueKey + "-" + (IndexNumber ?? 0).ToString("000");
}
return base.PresentationUniqueKey;
}
return base.CreatePresentationUniqueKey();
}
/// <summary>

View File

@ -96,19 +96,29 @@ namespace MediaBrowser.Controller.Entities.TV
}
}
[IgnoreDataMember]
public override string PresentationUniqueKey
public override string CreatePresentationUniqueKey()
{
get
{
var userdatakeys = GetUserDataKeys();
var userdatakeys = GetUserDataKeys();
if (userdatakeys.Count > 1)
{
return userdatakeys[0];
}
return base.PresentationUniqueKey;
if (userdatakeys.Count > 1)
{
return AddLibrariesToPresentationUniqueKey(userdatakeys[0]);
}
return base.CreatePresentationUniqueKey();
}
private string AddLibrariesToPresentationUniqueKey(string key)
{
var folders = LibraryManager.GetCollectionFolders(this)
.Select(i => i.Id.ToString("N"))
.ToArray();
if (folders.Length == 0)
{
return key;
}
return key + "-" + string.Join("-", folders);
}
private static string GetUniqueSeriesKey(BaseItem series)
@ -117,7 +127,7 @@ namespace MediaBrowser.Controller.Entities.TV
{
return series.Id.ToString("N");
}
return series.PresentationUniqueKey;
return series.GetPresentationUniqueKey();
}
public override int GetChildCount(User user)

View File

@ -1198,7 +1198,7 @@ namespace MediaBrowser.Controller.Entities
{
var user = query.User;
items = items.DistinctBy(i => i.PresentationUniqueKey, StringComparer.OrdinalIgnoreCase);
items = items.DistinctBy(i => i.GetPresentationUniqueKey(), StringComparer.OrdinalIgnoreCase);
if (query.SortBy.Length > 0)
{

View File

@ -44,18 +44,14 @@ namespace MediaBrowser.Controller.Entities
}
}
[IgnoreDataMember]
public override string PresentationUniqueKey
public override string CreatePresentationUniqueKey()
{
get
if (!string.IsNullOrWhiteSpace(PrimaryVersionId))
{
if (!string.IsNullOrWhiteSpace(PrimaryVersionId))
{
return PrimaryVersionId;
}
return base.PresentationUniqueKey;
return PrimaryVersionId;
}
return base.CreatePresentationUniqueKey();
}
[IgnoreDataMember]

View File

@ -284,6 +284,13 @@ namespace MediaBrowser.Providers.Manager
updateType |= SaveCumulativeRunTimeTicks(item, isFullRefresh, currentUpdateType);
updateType |= SaveDateLastMediaAdded(item, isFullRefresh, currentUpdateType);
var presentationUniqueKey = item.CreatePresentationUniqueKey();
if (!string.Equals(item.PresentationUniqueKey, presentationUniqueKey, StringComparison.Ordinal))
{
item.PresentationUniqueKey = presentationUniqueKey;
updateType |= ItemUpdateType.MetadataImport;
}
return updateType;
}

View File

@ -35,26 +35,17 @@ namespace MediaBrowser.Providers.TV
updateType |= SaveIsVirtualItem(item, episodes);
}
if (updateType <= ItemUpdateType.None)
if (!string.Equals(item.SeriesName, item.FindSeriesName(), StringComparison.Ordinal))
{
if (!string.Equals(item.SeriesName, item.FindSeriesName(), StringComparison.Ordinal))
{
updateType |= ItemUpdateType.MetadataImport;
}
updateType |= ItemUpdateType.MetadataImport;
}
if (updateType <= ItemUpdateType.None)
if (!string.Equals(item.SeriesSortName, item.FindSeriesSortName(), StringComparison.Ordinal))
{
if (!string.Equals(item.SeriesSortName, item.FindSeriesSortName(), StringComparison.Ordinal))
{
updateType |= ItemUpdateType.MetadataImport;
}
updateType |= ItemUpdateType.MetadataImport;
}
if (updateType <= ItemUpdateType.None)
if (item.SeriesId != item.FindSeriesId())
{
if (item.SeriesId != item.FindSeriesId())
{
updateType |= ItemUpdateType.MetadataImport;
}
updateType |= ItemUpdateType.MetadataImport;
}
return updateType;

View File

@ -126,7 +126,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
var item = _libraryManager.GetPerson(person.Key);
var hasMetdata = !string.IsNullOrWhiteSpace(item.Overview);
var performFullRefresh = !hasMetdata && (DateTime.UtcNow - item.DateLastRefreshed).TotalDays >= 60;
var performFullRefresh = !hasMetdata && (DateTime.UtcNow - item.DateLastRefreshed).TotalDays >= 30;
var defaultMetadataRefreshMode = performFullRefresh
? MetadataRefreshMode.FullRefresh

View File

@ -412,7 +412,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
"SeasonName",
"SeasonId",
"SeriesId",
"SeriesSortName"
"SeriesSortName",
"PresentationUniqueKey"
};
private readonly string[] _mediaStreamSaveColumns =
@ -918,7 +919,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
_saveItemCommand.GetParameter(index++).Value = GetCleanValue(item.Name);
}
_saveItemCommand.GetParameter(index++).Value = item.PresentationUniqueKey;
_saveItemCommand.GetParameter(index++).Value = item.GetPresentationUniqueKey();
_saveItemCommand.GetParameter(index++).Value = item.SlugName;
_saveItemCommand.GetParameter(index++).Value = item.OriginalTitle;
@ -1454,6 +1455,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
}
index++;
if (!reader.IsDBNull(index))
{
item.PresentationUniqueKey = reader.GetString(index);
}
index++;
return item;
}

View File

@ -152,7 +152,7 @@ namespace MediaBrowser.Server.Implementations.TV
{
return series.Id.ToString("N");
}
return series.PresentationUniqueKey;
return series.GetPresentationUniqueKey();
}
/// <summary>