persist locked fields in xml

pull/702/head
Luke Pulverenti 12 years ago
parent f05ec44742
commit 06ec5ebcb9

@ -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;

@ -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);

@ -107,17 +107,20 @@ namespace MediaBrowser.Providers.MediaInfo
audio.Name = title; audio.Name = title;
} }
var composer = GetDictionaryValue(tags, "composer"); if (!audio.LockedFields.Contains(MetadataFields.Cast))
if (!string.IsNullOrWhiteSpace(composer))
{ {
foreach (var person in Split(composer)) var composer = GetDictionaryValue(tags, "composer");
{
var name = person.Trim();
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; 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 if (!audio.LockedFields.Contains(MetadataFields.Studios))
FetchStudios(audio, tags, "organization"); {
FetchStudios(audio, tags, "ensemble"); // There's several values in tags may or may not be present
FetchStudios(audio, tags, "publisher"); FetchStudios(audio, tags, "organization");
FetchStudios(audio, tags, "ensemble");
FetchStudios(audio, tags, "publisher");
}
} }
/// <summary> /// <summary>

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

@ -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>");
@ -462,7 +468,7 @@ namespace MediaBrowser.Providers.Savers
{ {
builder.Append("<ScanType>" + SecurityElement.Escape(stream.ScanType) + "</ScanType>"); builder.Append("<ScanType>" + SecurityElement.Escape(stream.ScanType) + "</ScanType>");
} }
if (stream.Channels.HasValue) if (stream.Channels.HasValue)
{ {
builder.Append("<Channels>" + stream.Channels.Value.ToString(UsCulture) + "</Channels>"); builder.Append("<Channels>" + stream.Channels.Value.ToString(UsCulture) + "</Channels>");
@ -507,7 +513,7 @@ namespace MediaBrowser.Providers.Savers
} }
} }
} }
builder.Append("</" + stream.Type + ">"); builder.Append("</" + stream.Type + ">");
} }

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

Loading…
Cancel
Save