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",
"artist",
"albumartist"
};
});
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",
"disbanded"
};
});
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>
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)
@ -271,7 +280,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
AddMediaInfo(hasMediaSources, writer);
}
var tagsUsed = GetTagsUsed();
var tagsUsed = GetTagsUsed(item);
try
{
@ -834,7 +843,8 @@ namespace MediaBrowser.XbmcMetadata.Savers
var providerId = item.ProviderIds[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,9 +108,10 @@ namespace MediaBrowser.XbmcMetadata.Savers
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",
"season",
@ -124,8 +125,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
"absolute_number",
"displayseason",
"displayepisode"
};
});
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",
"artist",
"set",
"id"
};
});
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();
list.Add("seasonnumber");
var list = base.GetTagsUsed(item);
list.AddRange(new string[]
{
"seasonnumber"
});
return list;
}

View File

@ -90,9 +90,10 @@ 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",
"episodeguide",
@ -102,8 +103,7 @@ namespace MediaBrowser.XbmcMetadata.Savers
"airs_time",
"airs_dayofweek",
"animeseriesindex"
};
});
return list;
}