Metadata Downloading (#3525)
This commit is contained in:
parent
eb66763078
commit
f4fd7230ea
108 changed files with 6296 additions and 484 deletions
|
|
@ -12,6 +12,7 @@ using API.DTOs.Email;
|
|||
using API.DTOs.Filtering;
|
||||
using API.DTOs.Filtering.v2;
|
||||
using API.DTOs.KavitaPlus.Manage;
|
||||
using API.DTOs.KavitaPlus.Metadata;
|
||||
using API.DTOs.MediaErrors;
|
||||
using API.DTOs.Metadata;
|
||||
using API.DTOs.Progress;
|
||||
|
|
@ -359,5 +360,11 @@ public class AutoMapperProfiles : Profile
|
|||
.ForMember(dest => dest.VolumeTitle, opt => opt.MapFrom(src => src.Volume.Name))
|
||||
.ForMember(dest => dest.LibraryId, opt => opt.MapFrom(src => src.Volume.Series.LibraryId))
|
||||
.ForMember(dest => dest.LibraryType, opt => opt.MapFrom(src => src.Volume.Series.Library.Type));
|
||||
|
||||
CreateMap<MetadataSettings, MetadataSettingsDto>()
|
||||
.ForMember(dest => dest.Blacklist, opt => opt.MapFrom(src => src.Blacklist ?? new List<string>()))
|
||||
.ForMember(dest => dest.Whitelist, opt => opt.MapFrom(src => src.Whitelist ?? new List<string>()));
|
||||
CreateMap<MetadataFieldMapping, MetadataFieldMappingDto>();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,13 @@ public class LibraryBuilder : IEntityBuilder<Library>
|
|||
return this;
|
||||
}
|
||||
|
||||
public LibraryBuilder WIthAllowScrobbling(bool allowScrobbling)
|
||||
public LibraryBuilder WithAllowMetadataMatching(bool allow)
|
||||
{
|
||||
_library.AllowMetadataMatching = allow;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LibraryBuilder WithAllowScrobbling(bool allowScrobbling)
|
||||
{
|
||||
_library.AllowScrobbling = allowScrobbling;
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ using API.Services.Plus;
|
|||
|
||||
namespace API.Helpers.Builders;
|
||||
|
||||
public class PlusSeriesDtoBuilder : IEntityBuilder<PlusSeriesDto>
|
||||
public class PlusSeriesDtoBuilder : IEntityBuilder<PlusSeriesRequestDto>
|
||||
{
|
||||
private readonly PlusSeriesDto _seriesDto;
|
||||
public PlusSeriesDto Build() => _seriesDto;
|
||||
private readonly PlusSeriesRequestDto _seriesRequestDto;
|
||||
public PlusSeriesRequestDto Build() => _seriesRequestDto;
|
||||
|
||||
/// <summary>
|
||||
/// This must be a FULL Series
|
||||
|
|
@ -18,7 +18,7 @@ public class PlusSeriesDtoBuilder : IEntityBuilder<PlusSeriesDto>
|
|||
/// <param name="series"></param>
|
||||
public PlusSeriesDtoBuilder(Series series)
|
||||
{
|
||||
_seriesDto = new PlusSeriesDto()
|
||||
_seriesRequestDto = new PlusSeriesRequestDto()
|
||||
{
|
||||
MediaFormat = series.Library.Type.ConvertToPlusMediaFormat(series.Format),
|
||||
SeriesName = series.Name,
|
||||
|
|
|
|||
|
|
@ -73,13 +73,19 @@ public static class GenreHelper
|
|||
|
||||
public static void UpdateGenreList(ICollection<GenreTagDto>? existingGenres, Series series,
|
||||
IReadOnlyCollection<Genre> newGenres, Action<Genre> handleAdd, Action onModified)
|
||||
{
|
||||
UpdateGenreList(existingGenres.DefaultIfEmpty().Select(t => t.Title).ToList(), series, newGenres, handleAdd, onModified);
|
||||
}
|
||||
|
||||
public static void UpdateGenreList(ICollection<string>? existingGenres, Series series,
|
||||
IReadOnlyCollection<Genre> newGenres, Action<Genre> handleAdd, Action onModified)
|
||||
{
|
||||
if (existingGenres == null) return;
|
||||
|
||||
var isModified = false;
|
||||
|
||||
// Convert tags and existing genres to hash sets for quick lookups by normalized title
|
||||
var tagSet = new HashSet<string>(existingGenres.Select(t => t.Title.ToNormalized()));
|
||||
var tagSet = new HashSet<string>(existingGenres.Select(t => t.ToNormalized()));
|
||||
var genreSet = new HashSet<string>(series.Metadata.Genres.Select(g => g.NormalizedTitle));
|
||||
|
||||
// Remove tags that are no longer present in the input tags
|
||||
|
|
@ -99,7 +105,7 @@ public static class GenreHelper
|
|||
// Add new tags from the input list
|
||||
foreach (var tagDto in existingGenres)
|
||||
{
|
||||
var normalizedTitle = tagDto.Title.ToNormalized();
|
||||
var normalizedTitle = tagDto.ToNormalized();
|
||||
|
||||
if (genreSet.Contains(normalizedTitle)) continue; // This prevents re-adding existing genres
|
||||
|
||||
|
|
@ -109,7 +115,7 @@ public static class GenreHelper
|
|||
}
|
||||
else
|
||||
{
|
||||
handleAdd(new GenreBuilder(tagDto.Title).Build()); // Add new genre if not found
|
||||
handleAdd(new GenreBuilder(tagDto).Build()); // Add new genre if not found
|
||||
}
|
||||
isModified = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue