Merge pull request #2332 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-12-06 13:05:16 -05:00 committed by GitHub
commit dd4839a175
16 changed files with 133 additions and 27 deletions

View File

@ -291,6 +291,7 @@ namespace Emby.Server.Implementations.Data
AddColumn(db, "TypedBaseItems", "Artists", "Text", existingColumnNames);
AddColumn(db, "TypedBaseItems", "AlbumArtists", "Text", existingColumnNames);
AddColumn(db, "TypedBaseItems", "ExternalId", "Text", existingColumnNames);
AddColumn(db, "TypedBaseItems", "SeriesPresentationUniqueKey", "Text", existingColumnNames);
existingColumnNames = GetColumnNames(db, "ItemValues");
AddColumn(db, "ItemValues", "CleanValue", "Text", existingColumnNames);
@ -341,6 +342,7 @@ namespace Emby.Server.Implementations.Data
"drop index if exists Idx_ProviderIds1",
"drop table if exists Images",
"drop index if exists idx_Images",
"drop index if exists idx_TypeSeriesPresentationUniqueKey",
"create index if not exists idx_PathTypedBaseItems on TypedBaseItems(Path)",
"create index if not exists idx_ParentIdTypedBaseItems on TypedBaseItems(ParentId)",
@ -353,6 +355,9 @@ namespace Emby.Server.Implementations.Data
// covering index
"create index if not exists idx_TopParentIdGuid on TypedBaseItems(TopParentId,Guid)",
// series
"create index if not exists idx_TypeSeriesPresentationUniqueKey1 on TypedBaseItems(Type,SeriesPresentationUniqueKey,PresentationUniqueKey,SortName)",
// live tv programs
"create index if not exists idx_TypeTopParentIdStartDate on TypedBaseItems(Type,TopParentId,StartDate)",
@ -488,7 +493,8 @@ namespace Emby.Server.Implementations.Data
"ExtraType",
"Artists",
"AlbumArtists",
"ExternalId"
"ExternalId",
"SeriesPresentationUniqueKey"
};
private readonly string[] _mediaStreamSaveColumns =
@ -619,7 +625,8 @@ namespace Emby.Server.Implementations.Data
"ExtraType",
"Artists",
"AlbumArtists",
"ExternalId"
"ExternalId",
"SeriesPresentationUniqueKey"
};
var saveItemCommandCommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (";
@ -1024,11 +1031,13 @@ namespace Emby.Server.Implementations.Data
{
saveItemStatement.TryBind("@SeriesId", hasSeries.SeriesId);
saveItemStatement.TryBind("@SeriesSortName", hasSeries.SeriesSortName);
saveItemStatement.TryBind("@SeriesPresentationUniqueKey", hasSeries.SeriesPresentationUniqueKey);
}
else
{
saveItemStatement.TryBindNull("@SeriesId");
saveItemStatement.TryBindNull("@SeriesSortName");
saveItemStatement.TryBindNull("@SeriesPresentationUniqueKey");
}
saveItemStatement.TryBind("@ExternalSeriesId", item.ExternalSeriesId);
@ -1983,6 +1992,15 @@ namespace Emby.Server.Implementations.Data
}
index++;
if (hasSeries != null)
{
if (!reader.IsDBNull(index))
{
hasSeries.SeriesPresentationUniqueKey = reader.GetString(index);
}
}
index++;
if (string.IsNullOrWhiteSpace(item.Tagline))
{
var movie = item as Movie;
@ -4292,6 +4310,16 @@ namespace Emby.Server.Implementations.Data
}
}
if (!string.IsNullOrWhiteSpace(query.SeriesPresentationUniqueKey))
{
whereClauses.Add("SeriesPresentationUniqueKey=@SeriesPresentationUniqueKey");
if (statement != null)
{
statement.TryBind("@SeriesPresentationUniqueKey", query.SeriesPresentationUniqueKey);
}
}
if (query.BlockUnratedItems.Length == 1)
{
whereClauses.Add("(InheritedParentalRatingValue > 0 or UnratedType <> @UnratedType)");

View File

@ -1057,6 +1057,12 @@ namespace Emby.Server.Implementations.Library
try
{
await PerformLibraryValidation(progress, cancellationToken).ConfigureAwait(false);
if (!ConfigurationManager.Configuration.EnableSeriesPresentationUniqueKey)
{
ConfigurationManager.Configuration.EnableSeriesPresentationUniqueKey = true;
ConfigurationManager.SaveConfiguration();
}
}
finally
{
@ -1478,8 +1484,9 @@ namespace Emby.Server.Implementations.Library
!query.ParentId.HasValue &&
query.ChannelIds.Length == 0 &&
query.TopParentIds.Length == 0 &&
string.IsNullOrWhiteSpace(query.AncestorWithPresentationUniqueKey)
&& query.ItemIds.Length == 0)
string.IsNullOrWhiteSpace(query.AncestorWithPresentationUniqueKey) &&
string.IsNullOrWhiteSpace(query.SeriesPresentationUniqueKey) &&
query.ItemIds.Length == 0)
{
var userViews = _userviewManager().GetUserViews(new UserViewQuery
{

View File

@ -158,9 +158,13 @@ namespace Emby.Server.Implementations.TV
/// <returns>Task{Episode}.</returns>
private Tuple<DateTime, Func<Episode>> GetNextUp(Series series, User user)
{
var enableSeriesPresentationKey = _config.Configuration.EnableSeriesPresentationUniqueKey;
var seriesKey = GetUniqueSeriesKey(series);
var lastWatchedEpisode = _libraryManager.GetItemList(new InternalItemsQuery(user)
{
AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(series),
AncestorWithPresentationUniqueKey = enableSeriesPresentationKey ? null : seriesKey,
SeriesPresentationUniqueKey = enableSeriesPresentationKey ? seriesKey : null,
IncludeItemTypes = new[] { typeof(Episode).Name },
SortBy = new[] { ItemSortBy.SortName },
SortOrder = SortOrder.Descending,
@ -174,7 +178,8 @@ namespace Emby.Server.Implementations.TV
{
return _libraryManager.GetItemList(new InternalItemsQuery(user)
{
AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(series),
AncestorWithPresentationUniqueKey = enableSeriesPresentationKey ? null : seriesKey,
SeriesPresentationUniqueKey = enableSeriesPresentationKey ? seriesKey : null,
IncludeItemTypes = new[] { typeof(Episode).Name },
SortBy = new[] { ItemSortBy.SortName },
SortOrder = SortOrder.Ascending,

View File

@ -119,6 +119,7 @@ namespace MediaBrowser.Api
config.SkipDeserializationForBasicTypes = true;
config.SkipDeserializationForPrograms = true;
config.SkipDeserializationForAudio = true;
config.EnableSeriesPresentationUniqueKey = true;
}
public void Post(UpdateStartupConfiguration request)

View File

@ -18,6 +18,8 @@ namespace MediaBrowser.Controller.Entities
}
}
[IgnoreDataMember]
public string SeriesPresentationUniqueKey { get; set; }
[IgnoreDataMember]
public string SeriesName { get; set; }
[IgnoreDataMember]
@ -33,6 +35,10 @@ namespace MediaBrowser.Controller.Entities
{
return SeriesName;
}
public string FindSeriesPresentationUniqueKey()
{
return SeriesPresentationUniqueKey;
}
[IgnoreDataMember]
public override bool EnableRefreshOnDateModifiedChange

View File

@ -15,5 +15,7 @@ namespace MediaBrowser.Controller.Entities
string FindSeriesSortName();
Guid? SeriesId { get; set; }
Guid? FindSeriesId();
string SeriesPresentationUniqueKey { get; set; }
string FindSeriesPresentationUniqueKey();
}
}

View File

@ -147,6 +147,7 @@ namespace MediaBrowser.Controller.Entities
public string[] ArtistNames { get; set; }
public string[] ExcludeArtistIds { get; set; }
public string AncestorWithPresentationUniqueKey { get; set; }
public string SeriesPresentationUniqueKey { get; set; }
public bool GroupByPresentationUniqueKey { get; set; }
public bool EnableTotalRecordCount { get; set; }

View File

@ -165,13 +165,22 @@ namespace MediaBrowser.Controller.Entities.TV
{
return FindParent<Season>() != null;
}
}
}
[IgnoreDataMember]
public string SeriesPresentationUniqueKey { get; set; }
[IgnoreDataMember]
public string SeriesName { get; set; }
[IgnoreDataMember]
public string SeasonName { get; set; }
public string SeasonName { get; set; }
public string FindSeriesPresentationUniqueKey()
{
var series = Series;
return series == null ? null : series.PresentationUniqueKey;
}
public string FindSeasonName()
{

View File

@ -207,12 +207,21 @@ namespace MediaBrowser.Controller.Entities.TV
return UnratedItem.Series;
}
[IgnoreDataMember]
public string SeriesPresentationUniqueKey { get; set; }
[IgnoreDataMember]
public string SeriesName { get; set; }
[IgnoreDataMember]
public Guid? SeriesId { get; set; }
public string FindSeriesPresentationUniqueKey()
{
var series = Series;
return series == null ? null : series.PresentationUniqueKey;
}
public string FindSeriesName()
{
var series = Series;

View File

@ -95,12 +95,16 @@ namespace MediaBrowser.Controller.Entities.TV
public override string CreatePresentationUniqueKey()
{
var userdatakeys = GetUserDataKeys();
if (userdatakeys.Count > 1)
if (LibraryManager.GetLibraryOptions(this).EnableAutomaticSeriesGrouping)
{
return AddLibrariesToPresentationUniqueKey(userdatakeys[0]);
var userdatakeys = GetUserDataKeys();
if (userdatakeys.Count > 1)
{
return AddLibrariesToPresentationUniqueKey(userdatakeys[0]);
}
}
return base.CreatePresentationUniqueKey();
}
@ -131,9 +135,13 @@ namespace MediaBrowser.Controller.Entities.TV
public override int GetChildCount(User user)
{
var enableSeriesPresentationKey = ConfigurationManager.Configuration.EnableSeriesPresentationUniqueKey;
var seriesKey = GetUniqueSeriesKey(this);
var result = LibraryManager.GetItemsResult(new InternalItemsQuery(user)
{
AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(this),
AncestorWithPresentationUniqueKey = enableSeriesPresentationKey ? null : seriesKey,
SeriesPresentationUniqueKey = enableSeriesPresentationKey ? seriesKey : null,
IncludeItemTypes = new[] { typeof(Season).Name },
IsVirtualItem = false,
Limit = 0
@ -144,9 +152,15 @@ namespace MediaBrowser.Controller.Entities.TV
public override int GetRecursiveChildCount(User user)
{
var query = new InternalItemsQuery(user);
var enableSeriesPresentationKey = ConfigurationManager.Configuration.EnableSeriesPresentationUniqueKey;
var seriesKey = GetUniqueSeriesKey(this);
var query = new InternalItemsQuery(user)
{
AncestorWithPresentationUniqueKey = enableSeriesPresentationKey ? null : seriesKey,
SeriesPresentationUniqueKey = enableSeriesPresentationKey ? seriesKey : null,
};
query.AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(this);
if (query.SortBy.Length == 0)
{
query.SortBy = new[] { ItemSortBy.SortName };
@ -223,11 +237,13 @@ namespace MediaBrowser.Controller.Entities.TV
{
var config = user.Configuration;
var enableSeriesPresentationKey = ConfigurationManager.Configuration.EnableSeriesPresentationUniqueKey;
var seriesKey = GetUniqueSeriesKey(this);
var query = new InternalItemsQuery(user)
{
AncestorWithPresentationUniqueKey = seriesKey,
AncestorWithPresentationUniqueKey = enableSeriesPresentationKey ? null : seriesKey,
SeriesPresentationUniqueKey = enableSeriesPresentationKey ? seriesKey : null,
IncludeItemTypes = new[] { typeof(Season).Name },
SortBy = new[] { ItemSortBy.SortName }
};
@ -259,7 +275,11 @@ namespace MediaBrowser.Controller.Entities.TV
if (query.Recursive)
{
query.AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(this);
var enableSeriesPresentationKey = ConfigurationManager.Configuration.EnableSeriesPresentationUniqueKey;
var seriesKey = GetUniqueSeriesKey(this);
query.AncestorWithPresentationUniqueKey = enableSeriesPresentationKey ? null : seriesKey;
query.SeriesPresentationUniqueKey = enableSeriesPresentationKey ? seriesKey : null;
if (query.SortBy.Length == 0)
{
query.SortBy = new[] { ItemSortBy.SortName };
@ -281,11 +301,13 @@ namespace MediaBrowser.Controller.Entities.TV
public IEnumerable<Episode> GetEpisodes(User user)
{
var enableSeriesPresentationKey = ConfigurationManager.Configuration.EnableSeriesPresentationUniqueKey;
var seriesKey = GetUniqueSeriesKey(this);
var query = new InternalItemsQuery(user)
{
AncestorWithPresentationUniqueKey = seriesKey,
AncestorWithPresentationUniqueKey = enableSeriesPresentationKey ? null : seriesKey,
SeriesPresentationUniqueKey = enableSeriesPresentationKey ? seriesKey : null,
IncludeItemTypes = new[] { typeof(Episode).Name, typeof(Season).Name },
SortBy = new[] { ItemSortBy.SortName }
};
@ -387,14 +409,19 @@ namespace MediaBrowser.Controller.Entities.TV
public IEnumerable<Episode> GetSeasonEpisodes(Season parentSeason, User user)
{
var enableSeriesPresentationKey = ConfigurationManager.Configuration.EnableSeriesPresentationUniqueKey;
var queryFromSeries = ConfigurationManager.Configuration.DisplaySpecialsWithinSeasons;
// add optimization when this setting is not enabled
var seriesKey = ConfigurationManager.Configuration.DisplaySpecialsWithinSeasons ?
var seriesKey = queryFromSeries ?
GetUniqueSeriesKey(this) :
GetUniqueSeriesKey(parentSeason);
var query = new InternalItemsQuery(user)
{
AncestorWithPresentationUniqueKey = seriesKey,
AncestorWithPresentationUniqueKey = queryFromSeries && enableSeriesPresentationKey ? null : seriesKey,
SeriesPresentationUniqueKey = queryFromSeries && enableSeriesPresentationKey ? seriesKey : null,
IncludeItemTypes = new[] { typeof(Episode).Name },
SortBy = new[] { ItemSortBy.SortName }
};

View File

@ -14,6 +14,7 @@
public bool SaveLocalMetadata { get; set; }
public bool EnableInternetProviders { get; set; }
public bool ImportMissingEpisodes { get; set; }
public bool EnableAutomaticSeriesGrouping { get; set; }
public LibraryOptions()
{
@ -21,6 +22,7 @@
EnableRealtimeMonitor = true;
PathInfos = new MediaPathInfo[] { };
EnableInternetProviders = true;
EnableAutomaticSeriesGrouping = true;
}
}

View File

@ -46,6 +46,7 @@ namespace MediaBrowser.Model.Configuration
/// </summary>
/// <value><c>true</c> if [use HTTPS]; otherwise, <c>false</c>.</value>
public bool EnableHttps { get; set; }
public bool EnableSeriesPresentationUniqueKey { get; set; }
/// <summary>
/// Gets or sets the value pointing to the file system where the ssl certiifcate is located..

View File

@ -55,6 +55,13 @@ namespace MediaBrowser.Providers.TV
updateType |= ItemUpdateType.MetadataImport;
}
var seriesPresentationUniqueKey = item.FindSeriesPresentationUniqueKey();
if (!string.Equals(item.SeriesPresentationUniqueKey, seriesPresentationUniqueKey, StringComparison.Ordinal))
{
item.SeriesPresentationUniqueKey = seriesPresentationUniqueKey;
updateType |= ItemUpdateType.MetadataImport;
}
return updateType;
}

View File

@ -51,6 +51,13 @@ namespace MediaBrowser.Providers.TV
updateType |= ItemUpdateType.MetadataImport;
}
var seriesPresentationUniqueKey = item.FindSeriesPresentationUniqueKey();
if (!string.Equals(item.SeriesPresentationUniqueKey, seriesPresentationUniqueKey, StringComparison.Ordinal))
{
item.SeriesPresentationUniqueKey = seriesPresentationUniqueKey;
updateType |= ItemUpdateType.MetadataImport;
}
var seriesId = item.FindSeriesId();
if (item.SeriesId != seriesId)
{

View File

@ -693,9 +693,6 @@
<Content Include="dashboard-ui\files\dummy.mp4">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\librarypathmapping.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\metadatanfo.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@ -876,9 +873,6 @@
<Content Include="dashboard-ui\scripts\librarymenu.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\scripts\librarypathmapping.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\scripts\metadatanfo.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

View File

@ -35,7 +35,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
list.Add(Path.Combine(path, "VIDEO_TS", "VIDEO_TS.nfo"));
}
if (item.VideoType == VideoType.Dvd || item.VideoType == VideoType.BluRay || item.VideoType == VideoType.HdDvd)
if (!item.IsPlaceHolder && (item.VideoType == VideoType.Dvd || item.VideoType == VideoType.BluRay || item.VideoType == VideoType.HdDvd))
{
var path = item.ContainingFolderPath;