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,14 +169,10 @@ namespace MediaBrowser.Controller.Entities.Audio
list.Add("Artist-" + (item.Name ?? string.Empty).RemoveDiacritics()); list.Add("Artist-" + (item.Name ?? string.Empty).RemoveDiacritics());
return list; return list;
} }
public override string CreatePresentationUniqueKey()
public override string PresentationUniqueKey
{
get
{ {
return "Artist-" + (Name ?? string.Empty).RemoveDiacritics(); return "Artist-" + (Name ?? string.Empty).RemoveDiacritics();
} }
}
protected override bool GetBlockUnratedValue(UserPolicy config) protected override bool GetBlockUnratedValue(UserPolicy config)
{ {
return config.BlockUnratedItems.Contains(UnratedItem.Music); return config.BlockUnratedItems.Contains(UnratedItem.Music);

View File

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

View File

@ -1194,10 +1194,17 @@ namespace MediaBrowser.Controller.Entities
get { return null; } get { return null; }
} }
[IgnoreDataMember] public virtual string CreatePresentationUniqueKey()
public virtual string PresentationUniqueKey
{ {
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() public virtual bool RequiresRefresh()

View File

@ -16,13 +16,10 @@ namespace MediaBrowser.Controller.Entities
return list; return list;
} }
public override string PresentationUniqueKey public override string CreatePresentationUniqueKey()
{
get
{ {
return GetUserDataKeys()[0]; return GetUserDataKeys()[0];
} }
}
/// <summary> /// <summary>
/// Returns the folder containing the item. /// Returns the folder containing the item.

View File

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

View File

@ -53,5 +53,11 @@ namespace MediaBrowser.Controller.Entities
bool RequiresRefresh(); bool RequiresRefresh();
bool EnableForceSaveOnDateModifiedChange { get; } bool EnableForceSaveOnDateModifiedChange { get; }
string PresentationUniqueKey { get; set; }
string GetPresentationUniqueKey();
string CreatePresentationUniqueKey();
} }
} }

View File

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

View File

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

View File

@ -114,10 +114,7 @@ namespace MediaBrowser.Controller.Entities.TV
} }
} }
[IgnoreDataMember] public override string CreatePresentationUniqueKey()
public override string PresentationUniqueKey
{
get
{ {
if (IndexNumber.HasValue) if (IndexNumber.HasValue)
{ {
@ -128,8 +125,7 @@ namespace MediaBrowser.Controller.Entities.TV
} }
} }
return base.PresentationUniqueKey; return base.CreatePresentationUniqueKey();
}
} }
/// <summary> /// <summary>

View File

@ -96,19 +96,29 @@ namespace MediaBrowser.Controller.Entities.TV
} }
} }
[IgnoreDataMember] public override string CreatePresentationUniqueKey()
public override string PresentationUniqueKey
{
get
{ {
var userdatakeys = GetUserDataKeys(); var userdatakeys = GetUserDataKeys();
if (userdatakeys.Count > 1) if (userdatakeys.Count > 1)
{ {
return userdatakeys[0]; return AddLibrariesToPresentationUniqueKey(userdatakeys[0]);
} }
return base.PresentationUniqueKey; 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) private static string GetUniqueSeriesKey(BaseItem series)
@ -117,7 +127,7 @@ namespace MediaBrowser.Controller.Entities.TV
{ {
return series.Id.ToString("N"); return series.Id.ToString("N");
} }
return series.PresentationUniqueKey; return series.GetPresentationUniqueKey();
} }
public override int GetChildCount(User user) public override int GetChildCount(User user)

View File

@ -1198,7 +1198,7 @@ namespace MediaBrowser.Controller.Entities
{ {
var user = query.User; 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) if (query.SortBy.Length > 0)
{ {

View File

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

View File

@ -284,6 +284,13 @@ namespace MediaBrowser.Providers.Manager
updateType |= SaveCumulativeRunTimeTicks(item, isFullRefresh, currentUpdateType); updateType |= SaveCumulativeRunTimeTicks(item, isFullRefresh, currentUpdateType);
updateType |= SaveDateLastMediaAdded(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; return updateType;
} }

View File

@ -35,27 +35,18 @@ namespace MediaBrowser.Providers.TV
updateType |= SaveIsVirtualItem(item, episodes); 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; return updateType;
} }

View File

@ -126,7 +126,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
var item = _libraryManager.GetPerson(person.Key); var item = _libraryManager.GetPerson(person.Key);
var hasMetdata = !string.IsNullOrWhiteSpace(item.Overview); 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 var defaultMetadataRefreshMode = performFullRefresh
? MetadataRefreshMode.FullRefresh ? MetadataRefreshMode.FullRefresh

View File

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

View File

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