boxset image fixes

pull/702/head
Luke Pulverenti 9 years ago
parent 574a796280
commit 1f7e1f5c4a

@ -73,6 +73,7 @@ namespace MediaBrowser.Api
_config.Configuration.DisableXmlSavers = true; _config.Configuration.DisableXmlSavers = true;
_config.Configuration.DisableStartupScan = true; _config.Configuration.DisableStartupScan = true;
_config.Configuration.EnableUserViews = true; _config.Configuration.EnableUserViews = true;
_config.Configuration.EnableDateLastRefresh = true;
_config.SaveConfiguration(); _config.SaveConfiguration();
} }

@ -342,6 +342,9 @@ namespace MediaBrowser.Controller.Entities
public DateTime DateLastSaved { get; set; } public DateTime DateLastSaved { get; set; }
[IgnoreDataMember]
public DateTime DateLastRefreshed { get; set; }
/// <summary> /// <summary>
/// The logger /// The logger
/// </summary> /// </summary>

@ -30,6 +30,12 @@ namespace MediaBrowser.Controller.Entities
/// <value>The date last saved.</value> /// <value>The date last saved.</value>
DateTime DateLastSaved { get; set; } DateTime DateLastSaved { get; set; }
/// <summary>
/// Gets or sets the date last refreshed.
/// </summary>
/// <value>The date last refreshed.</value>
DateTime DateLastRefreshed { get; set; }
/// <summary> /// <summary>
/// Updates to repository. /// Updates to repository.
/// </summary> /// </summary>

@ -8,14 +8,14 @@ namespace MediaBrowser.Controller.Providers
None = 0, None = 0,
/// <summary> /// <summary>
/// The default /// Existing images will be validated
/// </summary> /// </summary>
Default = 1, ValidationOnly = 1,
/// <summary> /// <summary>
/// Existing images will be validated /// The default
/// </summary> /// </summary>
ValidationOnly = 2, Default = 2,
/// <summary> /// <summary>
/// All providers will be executed to search for new metadata /// 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 EnableVideoFrameByFrameAnalysis { get; set; }
public bool EnableDateLastRefresh { get; set; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class. /// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
/// </summary> /// </summary>

@ -12,6 +12,7 @@ using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using CommonIO; using CommonIO;
using MediaBrowser.Controller.Entities.Movies;
namespace MediaBrowser.Providers.Manager namespace MediaBrowser.Providers.Manager
{ {
@ -82,7 +83,7 @@ namespace MediaBrowser.Providers.Manager
/// <returns>ProviderResult.</returns> /// <returns>ProviderResult.</returns>
protected MetadataStatus GetLastResult(IHasMetadata item) protected MetadataStatus GetLastResult(IHasMetadata item)
{ {
if (item.DateLastSaved == default(DateTime)) if (GetLastRefreshDate(item) == default(DateTime))
{ {
return new MetadataStatus { ItemId = item.Id }; 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; updateType = updateType | beforeSaveResult;
// Save if changes were made, or it's never been saved before // 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 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) if (refreshOptions.ForceSave || refreshOptions.ReplaceAllMetadata)
@ -193,6 +196,11 @@ namespace MediaBrowser.Providers.Manager
updateType = updateType | ItemUpdateType.MetadataDownload; updateType = updateType | ItemUpdateType.MetadataDownload;
} }
if (refreshOptions.MetadataRefreshMode >= MetadataRefreshMode.Default && refreshOptions.ImageRefreshMode >= ImageRefreshMode.Default)
{
item.DateLastRefreshed = DateTime.UtcNow;
}
// Save to database // Save to database
await SaveItem(metadataResult, updateType, cancellationToken).ConfigureAwait(false); await SaveItem(metadataResult, updateType, cancellationToken).ConfigureAwait(false);
} }
@ -207,6 +215,26 @@ namespace MediaBrowser.Providers.Manager
return updateType; 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) protected async Task SaveItem(MetadataResult<TItemType> result, ItemUpdateType reason, CancellationToken cancellationToken)
{ {
if (result.Item.SupportsPeople && result.People != null) if (result.Item.SupportsPeople && result.People != null)

@ -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) protected override Task<List<BaseItem>> GetItemsWithImages(IHasImages item)
{ {
var playlist = (BoxSet)item; var playlist = (BoxSet)item;

@ -93,7 +93,12 @@ namespace MediaBrowser.Server.Implementations.Collections
if (options.ItemIdList.Count > 0) 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 else
{ {
@ -145,10 +150,10 @@ namespace MediaBrowser.Server.Implementations.Collections
public Task AddToCollection(Guid collectionId, IEnumerable<Guid> ids) 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; 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); await collection.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
_providerManager.QueueRefresh(collection.Id, new MetadataRefreshOptions(_fileSystem)); _providerManager.QueueRefresh(collection.Id, refreshOptions);
if (fireEvent) if (fireEvent)
{ {

@ -1699,7 +1699,7 @@ namespace MediaBrowser.Server.Implementations.Library
if (!refresh) if (!refresh)
{ {
refresh = (DateTime.UtcNow - item.DateLastSaved) >= _viewRefreshInterval; refresh = (DateTime.UtcNow - item.DateLastRefreshed) >= _viewRefreshInterval;
} }
if (refresh) if (refresh)
@ -1796,7 +1796,7 @@ namespace MediaBrowser.Server.Implementations.Library
await item.UpdateToRepository(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false); 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) if (refresh)
{ {
@ -1866,7 +1866,7 @@ namespace MediaBrowser.Server.Implementations.Library
await item.UpdateToRepository(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false); 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) if (refresh)
{ {

@ -197,6 +197,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
_connection.AddColumn(_logger, "TypedBaseItems", "IsHD", "BIT"); _connection.AddColumn(_logger, "TypedBaseItems", "IsHD", "BIT");
_connection.AddColumn(_logger, "TypedBaseItems", "ExternalEtag", "Text"); _connection.AddColumn(_logger, "TypedBaseItems", "ExternalEtag", "Text");
_connection.AddColumn(_logger, "TypedBaseItems", "ExternalImagePath", "Text"); _connection.AddColumn(_logger, "TypedBaseItems", "ExternalImagePath", "Text");
_connection.AddColumn(_logger, "TypedBaseItems", "DateLastRefreshed", "DATETIME");
PrepareStatements(); PrepareStatements();
@ -291,7 +292,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
"PreferredMetadataCountryCode", "PreferredMetadataCountryCode",
"IsHD", "IsHD",
"ExternalEtag", "ExternalEtag",
"ExternalImagePath" "ExternalImagePath",
"DateLastRefreshed"
}; };
private readonly string[] _mediaStreamSaveColumns = private readonly string[] _mediaStreamSaveColumns =
@ -378,7 +380,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
"PreferredMetadataCountryCode", "PreferredMetadataCountryCode",
"IsHD", "IsHD",
"ExternalEtag", "ExternalEtag",
"ExternalImagePath" "ExternalImagePath",
"DateLastRefreshed"
}; };
_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 (";
@ -599,6 +602,15 @@ namespace MediaBrowser.Server.Implementations.Persistence
_saveItemCommand.GetParameter(index++).Value = item.ExternalEtag; _saveItemCommand.GetParameter(index++).Value = item.ExternalEtag;
_saveItemCommand.GetParameter(index++).Value = item.ExternalImagePath; _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.Transaction = transaction;
_saveItemCommand.ExecuteNonQuery(); _saveItemCommand.ExecuteNonQuery();
@ -820,6 +832,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
item.ExternalImagePath = reader.GetString(23); item.ExternalImagePath = reader.GetString(23);
} }
if (!reader.IsDBNull(24))
{
item.DateLastRefreshed = reader.GetDateTime(24).ToUniversalTime();
}
return item; return item;
} }

@ -33,7 +33,7 @@ namespace MediaBrowser.Server.Implementations.Photos
ImageProcessor = imageProcessor; ImageProcessor = imageProcessor;
} }
public virtual bool Supports(IHasImages item) protected virtual bool Supports(IHasImages item)
{ {
return true; 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); 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; return item is CollectionFolder;
} }

@ -131,7 +131,7 @@ namespace MediaBrowser.Server.Implementations.UserViews
return GetFinalItems(items.Where(i => i.HasImage(ImageType.Primary)).ToList()); 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; var view = item as UserView;
if (view != null) if (view != null)

Loading…
Cancel
Save