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

@ -1,4 +1,5 @@
using System.Collections.Generic;
using API.DTOs.Recommendation;
using API.DTOs.Scrobbling;
using API.DTOs.SeriesDetail;
@ -9,6 +10,7 @@ internal class SeriesDetailPlusApiDto
public IEnumerable<MediaRecommendationDto> Recommendations { get; set; }
public IEnumerable<UserReviewDto> Reviews { get; set; }
public IEnumerable<RatingDto> Ratings { get; set; }
public ExternalSeriesDetailDto? Series { get; set; }
public int? AniListId { get; set; }
public long? MalId { get; set; }
}

View file

@ -1,10 +1,15 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using API.DTOs.KavitaPlus.Metadata;
using API.DTOs.Scrobbling;
using API.Services.Plus;
namespace API.DTOs.Recommendation;
#nullable enable
/// <summary>
/// This is AniListSeries
/// </summary>
public class ExternalSeriesDetailDto
{
public string Name { get; set; }
@ -18,7 +23,15 @@ public class ExternalSeriesDetailDto
public IList<SeriesStaffDto> Staff { get; set; }
public IList<MetadataTagDto> Tags { get; set; }
public string? Summary { get; set; }
public int? VolumeCount { get; set; }
public int? ChapterCount { get; set; }
public ScrobbleProvider Provider { get; set; } = ScrobbleProvider.AniList;
public DateTime? StartDate { get; set; }
public DateTime? EndDate { get; set; }
public int AverageScore { get; set; }
public int Chapters { get; set; }
public int Volumes { get; set; }
public IList<SeriesRelationship>? Relations { get; set; }
public IList<SeriesCharacter>? Characters { get; set; }
}

View file

@ -0,0 +1,22 @@
using API.Entities.Enums;
namespace API.DTOs.KavitaPlus.Metadata;
public class MetadataFieldMappingDto
{
public int Id { get; set; }
public MetadataFieldType SourceType { get; set; }
public MetadataFieldType DestinationType { get; set; }
/// <summary>
/// The string in the source
/// </summary>
public string SourceValue { get; set; }
/// <summary>
/// Write the string as this in the Destination (can also just be the Source)
/// </summary>
public string DestinationValue { get; set; }
/// <summary>
/// If true, the tag will be Moved over vs Copied over
/// </summary>
public bool ExcludeFromSource { get; set; }
}

View file

@ -0,0 +1,70 @@
using System.Collections.Generic;
using API.Entities;
using API.Entities.Enums;
namespace API.DTOs.KavitaPlus.Metadata;
public class MetadataSettingsDto
{
/// <summary>
/// If writing any sort of metadata from upstream (AniList, Hardcover) source is allowed
/// </summary>
public bool Enabled { get; set; }
/// <summary>
/// Allow the Summary to be written
/// </summary>
public bool EnableSummary { get; set; }
/// <summary>
/// Allow Publication status to be derived and updated
/// </summary>
public bool EnablePublicationStatus { get; set; }
/// <summary>
/// Allow Relationships between series to be set
/// </summary>
public bool EnableRelationships { get; set; }
/// <summary>
/// Allow People to be created (including downloading images)
/// </summary>
public bool EnablePeople { get; set; }
/// <summary>
/// Allow Start date to be set within the Series
/// </summary>
public bool EnableStartDate { get; set; }
/// <summary>
/// Allow setting the Localized name
/// </summary>
public bool EnableLocalizedName { get; set; }
// Need to handle the Genre/tags stuff
public bool EnableGenres { get; set; } = true;
public bool EnableTags { get; set; } = true;
/// <summary>
/// For Authors and Writers, how should names be stored (Exclusively applied for AniList). This does not affect Character names.
/// </summary>
public bool FirstLastPeopleNaming { get; set; }
/// <summary>
/// Any Genres or Tags that if present, will trigger an Age Rating Override. Highest rating will be prioritized for matching.
/// </summary>
public Dictionary<string, AgeRating> AgeRatingMappings { get; set; }
/// <summary>
/// A list of rules that allow mapping a genre/tag to another genre/tag
/// </summary>
public List<MetadataFieldMappingDto> FieldMappings { get; set; }
/// <summary>
/// Do not allow any Genre/Tag in this list to be written to Kavita
/// </summary>
public List<string> Blacklist { get; set; }
/// <summary>
/// Only allow these Tags to be written to Kavita
/// </summary>
public List<string> Whitelist { get; set; }
/// <summary>
/// Which Roles to allow metadata downloading for
/// </summary>
public List<PersonRole> PersonRoles { get; set; }
}

View file

@ -0,0 +1,9 @@
namespace API.DTOs.KavitaPlus.Metadata;
public class SeriesCharacter
{
public string Name { get; set; }
public required string Description { get; set; }
public required string Url { get; set; }
public string? ImageUrl { get; set; }
}

View file

@ -0,0 +1,24 @@
using API.DTOs.Scrobbling;
using API.Entities.Enums;
using API.Entities.Metadata;
using API.Services.Plus;
namespace API.DTOs.KavitaPlus.Metadata;
public class ALMediaTitle
{
public string? EnglishTitle { get; set; }
public string RomajiTitle { get; set; }
public string NativeTitle { get; set; }
public string PreferredTitle { get; set; }
}
public class SeriesRelationship
{
public int AniListId { get; set; }
public int? MalId { get; set; }
public ALMediaTitle SeriesName { get; set; }
public RelationKind Relation { get; set; }
public ScrobbleProvider Provider { get; set; }
public PlusMediaFormat PlusMediaFormat { get; set; } = PlusMediaFormat.Manga;
}

View file

@ -61,4 +61,10 @@ public class LibraryDto
/// A set of globs that will exclude matching content from being scanned
/// </summary>
public ICollection<string> ExcludePatterns { get; set; }
/// <summary>
/// Allow any series within this Library to download metadata.
/// </summary>
/// <remarks>This does not exclude the library from being linked to wrt Series Relationships</remarks>
/// <remarks>Requires a valid LicenseKey</remarks>
public bool AllowMetadataMatching { get; set; } = true;
}

View file

@ -4,6 +4,8 @@
public class SeriesStaffDto
{
public required string Name { get; set; }
public string? FirstName { get; set; }
public string? LastName { get; set; }
public required string Url { get; set; }
public required string Role { get; set; }
public string? ImageUrl { get; set; }

View file

@ -1,6 +1,9 @@
namespace API.DTOs.Scrobbling;
public record PlusSeriesDto
/// <summary>
/// Represents information about a potential Series for Kavita+
/// </summary>
public record PlusSeriesRequestDto
{
public int? AniListId { get; set; }
public long? MalId { get; set; }

View file

@ -12,4 +12,5 @@ public class SeriesDetailPlusDto
public RecommendationDto? Recommendations { get; set; }
public IEnumerable<UserReviewDto> Reviews { get; set; }
public IEnumerable<RatingDto>? Ratings { get; set; }
public ExternalSeriesDetailDto? Series { get; set; }
}

View file

@ -26,6 +26,8 @@ public class UpdateLibraryDto
public bool ManageReadingLists { get; init; }
[Required]
public bool AllowScrobbling { get; init; }
[Required]
public bool AllowMetadataMatching { get; init; }
/// <summary>
/// What types of files to allow the scanner to pickup
/// </summary>

View file

@ -175,5 +175,12 @@ public class UserPreferencesDto
[Required]
public PdfSpreadMode PdfSpreadMode { get; set; } = PdfSpreadMode.None;
/// <summary>
/// Kavita+: Should this account have Scrobbling enabled for AniList
/// </summary>
public bool AniListScrobblingEnabled { get; set; }
/// <summary>
/// Kavita+: Should this account have Want to Read Sync enabled
/// </summary>
public bool WantToReadSync { get; set; }
}