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

View File

@ -235,6 +235,35 @@ namespace MediaBrowser.Controller.Providers
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":
{
FetchFromTaglinesNode(reader.ReadSubtree(), item);

View File

@ -107,17 +107,20 @@ namespace MediaBrowser.Providers.MediaInfo
audio.Name = title;
}
var composer = GetDictionaryValue(tags, "composer");
if (!string.IsNullOrWhiteSpace(composer))
if (!audio.LockedFields.Contains(MetadataFields.Cast))
{
foreach (var person in Split(composer))
{
var name = person.Trim();
var composer = GetDictionaryValue(tags, "composer");
if (!string.IsNullOrEmpty(name))
if (!string.IsNullOrWhiteSpace(composer))
{
foreach (var person in Split(composer))
{
audio.AddPerson(new PersonInfo { Name = name, Type = PersonType.Composer });
var name = person.Trim();
if (!string.IsNullOrEmpty(name))
{
audio.AddPerson(new PersonInfo { Name = name, Type = PersonType.Composer });
}
}
}
}
@ -148,12 +151,18 @@ namespace MediaBrowser.Providers.MediaInfo
audio.ProductionYear = audio.PremiereDate.Value.ToLocalTime().Year;
}
FetchGenres(audio, tags);
if (!audio.LockedFields.Contains(MetadataFields.Genres))
{
FetchGenres(audio, tags);
}
// There's several values in tags may or may not be present
FetchStudios(audio, tags, "organization");
FetchStudios(audio, tags, "ensemble");
FetchStudios(audio, tags, "publisher");
if (!audio.LockedFields.Contains(MetadataFields.Studios))
{
// There's several values in tags may or may not be present
FetchStudios(audio, tags, "organization");
FetchStudios(audio, tags, "ensemble");
FetchStudios(audio, tags, "publisher");
}
}
/// <summary>

View File

@ -300,14 +300,17 @@ namespace MediaBrowser.Providers.MediaInfo
return;
}
var genres = GetDictionaryValue(data.format.tags, "genre");
if (!string.IsNullOrEmpty(genres))
if (!video.LockedFields.Contains(MetadataFields.Genres))
{
video.Genres = genres.Split(new[] { ';', '/' }, StringSplitOptions.RemoveEmptyEntries)
.Where(i => !string.IsNullOrWhiteSpace(i))
.Select(i => i.Trim())
.ToList();
var genres = GetDictionaryValue(data.format.tags, "genre");
if (!string.IsNullOrEmpty(genres))
{
video.Genres = genres.Split(new[] { ';', '/' }, StringSplitOptions.RemoveEmptyEntries)
.Where(i => !string.IsNullOrWhiteSpace(i))
.Select(i => i.Trim())
.ToList();
}
}
var overview = GetDictionaryValue(data.format.tags, "WM/SubTitleDescription");

View File

@ -77,7 +77,8 @@ namespace MediaBrowser.Providers.Savers
"CriticRatingSummary",
"GamesDbId",
"BirthDate",
"DeathDate"
"DeathDate",
"LockedFields"
});
var position = xml.ToString().LastIndexOf("</", StringComparison.OrdinalIgnoreCase);
@ -166,6 +167,11 @@ namespace MediaBrowser.Providers.Savers
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))
{
builder.Append("<Type>" + SecurityElement.Escape(item.DisplayMediaType) + "</Type>");

View File

@ -179,28 +179,23 @@ namespace MediaBrowser.Providers.TV
{
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 seriesDataPath = GetSeriesDataPath(ConfigurationManager.ApplicationPaths, seriesId);
var xmlPath = Path.Combine(seriesDataPath, "fanart.xml");
// Only download the xml if it doesn't already exist. The prescan task will take care of getting updates
if (!File.Exists(xmlPath))
if (!string.IsNullOrEmpty(seriesId))
{
await DownloadSeriesXml(seriesDataPath, seriesId, cancellationToken).ConfigureAwait(false);
}
var seriesDataPath = GetSeriesDataPath(ConfigurationManager.ApplicationPaths, seriesId);
var xmlPath = Path.Combine(seriesDataPath, "fanart.xml");
if (File.Exists(xmlPath))
{
await FetchFromXml(item, xmlPath, cancellationToken).ConfigureAwait(false);
// Only download the xml if it doesn't already exist. The prescan task will take care of getting updates
if (!File.Exists(xmlPath))
{
await DownloadSeriesXml(seriesDataPath, seriesId, cancellationToken).ConfigureAwait(false);
}
if (File.Exists(xmlPath))
{
await FetchFromXml(item, xmlPath, cancellationToken).ConfigureAwait(false);
}
}
SetLastRefreshed(item, DateTime.UtcNow);