tv metadata fixes
This commit is contained in:
parent
5897b2555f
commit
15046e5703
|
@ -233,6 +233,16 @@ namespace MediaBrowser.Controller.Providers
|
||||||
throw new ArgumentNullException("providerInfo");
|
throw new ArgumentNullException("providerInfo");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (NeedsRefreshBasedOnCompareDate(item, providerInfo))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RefreshOnFileSystemStampChange && item.LocationType == LocationType.FileSystem && HasFileSystemStampChanged(item, providerInfo))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (RefreshOnVersionChange && !String.Equals(ProviderVersion, providerInfo.ProviderVersion))
|
if (RefreshOnVersionChange && !String.Equals(ProviderVersion, providerInfo.ProviderVersion))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -248,16 +258,6 @@ namespace MediaBrowser.Controller.Providers
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NeedsRefreshBasedOnCompareDate(item, providerInfo))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (RefreshOnFileSystemStampChange && item.LocationType == LocationType.FileSystem && HasFileSystemStampChanged(item, providerInfo))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,8 @@ namespace MediaBrowser.Providers.Games
|
||||||
|
|
||||||
var metaFile = GameXmlSaver.GetGameSavePath(game);
|
var metaFile = GameXmlSaver.GetGameSavePath(game);
|
||||||
|
|
||||||
|
if (File.Exists(metaFile))
|
||||||
|
{
|
||||||
await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
|
await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -82,6 +84,7 @@ namespace MediaBrowser.Providers.Games
|
||||||
{
|
{
|
||||||
XmlParsingResourcePool.Release();
|
XmlParsingResourcePool.Release();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SetLastRefreshed(game, DateTime.UtcNow);
|
SetLastRefreshed(game, DateTime.UtcNow);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -92,6 +92,8 @@ namespace MediaBrowser.Providers.Movies
|
||||||
|
|
||||||
var path = MovieXmlSaver.GetMovieSavePath(item);
|
var path = MovieXmlSaver.GetMovieSavePath(item);
|
||||||
|
|
||||||
|
if (File.Exists(path))
|
||||||
|
{
|
||||||
await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
|
await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -104,6 +106,7 @@ namespace MediaBrowser.Providers.Movies
|
||||||
{
|
{
|
||||||
XmlParsingResourcePool.Release();
|
XmlParsingResourcePool.Release();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SetLastRefreshed(item, DateTime.UtcNow);
|
SetLastRefreshed(item, DateTime.UtcNow);
|
||||||
|
|
||||||
|
|
|
@ -93,11 +93,8 @@ namespace MediaBrowser.Providers.TV
|
||||||
|
|
||||||
var file = item.ResolveArgs.Parent.ResolveArgs.GetMetaFileByPath(metadataFile);
|
var file = item.ResolveArgs.Parent.ResolveArgs.GetMetaFileByPath(metadataFile);
|
||||||
|
|
||||||
if (file == null)
|
if (file != null)
|
||||||
{
|
{
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
|
await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -108,6 +105,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
{
|
{
|
||||||
XmlParsingResourcePool.Release();
|
XmlParsingResourcePool.Release();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SetLastRefreshed(item, DateTime.UtcNow);
|
SetLastRefreshed(item, DateTime.UtcNow);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -120,7 +120,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
|
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
|
||||||
{
|
{
|
||||||
// Don't proceed if there's local metadata
|
// Don't proceed if there's local metadata
|
||||||
if (HasLocalMeta(item) && !ConfigurationManager.Configuration.EnableTvDbUpdates)
|
if (!ConfigurationManager.Configuration.EnableTvDbUpdates && HasLocalMeta(item))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
|
using MediaBrowser.Common.IO;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
|
@ -162,7 +163,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DateTime CompareDate(BaseItem item)
|
protected override bool NeedsRefreshBasedOnCompareDate(BaseItem item, BaseProviderInfo providerInfo)
|
||||||
{
|
{
|
||||||
var seriesId = item.GetProviderId(MetadataProviders.Tvdb);
|
var seriesId = item.GetProviderId(MetadataProviders.Tvdb);
|
||||||
|
|
||||||
|
@ -180,16 +181,17 @@ namespace MediaBrowser.Providers.TV
|
||||||
|
|
||||||
if (files.Count > 0)
|
if (files.Count > 0)
|
||||||
{
|
{
|
||||||
return files.Max();
|
return files.Max() > providerInfo.LastRefreshed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (DirectoryNotFoundException)
|
catch (DirectoryNotFoundException)
|
||||||
{
|
{
|
||||||
// Don't blow up
|
// Don't blow up
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return base.CompareDate(item);
|
return base.NeedsRefreshBasedOnCompareDate(item, providerInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -298,6 +300,66 @@ namespace MediaBrowser.Providers.TV
|
||||||
_zipClient.ExtractAll(ms, seriesDataPath, true);
|
_zipClient.ExtractAll(ms, seriesDataPath, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var file in Directory.EnumerateFiles(seriesDataPath, "*.xml", SearchOption.AllDirectories).ToList())
|
||||||
|
{
|
||||||
|
await SanitizeXmlFile(file).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sanitizes the XML file.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file">The file.</param>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
|
private async Task SanitizeXmlFile(string file)
|
||||||
|
{
|
||||||
|
string validXml;
|
||||||
|
|
||||||
|
using (var fileStream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, true))
|
||||||
|
{
|
||||||
|
using (var reader = new StreamReader(fileStream))
|
||||||
|
{
|
||||||
|
var xml = await reader.ReadToEndAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
|
validXml = StripInvalidXmlCharacters(xml);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var fileStream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, true))
|
||||||
|
{
|
||||||
|
using (var writer = new StreamWriter(fileStream))
|
||||||
|
{
|
||||||
|
await writer.WriteAsync(validXml).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Strips the invalid XML characters.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inString">The in string.</param>
|
||||||
|
/// <returns>System.String.</returns>
|
||||||
|
public static string StripInvalidXmlCharacters(string inString)
|
||||||
|
{
|
||||||
|
if (inString == null) return null;
|
||||||
|
|
||||||
|
var sbOutput = new StringBuilder();
|
||||||
|
char ch;
|
||||||
|
|
||||||
|
for (int i = 0; i < inString.Length; i++)
|
||||||
|
{
|
||||||
|
ch = inString[i];
|
||||||
|
if ((ch >= 0x0020 && ch <= 0xD7FF) ||
|
||||||
|
(ch >= 0xE000 && ch <= 0xFFFD) ||
|
||||||
|
ch == 0x0009 ||
|
||||||
|
ch == 0x000A ||
|
||||||
|
ch == 0x000D)
|
||||||
|
{
|
||||||
|
sbOutput.Append(ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sbOutput.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -320,7 +382,7 @@ namespace MediaBrowser.Providers.TV
|
||||||
/// <returns>System.String.</returns>
|
/// <returns>System.String.</returns>
|
||||||
internal static string GetSeriesDataPath(IApplicationPaths appPaths)
|
internal static string GetSeriesDataPath(IApplicationPaths appPaths)
|
||||||
{
|
{
|
||||||
var dataPath = Path.Combine(appPaths.DataPath, "tvdb");
|
var dataPath = Path.Combine(appPaths.DataPath, "tvdb-v2");
|
||||||
|
|
||||||
return dataPath;
|
return dataPath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
|
||||||
|
|
||||||
private readonly object _syncLock = new object();
|
private readonly object _syncLock = new object();
|
||||||
private Timer UpdateTimer { get; set; }
|
private Timer UpdateTimer { get; set; }
|
||||||
private const int UpdateDuration = 2000;
|
private const int UpdateDuration = 500;
|
||||||
|
|
||||||
private readonly Dictionary<Guid, List<string>> _changedKeys = new Dictionary<Guid, List<string>>();
|
private readonly Dictionary<Guid, List<string>> _changedKeys = new Dictionary<Guid, List<string>>();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user