boxset image fixes
This commit is contained in:
parent
574a796280
commit
1f7e1f5c4a
|
@ -73,6 +73,7 @@ namespace MediaBrowser.Api
|
|||
_config.Configuration.DisableXmlSavers = true;
|
||||
_config.Configuration.DisableStartupScan = true;
|
||||
_config.Configuration.EnableUserViews = true;
|
||||
_config.Configuration.EnableDateLastRefresh = true;
|
||||
_config.SaveConfiguration();
|
||||
}
|
||||
|
||||
|
|
|
@ -342,6 +342,9 @@ namespace MediaBrowser.Controller.Entities
|
|||
|
||||
public DateTime DateLastSaved { get; set; }
|
||||
|
||||
[IgnoreDataMember]
|
||||
public DateTime DateLastRefreshed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
|
|
|
@ -30,6 +30,12 @@ namespace MediaBrowser.Controller.Entities
|
|||
/// <value>The date last saved.</value>
|
||||
DateTime DateLastSaved { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date last refreshed.
|
||||
/// </summary>
|
||||
/// <value>The date last refreshed.</value>
|
||||
DateTime DateLastRefreshed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Updates to repository.
|
||||
/// </summary>
|
||||
|
|
|
@ -7,15 +7,15 @@ namespace MediaBrowser.Controller.Providers
|
|||
/// </summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The default
|
||||
/// </summary>
|
||||
Default = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Existing images will be validated
|
||||
/// </summary>
|
||||
ValidationOnly = 2,
|
||||
ValidationOnly = 1,
|
||||
|
||||
/// <summary>
|
||||
/// The default
|
||||
/// </summary>
|
||||
Default = 2,
|
||||
|
||||
/// <summary>
|
||||
/// All providers will be executed to search for new metadata
|
||||
|
|
|
@ -224,6 +224,8 @@ namespace MediaBrowser.Model.Configuration
|
|||
|
||||
public bool EnableVideoFrameByFrameAnalysis { get; set; }
|
||||
|
||||
public bool EnableDateLastRefresh { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
||||
/// </summary>
|
||||
|
|
|
@ -12,6 +12,7 @@ using System.Linq;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using CommonIO;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
|
||||
namespace MediaBrowser.Providers.Manager
|
||||
{
|
||||
|
@ -82,7 +83,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
/// <returns>ProviderResult.</returns>
|
||||
protected MetadataStatus GetLastResult(IHasMetadata item)
|
||||
{
|
||||
if (item.DateLastSaved == default(DateTime))
|
||||
if (GetLastRefreshDate(item) == default(DateTime))
|
||||
{
|
||||
return new MetadataStatus { ItemId = item.Id };
|
||||
}
|
||||
|
@ -181,11 +182,13 @@ namespace MediaBrowser.Providers.Manager
|
|||
}
|
||||
}
|
||||
|
||||
var beforeSaveResult = await BeforeSave(itemOfType, item.DateLastSaved == default(DateTime) || refreshOptions.ReplaceAllMetadata || refreshOptions.MetadataRefreshMode == MetadataRefreshMode.FullRefresh, updateType).ConfigureAwait(false);
|
||||
var isFirstRefresh = GetLastRefreshDate(item) == default(DateTime);
|
||||
|
||||
var beforeSaveResult = await BeforeSave(itemOfType, isFirstRefresh || refreshOptions.ReplaceAllMetadata || refreshOptions.MetadataRefreshMode == MetadataRefreshMode.FullRefresh, updateType).ConfigureAwait(false);
|
||||
updateType = updateType | beforeSaveResult;
|
||||
|
||||
// Save if changes were made, or it's never been saved before
|
||||
if (refreshOptions.ForceSave || updateType > ItemUpdateType.None || item.DateLastSaved == default(DateTime) || refreshOptions.ReplaceAllMetadata)
|
||||
if (refreshOptions.ForceSave || updateType > ItemUpdateType.None || isFirstRefresh || refreshOptions.ReplaceAllMetadata)
|
||||
{
|
||||
// If any of these properties are set then make sure the updateType is not None, just to force everything to save
|
||||
if (refreshOptions.ForceSave || refreshOptions.ReplaceAllMetadata)
|
||||
|
@ -193,6 +196,11 @@ namespace MediaBrowser.Providers.Manager
|
|||
updateType = updateType | ItemUpdateType.MetadataDownload;
|
||||
}
|
||||
|
||||
if (refreshOptions.MetadataRefreshMode >= MetadataRefreshMode.Default && refreshOptions.ImageRefreshMode >= ImageRefreshMode.Default)
|
||||
{
|
||||
item.DateLastRefreshed = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
// Save to database
|
||||
await SaveItem(metadataResult, updateType, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
@ -207,6 +215,26 @@ namespace MediaBrowser.Providers.Manager
|
|||
return updateType;
|
||||
}
|
||||
|
||||
private DateTime GetLastRefreshDate(IHasMetadata item)
|
||||
{
|
||||
if (item.DateLastRefreshed != default(DateTime))
|
||||
{
|
||||
return item.DateLastRefreshed;
|
||||
}
|
||||
|
||||
if (ServerConfigurationManager.Configuration.EnableDateLastRefresh)
|
||||
{
|
||||
return item.DateLastRefreshed;
|
||||
}
|
||||
|
||||
if (item is BoxSet)
|
||||
{
|
||||
return item.DateLastRefreshed;
|
||||
}
|
||||
|
||||
return item.DateLastSaved;
|
||||
}
|
||||
|
||||
protected async Task SaveItem(MetadataResult<TItemType> result, ItemUpdateType reason, CancellationToken cancellationToken)
|
||||
{
|
||||
if (result.Item.SupportsPeople && result.People != null)
|
||||
|
@ -222,7 +250,7 @@ namespace MediaBrowser.Providers.Manager
|
|||
item.AfterMetadataRefresh();
|
||||
return _cachedTask;
|
||||
}
|
||||
|
||||
|
||||
private readonly Task<ItemUpdateType> _cachedResult = Task.FromResult(ItemUpdateType.None);
|
||||
/// <summary>
|
||||
/// Befores the save.
|
||||
|
|
|
@ -22,6 +22,17 @@ namespace MediaBrowser.Server.Implementations.Collections
|
|||
{
|
||||
}
|
||||
|
||||
protected override bool Supports(IHasImages item)
|
||||
{
|
||||
// Right now this is the only way to prevent this image from getting created ahead of internet image providers
|
||||
if (!item.IsLocked)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return base.Supports(item);
|
||||
}
|
||||
|
||||
protected override Task<List<BaseItem>> GetItemsWithImages(IHasImages item)
|
||||
{
|
||||
var playlist = (BoxSet)item;
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace MediaBrowser.Server.Implementations.Collections
|
|||
|
||||
try
|
||||
{
|
||||
_fileSystem.CreateDirectory(path);
|
||||
_fileSystem.CreateDirectory(path);
|
||||
|
||||
var collection = new BoxSet
|
||||
{
|
||||
|
@ -93,7 +93,12 @@ namespace MediaBrowser.Server.Implementations.Collections
|
|||
|
||||
if (options.ItemIdList.Count > 0)
|
||||
{
|
||||
await AddToCollection(collection.Id, options.ItemIdList, false);
|
||||
await AddToCollection(collection.Id, options.ItemIdList, false, new MetadataRefreshOptions(_fileSystem)
|
||||
{
|
||||
// The initial adding of items is going to create a local metadata file
|
||||
// This will cause internet metadata to be skipped as a result
|
||||
MetadataRefreshMode = MetadataRefreshMode.FullRefresh
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -145,10 +150,10 @@ namespace MediaBrowser.Server.Implementations.Collections
|
|||
|
||||
public Task AddToCollection(Guid collectionId, IEnumerable<Guid> ids)
|
||||
{
|
||||
return AddToCollection(collectionId, ids, true);
|
||||
return AddToCollection(collectionId, ids, true, new MetadataRefreshOptions(_fileSystem));
|
||||
}
|
||||
|
||||
private async Task AddToCollection(Guid collectionId, IEnumerable<Guid> ids, bool fireEvent)
|
||||
private async Task AddToCollection(Guid collectionId, IEnumerable<Guid> ids, bool fireEvent, MetadataRefreshOptions refreshOptions)
|
||||
{
|
||||
var collection = _libraryManager.GetItemById(collectionId) as BoxSet;
|
||||
|
||||
|
@ -186,7 +191,7 @@ namespace MediaBrowser.Server.Implementations.Collections
|
|||
|
||||
await collection.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
_providerManager.QueueRefresh(collection.Id, new MetadataRefreshOptions(_fileSystem));
|
||||
_providerManager.QueueRefresh(collection.Id, refreshOptions);
|
||||
|
||||
if (fireEvent)
|
||||
{
|
||||
|
|
|
@ -1699,7 +1699,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
|
||||
if (!refresh)
|
||||
{
|
||||
refresh = (DateTime.UtcNow - item.DateLastSaved) >= _viewRefreshInterval;
|
||||
refresh = (DateTime.UtcNow - item.DateLastRefreshed) >= _viewRefreshInterval;
|
||||
}
|
||||
|
||||
if (refresh)
|
||||
|
@ -1796,7 +1796,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
await item.UpdateToRepository(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
var refresh = isNew || (DateTime.UtcNow - item.DateLastSaved) >= _viewRefreshInterval;
|
||||
var refresh = isNew || (DateTime.UtcNow - item.DateLastRefreshed) >= _viewRefreshInterval;
|
||||
|
||||
if (refresh)
|
||||
{
|
||||
|
@ -1866,7 +1866,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
await item.UpdateToRepository(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
var refresh = isNew || (DateTime.UtcNow - item.DateLastSaved) >= _viewRefreshInterval;
|
||||
var refresh = isNew || (DateTime.UtcNow - item.DateLastRefreshed) >= _viewRefreshInterval;
|
||||
|
||||
if (refresh)
|
||||
{
|
||||
|
|
|
@ -706,7 +706,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||
|
||||
isNew = true;
|
||||
}
|
||||
|
||||
|
||||
item.ChannelId = _tvDtoService.GetInternalChannelId(serviceName, info.ChannelId).ToString("N");
|
||||
item.CommunityRating = info.CommunityRating;
|
||||
item.OfficialRating = info.OfficialRating;
|
||||
|
|
|
@ -197,6 +197,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
_connection.AddColumn(_logger, "TypedBaseItems", "IsHD", "BIT");
|
||||
_connection.AddColumn(_logger, "TypedBaseItems", "ExternalEtag", "Text");
|
||||
_connection.AddColumn(_logger, "TypedBaseItems", "ExternalImagePath", "Text");
|
||||
_connection.AddColumn(_logger, "TypedBaseItems", "DateLastRefreshed", "DATETIME");
|
||||
|
||||
PrepareStatements();
|
||||
|
||||
|
@ -291,7 +292,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
"PreferredMetadataCountryCode",
|
||||
"IsHD",
|
||||
"ExternalEtag",
|
||||
"ExternalImagePath"
|
||||
"ExternalImagePath",
|
||||
"DateLastRefreshed"
|
||||
};
|
||||
|
||||
private readonly string[] _mediaStreamSaveColumns =
|
||||
|
@ -378,7 +380,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
"PreferredMetadataCountryCode",
|
||||
"IsHD",
|
||||
"ExternalEtag",
|
||||
"ExternalImagePath"
|
||||
"ExternalImagePath",
|
||||
"DateLastRefreshed"
|
||||
};
|
||||
_saveItemCommand = _connection.CreateCommand();
|
||||
_saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (";
|
||||
|
@ -599,6 +602,15 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
_saveItemCommand.GetParameter(index++).Value = item.ExternalEtag;
|
||||
_saveItemCommand.GetParameter(index++).Value = item.ExternalImagePath;
|
||||
|
||||
if (item.DateLastRefreshed == default(DateTime))
|
||||
{
|
||||
_saveItemCommand.GetParameter(index++).Value = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_saveItemCommand.GetParameter(index++).Value = item.DateLastRefreshed;
|
||||
}
|
||||
|
||||
_saveItemCommand.Transaction = transaction;
|
||||
|
||||
_saveItemCommand.ExecuteNonQuery();
|
||||
|
@ -820,6 +832,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||
item.ExternalImagePath = reader.GetString(23);
|
||||
}
|
||||
|
||||
if (!reader.IsDBNull(24))
|
||||
{
|
||||
item.DateLastRefreshed = reader.GetDateTime(24).ToUniversalTime();
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace MediaBrowser.Server.Implementations.Photos
|
|||
ImageProcessor = imageProcessor;
|
||||
}
|
||||
|
||||
public virtual bool Supports(IHasImages item)
|
||||
protected virtual bool Supports(IHasImages item)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace MediaBrowser.Server.Implementations.UserViews
|
|||
return GetFinalItems(items.Where(i => i.HasImage(ImageType.Primary) || i.HasImage(ImageType.Thumb)).ToList(), 8);
|
||||
}
|
||||
|
||||
public override bool Supports(IHasImages item)
|
||||
protected override bool Supports(IHasImages item)
|
||||
{
|
||||
return item is CollectionFolder;
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ namespace MediaBrowser.Server.Implementations.UserViews
|
|||
return GetFinalItems(items.Where(i => i.HasImage(ImageType.Primary)).ToList());
|
||||
}
|
||||
|
||||
public override bool Supports(IHasImages item)
|
||||
protected override bool Supports(IHasImages item)
|
||||
{
|
||||
var view = item as UserView;
|
||||
if (view != null)
|
||||
|
|
Loading…
Reference in New Issue
Block a user