Metadata Downloading (#3525)

This commit is contained in:
Joe Milazzo 2025-02-05 16:16:44 -06:00 committed by GitHub
parent eb66763078
commit f4fd7230ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
108 changed files with 6296 additions and 484 deletions

View file

@ -103,13 +103,18 @@ public static class TagHelper
public static void UpdateTagList(ICollection<TagDto>? existingDbTags, Series series, IReadOnlyCollection<Tag> newTags, Action<Tag> handleAdd, Action onModified)
{
UpdateTagList(existingDbTags.Select(t => t.Title).ToList(), series, newTags, handleAdd, onModified);
}
public static void UpdateTagList(ICollection<string>? existingDbTags, Series series, IReadOnlyCollection<Tag> newTags, Action<Tag> handleAdd, Action onModified)
{
if (existingDbTags == null) return;
var isModified = false;
// Convert tags and existing genres to hash sets for quick lookups by normalized title
var existingTagSet = new HashSet<string>(existingDbTags.Select(t => t.Title.ToNormalized()));
var existingTagSet = new HashSet<string>(existingDbTags.Select(t => t.ToNormalized()));
var dbTagSet = new HashSet<string>(series.Metadata.Tags.Select(g => g.NormalizedTitle));
// Remove tags that are no longer present in the input tags
@ -129,7 +134,7 @@ public static class TagHelper
// Add new tags from the input list
foreach (var tagDto in existingDbTags)
{
var normalizedTitle = tagDto.Title.ToNormalized();
var normalizedTitle = tagDto.ToNormalized();
if (dbTagSet.Contains(normalizedTitle)) continue; // This prevents re-adding existing genres
@ -139,7 +144,7 @@ public static class TagHelper
}
else
{
handleAdd(new TagBuilder(tagDto.Title).Build()); // Add new genre if not found
handleAdd(new TagBuilder(tagDto).Build()); // Add new genre if not found
}
isModified = true;
}