denormalize seriesid
This commit is contained in:
parent
2772d59559
commit
1fcbd3c6da
|
@ -117,7 +117,7 @@ namespace MediaBrowser.Api
|
|||
config.EnableStandaloneMusicKeys = true;
|
||||
config.EnableCaseSensitiveItemIds = true;
|
||||
//config.EnableFolderView = true;
|
||||
config.SchemaVersion = 100;
|
||||
config.SchemaVersion = 101;
|
||||
}
|
||||
|
||||
public void Post(UpdateStartupConfiguration request)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using MediaBrowser.Controller.Providers;
|
||||
using System;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
@ -19,12 +20,18 @@ namespace MediaBrowser.Controller.Entities
|
|||
|
||||
[IgnoreDataMember]
|
||||
public string SeriesName { get; set; }
|
||||
public Guid? SeriesId { get; set; }
|
||||
|
||||
public string FindSeriesName()
|
||||
{
|
||||
return SeriesName;
|
||||
}
|
||||
|
||||
public Guid? FindSeriesId()
|
||||
{
|
||||
return SeriesId;
|
||||
}
|
||||
|
||||
public override bool CanDownload()
|
||||
{
|
||||
var locationType = LocationType;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
public interface IHasSeries
|
||||
|
@ -8,7 +10,8 @@ namespace MediaBrowser.Controller.Entities
|
|||
/// </summary>
|
||||
/// <value>The name of the series.</value>
|
||||
string SeriesName { get; set; }
|
||||
|
||||
string FindSeriesName();
|
||||
Guid? SeriesId { get; set; }
|
||||
Guid? FindSeriesId();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -249,6 +249,13 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
|
||||
[IgnoreDataMember]
|
||||
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()
|
||||
{
|
||||
|
|
|
@ -237,12 +237,20 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
[IgnoreDataMember]
|
||||
public string SeriesName { get; set; }
|
||||
|
||||
public Guid? SeriesId { get; set; }
|
||||
|
||||
public string FindSeriesName()
|
||||
{
|
||||
var series = Series;
|
||||
return series == null ? SeriesName : series.Name;
|
||||
}
|
||||
|
||||
public Guid? FindSeriesId()
|
||||
{
|
||||
var series = Series;
|
||||
return series == null ? (Guid?)null : series.Id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the lookup information.
|
||||
/// </summary>
|
||||
|
|
|
@ -197,6 +197,8 @@
|
|||
/// </summary>
|
||||
SeriesGenres,
|
||||
|
||||
SeriesPrimaryImage,
|
||||
|
||||
/// <summary>
|
||||
/// The series studio
|
||||
/// </summary>
|
||||
|
|
|
@ -430,7 +430,8 @@ namespace MediaBrowser.Providers.TV
|
|||
ParentIndexNumber = seasonNumber,
|
||||
Id = _libraryManager.GetNewItemId((series.Id + seasonNumber.ToString(_usCulture) + name), typeof(Episode)),
|
||||
IsVirtualItem = true,
|
||||
SeasonId = season == null ? (Guid?)null : season.Id
|
||||
SeasonId = season == null ? (Guid?)null : season.Id,
|
||||
SeriesId = series.Id
|
||||
};
|
||||
|
||||
episode.SetParent(season);
|
||||
|
|
|
@ -1316,6 +1316,12 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||
|
||||
dto.SeasonName = episode.SeasonName;
|
||||
|
||||
var seriesId = episode.SeriesId;
|
||||
if (seriesId.HasValue)
|
||||
{
|
||||
dto.SeriesId = seriesId.Value.ToString("N");
|
||||
}
|
||||
|
||||
Series episodeSeries = null;
|
||||
|
||||
if (fields.Contains(ItemFields.SeriesGenres))
|
||||
|
@ -1327,13 +1333,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||
}
|
||||
}
|
||||
|
||||
episodeSeries = episodeSeries ?? episode.Series;
|
||||
if (episodeSeries != null)
|
||||
{
|
||||
dto.SeriesId = GetDtoId(episodeSeries);
|
||||
}
|
||||
|
||||
if (options.GetImageLimit(ImageType.Primary) > 0)
|
||||
if (fields.Contains(ItemFields.SeriesPrimaryImage))
|
||||
{
|
||||
episodeSeries = episodeSeries ?? episode.Series;
|
||||
if (episodeSeries != null)
|
||||
|
@ -1369,18 +1369,27 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||
{
|
||||
dto.SeriesName = season.SeriesName;
|
||||
|
||||
series = season.Series;
|
||||
|
||||
if (series != null)
|
||||
var seriesId = season.SeriesId;
|
||||
if (seriesId.HasValue)
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
if (options.GetImageLimit(ImageType.Primary) > 0)
|
||||
if (fields.Contains(ItemFields.SeriesPrimaryImage))
|
||||
{
|
||||
series = series ?? season.Series;
|
||||
if (series != null)
|
||||
{
|
||||
dto.SeriesPrimaryImageTag = GetImageCacheTag(series, ImageType.Primary);
|
||||
}
|
||||
|
|
|
@ -30,23 +30,32 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
|||
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
|
||||
// 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);
|
||||
|
||||
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)
|
||||
{
|
||||
episode.SeasonId = season.Id;
|
||||
|
|
|
@ -95,7 +95,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
private IDbCommand _updateInheritedRatingCommand;
|
||||
private IDbCommand _updateInheritedTagsCommand;
|
||||
|
||||
public const int LatestSchemaVersion = 100;
|
||||
public const int LatestSchemaVersion = 101;
|
||||
|
||||
/// <summary>
|
||||
/// 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", "SeasonName", "Text");
|
||||
_connection.AddColumn(Logger, "TypedBaseItems", "SeasonId", "GUID");
|
||||
_connection.AddColumn(Logger, "TypedBaseItems", "SeriesId", "GUID");
|
||||
|
||||
_connection.AddColumn(Logger, "UserDataKeys", "Priority", "INT");
|
||||
_connection.AddColumn(Logger, "ItemValues", "CleanValue", "Text");
|
||||
|
@ -407,7 +408,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
"IsVirtualItem",
|
||||
"SeriesName",
|
||||
"SeasonName",
|
||||
"SeasonId"
|
||||
"SeasonId",
|
||||
"SeriesId"
|
||||
};
|
||||
|
||||
private readonly string[] _mediaStreamSaveColumns =
|
||||
|
@ -529,7 +531,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
"SeriesName",
|
||||
"UserDataKey",
|
||||
"SeasonName",
|
||||
"SeasonId"
|
||||
"SeasonId",
|
||||
"SeriesId"
|
||||
};
|
||||
_saveItemCommand = _connection.CreateCommand();
|
||||
_saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (";
|
||||
|
@ -972,6 +975,15 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
_saveItemCommand.GetParameter(index++).Value = null;
|
||||
}
|
||||
|
||||
if (hasSeries != null)
|
||||
{
|
||||
_saveItemCommand.GetParameter(index++).Value = hasSeries.FindSeriesId();
|
||||
}
|
||||
else
|
||||
{
|
||||
_saveItemCommand.GetParameter(index++).Value = null;
|
||||
}
|
||||
|
||||
_saveItemCommand.Transaction = transaction;
|
||||
|
||||
_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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user