Update NfoSavers so they don't duplicate user defined IExternalIds

This commit is contained in:
Darrell King 2017-01-27 23:28:21 +00:00
parent ab026ab2de
commit 8e605ba613
7 changed files with 74 additions and 57 deletions

View File

@ -85,15 +85,15 @@ namespace MediaBrowser.XbmcMetadata.Savers
} }
} }
protected override List<string> GetTagsUsed() protected override List<string> GetTagsUsed(IHasMetadata item)
{ {
var list = new List<string> var list = base.GetTagsUsed(item);
list.AddRange(new string[]
{ {
"track", "track",
"artist", "artist",
"albumartist" "albumartist"
}; });
return list; return list;
} }

View File

@ -79,14 +79,14 @@ namespace MediaBrowser.XbmcMetadata.Savers
} }
} }
protected override List<string> GetTagsUsed() protected override List<string> GetTagsUsed(IHasMetadata item)
{ {
var list = new List<string> var list = base.GetTagsUsed(item);
list.AddRange(new string[]
{ {
"album", "album",
"disbanded" "disbanded"
}; });
return list; return list;
} }

View File

@ -183,9 +183,18 @@ namespace MediaBrowser.XbmcMetadata.Savers
/// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns> /// <returns><c>true</c> if [is enabled for] [the specified item]; otherwise, <c>false</c>.</returns>
public abstract bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType); public abstract bool IsEnabledFor(IHasMetadata item, ItemUpdateType updateType);
protected virtual List<string> GetTagsUsed() protected virtual List<string> GetTagsUsed(IHasMetadata item)
{ {
return new List<string>(); var list = new List<string>();
foreach (var providerKey in item.ProviderIds.Keys)
{
var providerIdTagName = GetTagForProviderKey(providerKey);
if (!CommonTags.ContainsKey(providerIdTagName))
{
list.Add(providerIdTagName);
}
}
return list;
} }
public void Save(IHasMetadata item, CancellationToken cancellationToken) public void Save(IHasMetadata item, CancellationToken cancellationToken)
@ -271,7 +280,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
AddMediaInfo(hasMediaSources, writer); AddMediaInfo(hasMediaSources, writer);
} }
var tagsUsed = GetTagsUsed(); var tagsUsed = GetTagsUsed(item);
try try
{ {
@ -834,7 +843,8 @@ namespace MediaBrowser.XbmcMetadata.Savers
var providerId = item.ProviderIds[providerKey]; var providerId = item.ProviderIds[providerKey];
if (!string.IsNullOrEmpty(providerId) && !writtenProviderIds.Contains(providerKey)) if (!string.IsNullOrEmpty(providerId) && !writtenProviderIds.Contains(providerKey))
{ {
writer.WriteElementString(providerKey.ToLower() + "id", providerId); writer.WriteElementString(GetTagForProviderKey(providerKey), providerId);
writtenProviderIds.Add(providerKey);
} }
} }
} }
@ -1093,5 +1103,10 @@ namespace MediaBrowser.XbmcMetadata.Savers
} }
} }
} }
private static string GetTagForProviderKey(string providerKey)
{
return providerKey.ToLower() + "id";
}
} }
} }

View File

@ -108,24 +108,24 @@ namespace MediaBrowser.XbmcMetadata.Savers
private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
protected override List<string> GetTagsUsed() protected override List<string> GetTagsUsed(IHasMetadata item)
{ {
var list = new List<string> var list = base.GetTagsUsed(item);
list.AddRange(new string[]
{ {
"aired", "aired",
"season", "season",
"episode", "episode",
"episodenumberend", "episodenumberend",
"airsafter_season", "airsafter_season",
"airsbefore_episode", "airsbefore_episode",
"airsbefore_season", "airsbefore_season",
"DVD_episodenumber", "DVD_episodenumber",
"DVD_season", "DVD_season",
"absolute_number", "absolute_number",
"displayseason", "displayseason",
"displayepisode" "displayepisode"
}; });
return list; return list;
} }

View File

@ -113,16 +113,16 @@ namespace MediaBrowser.XbmcMetadata.Savers
} }
} }
protected override List<string> GetTagsUsed() protected override List<string> GetTagsUsed(IHasMetadata item)
{ {
var list = new List<string> var list = base.GetTagsUsed(item);
list.AddRange(new string[]
{ {
"album", "album",
"artist", "artist",
"set", "set",
"id" "id"
}; });
return list; return list;
} }

View File

@ -51,11 +51,13 @@ namespace MediaBrowser.XbmcMetadata.Savers
} }
} }
protected override List<string> GetTagsUsed() protected override List<string> GetTagsUsed(IHasMetadata item)
{ {
var list = base.GetTagsUsed(); var list = base.GetTagsUsed(item);
list.AddRange(new string[]
list.Add("seasonnumber"); {
"seasonnumber"
});
return list; return list;
} }

View File

@ -90,20 +90,20 @@ namespace MediaBrowser.XbmcMetadata.Savers
} }
} }
protected override List<string> GetTagsUsed() protected override List<string> GetTagsUsed(IHasMetadata item)
{ {
var list = new List<string> var list = base.GetTagsUsed(item);
list.AddRange(new string[]
{ {
"id", "id",
"episodeguide", "episodeguide",
"season", "season",
"episode", "episode",
"status", "status",
"airs_time", "airs_time",
"airs_dayofweek", "airs_dayofweek",
"animeseriesindex" "animeseriesindex"
}; });
return list; return list;
} }