replace comparison data with comparedate

pull/702/head
Luke Pulverenti 12 years ago
parent b9c1113df9
commit 43c9ab9cdc

@ -148,22 +148,13 @@ namespace MediaBrowser.Providers.Movies
return false; return false;
} }
// Refresh if tmdb id has changed
if (providerInfo.Data != GetComparisonData(item.GetProviderId(MetadataProviders.Tmdb)))
{
return true;
}
return base.NeedsRefreshInternal(item, providerInfo); return base.NeedsRefreshInternal(item, providerInfo);
} }
/// <summary> protected override DateTime CompareDate(BaseItem item)
/// Gets the comparison data.
/// </summary>
/// <param name="id">The id.</param>
/// <returns>Guid.</returns>
private Guid GetComparisonData(string id)
{ {
var id = item.GetProviderId(MetadataProviders.Tmdb);
if (!string.IsNullOrEmpty(id)) if (!string.IsNullOrEmpty(id))
{ {
// Process images // Process images
@ -171,16 +162,16 @@ namespace MediaBrowser.Providers.Movies
var files = new DirectoryInfo(path) var files = new DirectoryInfo(path)
.EnumerateFiles("*.xml", SearchOption.TopDirectoryOnly) .EnumerateFiles("*.xml", SearchOption.TopDirectoryOnly)
.Select(i => i.FullName + i.LastWriteTimeUtc.Ticks) .Select(i => i.LastWriteTimeUtc)
.ToArray(); .ToArray();
if (files.Length > 0) if (files.Length > 0)
{ {
return string.Join(string.Empty, files).GetMD5(); return files.Max();
} }
} }
return Guid.Empty; return base.CompareDate(item);
} }
/// <summary> /// <summary>
@ -253,7 +244,6 @@ namespace MediaBrowser.Providers.Movies
await FetchFromXml(item, xmlPath, cancellationToken).ConfigureAwait(false); await FetchFromXml(item, xmlPath, cancellationToken).ConfigureAwait(false);
} }
data.Data = GetComparisonData(item.GetProviderId(MetadataProviders.Tmdb));
SetLastRefreshed(item, DateTime.UtcNow); SetLastRefreshed(item, DateTime.UtcNow);
return true; return true;
} }

@ -132,20 +132,10 @@ namespace MediaBrowser.Providers.Music
return false; return false;
} }
if (GetComparisonData(item) != providerInfo.Data)
{
return true;
}
return base.NeedsRefreshInternal(item, providerInfo); return base.NeedsRefreshInternal(item, providerInfo);
} }
/// <summary> protected override DateTime CompareDate(BaseItem item)
/// Gets the comparison data.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>Guid.</returns>
private Guid GetComparisonData(BaseItem item)
{ {
var musicBrainzId = item.GetProviderId(MetadataProviders.Musicbrainz); var musicBrainzId = item.GetProviderId(MetadataProviders.Musicbrainz);
@ -156,16 +146,16 @@ namespace MediaBrowser.Providers.Music
var files = new DirectoryInfo(path) var files = new DirectoryInfo(path)
.EnumerateFiles("*.xml", SearchOption.TopDirectoryOnly) .EnumerateFiles("*.xml", SearchOption.TopDirectoryOnly)
.Select(i => i.FullName + i.LastWriteTimeUtc.Ticks) .Select(i => i.LastWriteTimeUtc)
.ToArray(); .ToArray();
if (files.Length > 0) if (files.Length > 0)
{ {
return string.Join(string.Empty, files).GetMD5(); return files.Max();
} }
} }
return Guid.Empty; return base.CompareDate(item);
} }
/// <summary> /// <summary>
@ -249,8 +239,6 @@ namespace MediaBrowser.Providers.Music
item.ProviderData[Id] = data; item.ProviderData[Id] = data;
} }
data.Data = GetComparisonData(item);
SetLastRefreshed(item, DateTime.UtcNow); SetLastRefreshed(item, DateTime.UtcNow);
return true; return true;
} }

@ -1,5 +1,4 @@
using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO; using MediaBrowser.Common.IO;
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
@ -80,20 +79,13 @@ namespace MediaBrowser.Providers.TV
return false; return false;
} }
if (providerInfo.Data != GetComparisonData(item.GetProviderId(MetadataProviders.Tvdb)))
{
return true;
}
return base.NeedsRefreshInternal(item, providerInfo); return base.NeedsRefreshInternal(item, providerInfo);
} }
/// <summary> protected override DateTime CompareDate(BaseItem item)
/// Gets the comparison data.
/// </summary>
/// <returns>Guid.</returns>
private Guid GetComparisonData(string id)
{ {
var id = item.GetProviderId(MetadataProviders.Tvdb);
if (!string.IsNullOrEmpty(id)) if (!string.IsNullOrEmpty(id))
{ {
// Process images // Process images
@ -101,16 +93,16 @@ namespace MediaBrowser.Providers.TV
var files = new DirectoryInfo(path) var files = new DirectoryInfo(path)
.EnumerateFiles("*.xml", SearchOption.TopDirectoryOnly) .EnumerateFiles("*.xml", SearchOption.TopDirectoryOnly)
.Select(i => i.FullName + i.LastWriteTimeUtc.Ticks) .Select(i => i.LastWriteTimeUtc)
.ToArray(); .ToArray();
if (files.Length > 0) if (files.Length > 0)
{ {
return string.Join(string.Empty, files).GetMD5(); return files.Max();
} }
} }
return Guid.Empty; return base.CompareDate(item);
} }
/// <summary> /// <summary>
@ -202,7 +194,6 @@ namespace MediaBrowser.Providers.TV
await FetchFromXml(item, xmlPath, cancellationToken).ConfigureAwait(false); await FetchFromXml(item, xmlPath, cancellationToken).ConfigureAwait(false);
} }
data.Data = GetComparisonData(item.GetProviderId(MetadataProviders.Tvdb));
SetLastRefreshed(item, DateTime.UtcNow); SetLastRefreshed(item, DateTime.UtcNow);
return true; return true;

@ -162,29 +162,7 @@ namespace MediaBrowser.Providers.TV
} }
} }
/// <summary> protected override DateTime CompareDate(BaseItem item)
/// Needses the refresh internal.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="providerInfo">The provider info.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
{
// Refresh even if local metadata exists because we need episode infos
if (GetComparisonData(item) != providerInfo.Data)
{
return true;
}
return base.NeedsRefreshInternal(item, providerInfo);
}
/// <summary>
/// Gets the comparison data.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>Guid.</returns>
private Guid GetComparisonData(BaseItem item)
{ {
var seriesId = item.GetProviderId(MetadataProviders.Tvdb); var seriesId = item.GetProviderId(MetadataProviders.Tvdb);
@ -195,16 +173,16 @@ namespace MediaBrowser.Providers.TV
var files = new DirectoryInfo(path) var files = new DirectoryInfo(path)
.EnumerateFiles("*.xml", SearchOption.TopDirectoryOnly) .EnumerateFiles("*.xml", SearchOption.TopDirectoryOnly)
.Select(i => i.FullName + i.LastWriteTimeUtc.Ticks) .Select(i => i.LastWriteTimeUtc)
.ToArray(); .ToArray();
if (files.Length > 0) if (files.Length > 0)
{ {
return string.Join(string.Empty, files).GetMD5(); return files.Max();
} }
} }
return Guid.Empty; return base.CompareDate(item);
} }
/// <summary> /// <summary>
@ -245,8 +223,6 @@ namespace MediaBrowser.Providers.TV
item.ProviderData[Id] = data; item.ProviderData[Id] = data;
} }
data.Data = GetComparisonData(item);
SetLastRefreshed(item, DateTime.UtcNow); SetLastRefreshed(item, DateTime.UtcNow);
return true; return true;
} }

Loading…
Cancel
Save