persist locked fields in xml

This commit is contained in:
Luke Pulverenti 2013-08-03 20:59:23 -04:00
parent f05ec44742
commit 06ec5ebcb9
6 changed files with 86 additions and 41 deletions

View File

@ -1064,6 +1064,8 @@ namespace MediaBrowser.Controller.Entities
{ {
try try
{ {
Logger.Debug("Found shortcut at {0}", i.FullName);
return new LinkedChild return new LinkedChild
{ {
Path = FileSystem.ResolveShortcut(i.FullName), Path = FileSystem.ResolveShortcut(i.FullName),
@ -1082,6 +1084,7 @@ namespace MediaBrowser.Controller.Entities
if (!newShortcutLinks.SequenceEqual(currentShortcutLinks)) if (!newShortcutLinks.SequenceEqual(currentShortcutLinks))
{ {
Logger.Info("Shortcut links have changed for {0}", Path); Logger.Info("Shortcut links have changed for {0}", Path);
newShortcutLinks.AddRange(currentManualLinks); newShortcutLinks.AddRange(currentManualLinks);
LinkedChildren = newShortcutLinks; LinkedChildren = newShortcutLinks;
return true; return true;

View File

@ -235,6 +235,35 @@ namespace MediaBrowser.Controller.Providers
break; break;
} }
case "LockedFields":
{
var fields = new List<MetadataFields>();
var val = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(val))
{
var list = val.Split('|').Select(i =>
{
MetadataFields field;
if (Enum.TryParse<MetadataFields>(i, true, out field))
{
return (MetadataFields?)field;
}
return null;
}).Where(i => i.HasValue).Select(i => i.Value);
fields.AddRange(list);
}
item.LockedFields = fields;
break;
}
case "TagLines": case "TagLines":
{ {
FetchFromTaglinesNode(reader.ReadSubtree(), item); FetchFromTaglinesNode(reader.ReadSubtree(), item);

View File

@ -107,6 +107,8 @@ namespace MediaBrowser.Providers.MediaInfo
audio.Name = title; audio.Name = title;
} }
if (!audio.LockedFields.Contains(MetadataFields.Cast))
{
var composer = GetDictionaryValue(tags, "composer"); var composer = GetDictionaryValue(tags, "composer");
if (!string.IsNullOrWhiteSpace(composer)) if (!string.IsNullOrWhiteSpace(composer))
@ -121,6 +123,7 @@ namespace MediaBrowser.Providers.MediaInfo
} }
} }
} }
}
audio.Album = GetDictionaryValue(tags, "album"); audio.Album = GetDictionaryValue(tags, "album");
@ -148,13 +151,19 @@ namespace MediaBrowser.Providers.MediaInfo
audio.ProductionYear = audio.PremiereDate.Value.ToLocalTime().Year; audio.ProductionYear = audio.PremiereDate.Value.ToLocalTime().Year;
} }
if (!audio.LockedFields.Contains(MetadataFields.Genres))
{
FetchGenres(audio, tags); FetchGenres(audio, tags);
}
if (!audio.LockedFields.Contains(MetadataFields.Studios))
{
// There's several values in tags may or may not be present // There's several values in tags may or may not be present
FetchStudios(audio, tags, "organization"); FetchStudios(audio, tags, "organization");
FetchStudios(audio, tags, "ensemble"); FetchStudios(audio, tags, "ensemble");
FetchStudios(audio, tags, "publisher"); FetchStudios(audio, tags, "publisher");
} }
}
/// <summary> /// <summary>
/// Splits the specified val. /// Splits the specified val.

View File

@ -300,6 +300,8 @@ namespace MediaBrowser.Providers.MediaInfo
return; return;
} }
if (!video.LockedFields.Contains(MetadataFields.Genres))
{
var genres = GetDictionaryValue(data.format.tags, "genre"); var genres = GetDictionaryValue(data.format.tags, "genre");
if (!string.IsNullOrEmpty(genres)) if (!string.IsNullOrEmpty(genres))
@ -309,6 +311,7 @@ namespace MediaBrowser.Providers.MediaInfo
.Select(i => i.Trim()) .Select(i => i.Trim())
.ToList(); .ToList();
} }
}
var overview = GetDictionaryValue(data.format.tags, "WM/SubTitleDescription"); var overview = GetDictionaryValue(data.format.tags, "WM/SubTitleDescription");

View File

@ -77,7 +77,8 @@ namespace MediaBrowser.Providers.Savers
"CriticRatingSummary", "CriticRatingSummary",
"GamesDbId", "GamesDbId",
"BirthDate", "BirthDate",
"DeathDate" "DeathDate",
"LockedFields"
}); });
var position = xml.ToString().LastIndexOf("</", StringComparison.OrdinalIgnoreCase); var position = xml.ToString().LastIndexOf("</", StringComparison.OrdinalIgnoreCase);
@ -166,6 +167,11 @@ namespace MediaBrowser.Providers.Savers
builder.Append("<LockData>" + item.DontFetchMeta.ToString().ToLower() + "</LockData>"); builder.Append("<LockData>" + item.DontFetchMeta.ToString().ToLower() + "</LockData>");
if (item.LockedFields.Count > 0)
{
builder.Append("<LockedFields>" + string.Join("|", item.LockedFields.Select(i => i.ToString()).ToArray()) + "</LockedFields>");
}
if (!string.IsNullOrEmpty(item.DisplayMediaType)) if (!string.IsNullOrEmpty(item.DisplayMediaType))
{ {
builder.Append("<Type>" + SecurityElement.Escape(item.DisplayMediaType) + "</Type>"); builder.Append("<Type>" + SecurityElement.Escape(item.DisplayMediaType) + "</Type>");

View File

@ -179,16 +179,10 @@ namespace MediaBrowser.Providers.TV
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
BaseProviderInfo data;
if (!item.ProviderData.TryGetValue(Id, out data))
{
data = new BaseProviderInfo();
item.ProviderData[Id] = data;
}
var seriesId = item.GetProviderId(MetadataProviders.Tvdb); var seriesId = item.GetProviderId(MetadataProviders.Tvdb);
if (!string.IsNullOrEmpty(seriesId))
{
var seriesDataPath = GetSeriesDataPath(ConfigurationManager.ApplicationPaths, seriesId); var seriesDataPath = GetSeriesDataPath(ConfigurationManager.ApplicationPaths, seriesId);
var xmlPath = Path.Combine(seriesDataPath, "fanart.xml"); var xmlPath = Path.Combine(seriesDataPath, "fanart.xml");
@ -202,6 +196,7 @@ namespace MediaBrowser.Providers.TV
{ {
await FetchFromXml(item, xmlPath, cancellationToken).ConfigureAwait(false); await FetchFromXml(item, xmlPath, cancellationToken).ConfigureAwait(false);
} }
}
SetLastRefreshed(item, DateTime.UtcNow); SetLastRefreshed(item, DateTime.UtcNow);