update seasons
This commit is contained in:
parent
432c52f934
commit
329e047803
|
@ -418,7 +418,7 @@ namespace MediaBrowser.Api
|
||||||
if (request.IsMissing.HasValue)
|
if (request.IsMissing.HasValue)
|
||||||
{
|
{
|
||||||
var val = request.IsMissing.Value;
|
var val = request.IsMissing.Value;
|
||||||
items = items.Where(i => (i.IsMissingSeason ?? false) == val);
|
items = items.Where(i => (i.IsMissingSeason) == val);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.IsVirtualUnaired.HasValue)
|
if (request.IsVirtualUnaired.HasValue)
|
||||||
|
|
|
@ -134,7 +134,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
if (!IsMissingSeason.HasValue)
|
if (!IsVirtualItem.HasValue)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -144,12 +144,18 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||||
}
|
}
|
||||||
|
|
||||||
[IgnoreDataMember]
|
[IgnoreDataMember]
|
||||||
public bool? IsMissingSeason { get; set; }
|
public bool? IsVirtualItem { get; set; }
|
||||||
|
|
||||||
|
[IgnoreDataMember]
|
||||||
|
public bool IsMissingSeason
|
||||||
|
{
|
||||||
|
get { return (IsVirtualItem ?? false) && !IsUnaired; }
|
||||||
|
}
|
||||||
|
|
||||||
[IgnoreDataMember]
|
[IgnoreDataMember]
|
||||||
public bool IsVirtualUnaired
|
public bool IsVirtualUnaired
|
||||||
{
|
{
|
||||||
get { return LocationType == LocationType.Virtual && IsUnaired; }
|
get { return (IsVirtualItem ?? false) && IsUnaired; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[IgnoreDataMember]
|
[IgnoreDataMember]
|
||||||
|
@ -313,10 +319,6 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||||
{
|
{
|
||||||
var hasChanges = base.BeforeMetadataRefresh();
|
var hasChanges = base.BeforeMetadataRefresh();
|
||||||
|
|
||||||
var locationType = LocationType;
|
|
||||||
|
|
||||||
if (locationType == LocationType.FileSystem || locationType == LocationType.Offline)
|
|
||||||
{
|
|
||||||
if (!IndexNumber.HasValue && !string.IsNullOrEmpty(Path))
|
if (!IndexNumber.HasValue && !string.IsNullOrEmpty(Path))
|
||||||
{
|
{
|
||||||
IndexNumber = IndexNumber ?? LibraryManager.GetSeasonNumberFromPath(Path);
|
IndexNumber = IndexNumber ?? LibraryManager.GetSeasonNumberFromPath(Path);
|
||||||
|
@ -327,7 +329,6 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||||
hasChanges = true;
|
hasChanges = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return hasChanges;
|
return hasChanges;
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,7 +240,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||||
|
|
||||||
if (!includeMissingSeasons)
|
if (!includeMissingSeasons)
|
||||||
{
|
{
|
||||||
seasons = seasons.Where(i => !(i.IsMissingSeason ?? false));
|
seasons = seasons.Where(i => !(i.IsMissingSeason));
|
||||||
}
|
}
|
||||||
if (!includeVirtualUnaired)
|
if (!includeVirtualUnaired)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1142,7 +1142,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
var e = i as Season;
|
var e = i as Season;
|
||||||
if (e != null)
|
if (e != null)
|
||||||
{
|
{
|
||||||
return (e.IsMissingSeason ?? false) == val;
|
return (e.IsMissingSeason) == val;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
|
@ -97,7 +97,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<Season> AddSeason(Series series,
|
public async Task<Season> AddSeason(Series series,
|
||||||
int? seasonNumber,
|
int? seasonNumber,
|
||||||
bool isMissingSeason,
|
bool isVirtualItem,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var seasonName = seasonNumber == 0 ?
|
var seasonName = seasonNumber == 0 ?
|
||||||
|
@ -111,7 +111,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
Name = seasonName,
|
Name = seasonName,
|
||||||
IndexNumber = seasonNumber,
|
IndexNumber = seasonNumber,
|
||||||
Id = _libraryManager.GetNewItemId((series.Id + (seasonNumber ?? -1).ToString(_usCulture) + seasonName), typeof(Season)),
|
Id = _libraryManager.GetNewItemId((series.Id + (seasonNumber ?? -1).ToString(_usCulture) + seasonName), typeof(Season)),
|
||||||
IsMissingSeason = isMissingSeason
|
IsVirtualItem = isVirtualItem
|
||||||
};
|
};
|
||||||
|
|
||||||
season.SetParent(series);
|
season.SetParent(series);
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
{
|
{
|
||||||
var episodes = item.GetEpisodes().ToList();
|
var episodes = item.GetEpisodes().ToList();
|
||||||
updateType |= SavePremiereDate(item, episodes);
|
updateType |= SavePremiereDate(item, episodes);
|
||||||
updateType |= SaveIsMissing(item, episodes);
|
updateType |= SaveIsVirtualItem(item, episodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return updateType;
|
return updateType;
|
||||||
|
@ -67,13 +67,13 @@ namespace MediaBrowser.Providers.TV
|
||||||
return ItemUpdateType.None;
|
return ItemUpdateType.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemUpdateType SaveIsMissing(Season item, List<Episode> episodes)
|
private ItemUpdateType SaveIsVirtualItem(Season item, List<Episode> episodes)
|
||||||
{
|
{
|
||||||
var isMissing = item.LocationType == LocationType.Virtual && (episodes.Count == 0 || episodes.All(i => i.IsMissingEpisode));
|
var isVirtualItem = item.LocationType == LocationType.Virtual && (episodes.Count == 0 || episodes.All(i => i.LocationType == LocationType.Virtual));
|
||||||
|
|
||||||
if (item.IsMissingSeason != isMissing)
|
if (item.IsVirtualItem != isVirtualItem)
|
||||||
{
|
{
|
||||||
item.IsMissingSeason = isMissing;
|
item.IsVirtualItem = isVirtualItem;
|
||||||
return ItemUpdateType.MetadataEdit;
|
return ItemUpdateType.MetadataEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -238,6 +238,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
_connection.AddColumn(Logger, "TypedBaseItems", "PrimaryVersionId", "Text");
|
_connection.AddColumn(Logger, "TypedBaseItems", "PrimaryVersionId", "Text");
|
||||||
_connection.AddColumn(Logger, "TypedBaseItems", "DateLastMediaAdded", "DATETIME");
|
_connection.AddColumn(Logger, "TypedBaseItems", "DateLastMediaAdded", "DATETIME");
|
||||||
_connection.AddColumn(Logger, "TypedBaseItems", "Album", "Text");
|
_connection.AddColumn(Logger, "TypedBaseItems", "Album", "Text");
|
||||||
|
_connection.AddColumn(Logger, "TypedBaseItems", "IsVirtualItem", "BIT");
|
||||||
|
|
||||||
_connection.AddColumn(Logger, "UserDataKeys", "Priority", "INT");
|
_connection.AddColumn(Logger, "UserDataKeys", "Priority", "INT");
|
||||||
|
|
||||||
|
@ -359,7 +360,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
"DateLastMediaAdded",
|
"DateLastMediaAdded",
|
||||||
"Album",
|
"Album",
|
||||||
"CriticRating",
|
"CriticRating",
|
||||||
"CriticRatingSummary"
|
"CriticRatingSummary",
|
||||||
|
"IsVirtualItem"
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly string[] _mediaStreamSaveColumns =
|
private readonly string[] _mediaStreamSaveColumns =
|
||||||
|
@ -474,7 +476,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
"OriginalTitle",
|
"OriginalTitle",
|
||||||
"PrimaryVersionId",
|
"PrimaryVersionId",
|
||||||
"DateLastMediaAdded",
|
"DateLastMediaAdded",
|
||||||
"Album"
|
"Album",
|
||||||
|
"IsVirtualItem"
|
||||||
};
|
};
|
||||||
_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 (";
|
||||||
|
@ -866,6 +869,16 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
|
|
||||||
_saveItemCommand.GetParameter(index++).Value = item.Album;
|
_saveItemCommand.GetParameter(index++).Value = item.Album;
|
||||||
|
|
||||||
|
var season = item as Season;
|
||||||
|
if (season != null && season.IsVirtualItem.HasValue)
|
||||||
|
{
|
||||||
|
_saveItemCommand.GetParameter(index++).Value = season.IsVirtualItem.Value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_saveItemCommand.GetParameter(index++).Value = null;
|
||||||
|
}
|
||||||
|
|
||||||
_saveItemCommand.Transaction = transaction;
|
_saveItemCommand.Transaction = transaction;
|
||||||
|
|
||||||
_saveItemCommand.ExecuteNonQuery();
|
_saveItemCommand.ExecuteNonQuery();
|
||||||
|
@ -1281,6 +1294,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
item.CriticRatingSummary = reader.GetString(57);
|
item.CriticRatingSummary = reader.GetString(57);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var season = item as Season;
|
||||||
|
if (season != null && !reader.IsDBNull(58))
|
||||||
|
{
|
||||||
|
season.IsVirtualItem = reader.GetBoolean(58);
|
||||||
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user