denormalize seriesid
This commit is contained in:
parent
2772d59559
commit
1fcbd3c6da
|
@ -117,7 +117,7 @@ namespace MediaBrowser.Api
|
||||||
config.EnableStandaloneMusicKeys = true;
|
config.EnableStandaloneMusicKeys = true;
|
||||||
config.EnableCaseSensitiveItemIds = true;
|
config.EnableCaseSensitiveItemIds = true;
|
||||||
//config.EnableFolderView = true;
|
//config.EnableFolderView = true;
|
||||||
config.SchemaVersion = 100;
|
config.SchemaVersion = 101;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Post(UpdateStartupConfiguration request)
|
public void Post(UpdateStartupConfiguration request)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using MediaBrowser.Controller.Providers;
|
using System;
|
||||||
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
@ -19,12 +20,18 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
[IgnoreDataMember]
|
[IgnoreDataMember]
|
||||||
public string SeriesName { get; set; }
|
public string SeriesName { get; set; }
|
||||||
|
public Guid? SeriesId { get; set; }
|
||||||
|
|
||||||
public string FindSeriesName()
|
public string FindSeriesName()
|
||||||
{
|
{
|
||||||
return SeriesName;
|
return SeriesName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Guid? FindSeriesId()
|
||||||
|
{
|
||||||
|
return SeriesId;
|
||||||
|
}
|
||||||
|
|
||||||
public override bool CanDownload()
|
public override bool CanDownload()
|
||||||
{
|
{
|
||||||
var locationType = LocationType;
|
var locationType = LocationType;
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Entities
|
namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
public interface IHasSeries
|
public interface IHasSeries
|
||||||
|
@ -8,7 +10,8 @@ namespace MediaBrowser.Controller.Entities
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The name of the series.</value>
|
/// <value>The name of the series.</value>
|
||||||
string SeriesName { get; set; }
|
string SeriesName { get; set; }
|
||||||
|
|
||||||
string FindSeriesName();
|
string FindSeriesName();
|
||||||
|
Guid? SeriesId { get; set; }
|
||||||
|
Guid? FindSeriesId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,6 +249,13 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||||
|
|
||||||
[IgnoreDataMember]
|
[IgnoreDataMember]
|
||||||
public Guid? SeasonId { get; set; }
|
public Guid? SeasonId { get; set; }
|
||||||
|
public Guid? SeriesId { get; set; }
|
||||||
|
|
||||||
|
public Guid? FindSeriesId()
|
||||||
|
{
|
||||||
|
var series = Series;
|
||||||
|
return series == null ? (Guid?)null : series.Id;
|
||||||
|
}
|
||||||
|
|
||||||
public override IEnumerable<Guid> GetAncestorIds()
|
public override IEnumerable<Guid> GetAncestorIds()
|
||||||
{
|
{
|
||||||
|
|
|
@ -237,12 +237,20 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||||
[IgnoreDataMember]
|
[IgnoreDataMember]
|
||||||
public string SeriesName { get; set; }
|
public string SeriesName { get; set; }
|
||||||
|
|
||||||
|
public Guid? SeriesId { get; set; }
|
||||||
|
|
||||||
public string FindSeriesName()
|
public string FindSeriesName()
|
||||||
{
|
{
|
||||||
var series = Series;
|
var series = Series;
|
||||||
return series == null ? SeriesName : series.Name;
|
return series == null ? SeriesName : series.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Guid? FindSeriesId()
|
||||||
|
{
|
||||||
|
var series = Series;
|
||||||
|
return series == null ? (Guid?)null : series.Id;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the lookup information.
|
/// Gets the lookup information.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -197,6 +197,8 @@
|
||||||
/// </summary>
|
/// </summary>
|
||||||
SeriesGenres,
|
SeriesGenres,
|
||||||
|
|
||||||
|
SeriesPrimaryImage,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The series studio
|
/// The series studio
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -430,7 +430,8 @@ namespace MediaBrowser.Providers.TV
|
||||||
ParentIndexNumber = seasonNumber,
|
ParentIndexNumber = seasonNumber,
|
||||||
Id = _libraryManager.GetNewItemId((series.Id + seasonNumber.ToString(_usCulture) + name), typeof(Episode)),
|
Id = _libraryManager.GetNewItemId((series.Id + seasonNumber.ToString(_usCulture) + name), typeof(Episode)),
|
||||||
IsVirtualItem = true,
|
IsVirtualItem = true,
|
||||||
SeasonId = season == null ? (Guid?)null : season.Id
|
SeasonId = season == null ? (Guid?)null : season.Id,
|
||||||
|
SeriesId = series.Id
|
||||||
};
|
};
|
||||||
|
|
||||||
episode.SetParent(season);
|
episode.SetParent(season);
|
||||||
|
|
|
@ -1316,6 +1316,12 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
|
|
||||||
dto.SeasonName = episode.SeasonName;
|
dto.SeasonName = episode.SeasonName;
|
||||||
|
|
||||||
|
var seriesId = episode.SeriesId;
|
||||||
|
if (seriesId.HasValue)
|
||||||
|
{
|
||||||
|
dto.SeriesId = seriesId.Value.ToString("N");
|
||||||
|
}
|
||||||
|
|
||||||
Series episodeSeries = null;
|
Series episodeSeries = null;
|
||||||
|
|
||||||
if (fields.Contains(ItemFields.SeriesGenres))
|
if (fields.Contains(ItemFields.SeriesGenres))
|
||||||
|
@ -1327,13 +1333,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
episodeSeries = episodeSeries ?? episode.Series;
|
if (fields.Contains(ItemFields.SeriesPrimaryImage))
|
||||||
if (episodeSeries != null)
|
|
||||||
{
|
|
||||||
dto.SeriesId = GetDtoId(episodeSeries);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.GetImageLimit(ImageType.Primary) > 0)
|
|
||||||
{
|
{
|
||||||
episodeSeries = episodeSeries ?? episode.Series;
|
episodeSeries = episodeSeries ?? episode.Series;
|
||||||
if (episodeSeries != null)
|
if (episodeSeries != null)
|
||||||
|
@ -1369,18 +1369,27 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||||
{
|
{
|
||||||
dto.SeriesName = season.SeriesName;
|
dto.SeriesName = season.SeriesName;
|
||||||
|
|
||||||
series = season.Series;
|
var seriesId = season.SeriesId;
|
||||||
|
if (seriesId.HasValue)
|
||||||
if (series != null)
|
|
||||||
{
|
{
|
||||||
dto.SeriesId = GetDtoId(series);
|
dto.SeriesId = seriesId.Value.ToString("N");
|
||||||
|
}
|
||||||
|
|
||||||
if (fields.Contains(ItemFields.SeriesStudio))
|
series = null;
|
||||||
|
|
||||||
|
if (fields.Contains(ItemFields.SeriesStudio))
|
||||||
|
{
|
||||||
|
series = series ?? season.Series;
|
||||||
|
if (series != null)
|
||||||
{
|
{
|
||||||
dto.SeriesStudio = series.Studios.FirstOrDefault();
|
dto.SeriesStudio = series.Studios.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (options.GetImageLimit(ImageType.Primary) > 0)
|
if (fields.Contains(ItemFields.SeriesPrimaryImage))
|
||||||
|
{
|
||||||
|
series = series ?? season.Series;
|
||||||
|
if (series != null)
|
||||||
{
|
{
|
||||||
dto.SeriesPrimaryImageTag = GetImageCacheTag(series, ImageType.Primary);
|
dto.SeriesPrimaryImageTag = GetImageCacheTag(series, ImageType.Primary);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,23 +30,32 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var season = parent as Season;
|
|
||||||
|
|
||||||
// Just in case the user decided to nest episodes.
|
|
||||||
// Not officially supported but in some cases we can handle it.
|
|
||||||
if (season == null)
|
|
||||||
{
|
|
||||||
season = parent.GetParents().OfType<Season>().FirstOrDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the parent is a Season or Series, then this is an Episode if the VideoResolver returns something
|
// If the parent is a Season or Series, then this is an Episode if the VideoResolver returns something
|
||||||
// Also handle flat tv folders
|
// Also handle flat tv folders
|
||||||
if (season != null || args.HasParent<Series>() || string.Equals(args.GetCollectionType(), CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(args.GetCollectionType(), CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
var episode = ResolveVideo<Episode>(args, false);
|
var episode = ResolveVideo<Episode>(args, false);
|
||||||
|
|
||||||
if (episode != null)
|
if (episode != null)
|
||||||
{
|
{
|
||||||
|
var season = parent as Season;
|
||||||
|
// Just in case the user decided to nest episodes.
|
||||||
|
// Not officially supported but in some cases we can handle it.
|
||||||
|
if (season == null)
|
||||||
|
{
|
||||||
|
season = parent.GetParents().OfType<Season>().FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
var series = parent as Series;
|
||||||
|
if (series == null)
|
||||||
|
{
|
||||||
|
series = parent.GetParents().OfType<Series>().FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (series != null)
|
||||||
|
{
|
||||||
|
episode.SeriesId = series.Id;
|
||||||
|
}
|
||||||
if (season != null)
|
if (season != null)
|
||||||
{
|
{
|
||||||
episode.SeasonId = season.Id;
|
episode.SeasonId = season.Id;
|
||||||
|
|
|
@ -95,7 +95,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
private IDbCommand _updateInheritedRatingCommand;
|
private IDbCommand _updateInheritedRatingCommand;
|
||||||
private IDbCommand _updateInheritedTagsCommand;
|
private IDbCommand _updateInheritedTagsCommand;
|
||||||
|
|
||||||
public const int LatestSchemaVersion = 100;
|
public const int LatestSchemaVersion = 101;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="SqliteItemRepository"/> class.
|
/// Initializes a new instance of the <see cref="SqliteItemRepository"/> class.
|
||||||
|
@ -273,6 +273,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
_connection.AddColumn(Logger, "TypedBaseItems", "UserDataKey", "Text");
|
_connection.AddColumn(Logger, "TypedBaseItems", "UserDataKey", "Text");
|
||||||
_connection.AddColumn(Logger, "TypedBaseItems", "SeasonName", "Text");
|
_connection.AddColumn(Logger, "TypedBaseItems", "SeasonName", "Text");
|
||||||
_connection.AddColumn(Logger, "TypedBaseItems", "SeasonId", "GUID");
|
_connection.AddColumn(Logger, "TypedBaseItems", "SeasonId", "GUID");
|
||||||
|
_connection.AddColumn(Logger, "TypedBaseItems", "SeriesId", "GUID");
|
||||||
|
|
||||||
_connection.AddColumn(Logger, "UserDataKeys", "Priority", "INT");
|
_connection.AddColumn(Logger, "UserDataKeys", "Priority", "INT");
|
||||||
_connection.AddColumn(Logger, "ItemValues", "CleanValue", "Text");
|
_connection.AddColumn(Logger, "ItemValues", "CleanValue", "Text");
|
||||||
|
@ -407,7 +408,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
"IsVirtualItem",
|
"IsVirtualItem",
|
||||||
"SeriesName",
|
"SeriesName",
|
||||||
"SeasonName",
|
"SeasonName",
|
||||||
"SeasonId"
|
"SeasonId",
|
||||||
|
"SeriesId"
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly string[] _mediaStreamSaveColumns =
|
private readonly string[] _mediaStreamSaveColumns =
|
||||||
|
@ -529,7 +531,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
"SeriesName",
|
"SeriesName",
|
||||||
"UserDataKey",
|
"UserDataKey",
|
||||||
"SeasonName",
|
"SeasonName",
|
||||||
"SeasonId"
|
"SeasonId",
|
||||||
|
"SeriesId"
|
||||||
};
|
};
|
||||||
_saveItemCommand = _connection.CreateCommand();
|
_saveItemCommand = _connection.CreateCommand();
|
||||||
_saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (";
|
_saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (";
|
||||||
|
@ -972,6 +975,15 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
_saveItemCommand.GetParameter(index++).Value = null;
|
_saveItemCommand.GetParameter(index++).Value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasSeries != null)
|
||||||
|
{
|
||||||
|
_saveItemCommand.GetParameter(index++).Value = hasSeries.FindSeriesId();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_saveItemCommand.GetParameter(index++).Value = null;
|
||||||
|
}
|
||||||
|
|
||||||
_saveItemCommand.Transaction = transaction;
|
_saveItemCommand.Transaction = transaction;
|
||||||
|
|
||||||
_saveItemCommand.ExecuteNonQuery();
|
_saveItemCommand.ExecuteNonQuery();
|
||||||
|
@ -1416,6 +1428,14 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasSeries != null)
|
||||||
|
{
|
||||||
|
if (!reader.IsDBNull(62))
|
||||||
|
{
|
||||||
|
hasSeries.SeriesId = reader.GetGuid(62);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user