Merged develop in

This commit is contained in:
Joseph Milazzo 2025-04-26 16:17:05 -05:00
commit d12a79892f
1443 changed files with 215765 additions and 44113 deletions

View file

@ -29,6 +29,10 @@ public class AppUser : IdentityUser<int>, IHasConcurrencyToken
/// </summary>
public ICollection<ReadingList> ReadingLists { get; set; } = null!;
/// <summary>
/// Collections associated with this user
/// </summary>
public ICollection<AppUserCollection> Collections { get; set; } = null!;
/// <summary>
/// A list of Series the user want's to read
/// </summary>
public ICollection<AppUserWantToRead> WantToRead { get; set; } = null!;
@ -63,6 +67,27 @@ public class AppUser : IdentityUser<int>, IHasConcurrencyToken
/// <remarks>Requires Kavita+ Subscription</remarks>
public string? AniListAccessToken { get; set; }
/// <summary>
/// The Username of the MAL user
/// </summary>
public string? MalUserName { get; set; }
/// <summary>
/// The Client ID for the user's MAL account. User should create a client on MAL for this.
/// </summary>
public string? MalAccessToken { get; set; }
/// <summary>
/// Has the user ran Scrobble Event Generation
/// </summary>
/// <remarks>Only applicable for Kavita+ and when a Token is present</remarks>
public bool HasRunScrobbleEventGeneration { get; set; }
/// <summary>
/// The timestamp of when Scrobble Event Generation ran (Utc)
/// </summary>
/// <remarks>Kavita+ only</remarks>
public DateTime ScrobbleEventGenerationRan { get; set; }
/// <summary>
/// A list of Series the user doesn't want scrobbling for
/// </summary>

View file

@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using API.Entities.Enums;
using API.Entities.Interfaces;
using API.Services.Plus;
namespace API.Entities;
/// <summary>
/// Represents a Collection of Series for a given User
/// </summary>
public class AppUserCollection : IEntityDate, IHasCoverImage
{
public int Id { get; set; }
public required string Title { get; set; }
/// <summary>
/// A normalized string used to check if the collection already exists in the DB
/// </summary>
public required string NormalizedTitle { get; set; }
public string? Summary { get; set; }
/// <summary>
/// Reading lists that are promoted are only done by admins
/// </summary>
public bool Promoted { get; set; }
public string? CoverImage { get; set; }
public string PrimaryColor { get; set; }
public string SecondaryColor { get; set; }
public bool CoverImageLocked { get; set; }
/// <summary>
/// The highest age rating from all Series within the collection
/// </summary>
public required AgeRating AgeRating { get; set; } = AgeRating.Unknown;
public ICollection<Series> Items { get; set; } = null!;
public DateTime Created { get; set; }
public DateTime LastModified { get; set; }
public DateTime CreatedUtc { get; set; }
public DateTime LastModifiedUtc { get; set; }
// Sync stuff for Kavita+
/// <summary>
/// Last time Kavita Synced the Collection with an upstream source (for non Kavita sourced collections)
/// </summary>
public DateTime LastSyncUtc { get; set; }
/// <summary>
/// Who created/manages the list. Non-Kavita lists are not editable by the user, except to promote
/// </summary>
public ScrobbleProvider Source { get; set; } = ScrobbleProvider.Kavita;
/// <summary>
/// For Non-Kavita sourced collections, the url to sync from
/// </summary>
public string? SourceUrl { get; set; }
/// <summary>
/// Total number of items as of the last sync. Not applicable for Kavita managed collections.
/// </summary>
public int TotalSourceCount { get; set; }
/// <summary>
/// A <br/> separated string of all missing series
/// </summary>
public string? MissingSeriesFromSource { get; set; }
public void ResetColorScape()
{
PrimaryColor = string.Empty;
SecondaryColor = string.Empty;
}
// Relationship
public AppUser AppUser { get; set; } = null!;
public int AppUserId { get; set; }
}

View file

@ -7,6 +7,9 @@ namespace API.Entities;
public class AppUserPreferences
{
public int Id { get; set; }
#region MangaReader
/// <summary>
/// Manga Reader Option: What direction should the next/prev page buttons go
/// </summary>
@ -51,6 +54,15 @@ public class AppUserPreferences
/// Manga Reader Option: Should swiping trigger pagination
/// </summary>
public bool SwipeToPaginate { get; set; }
/// <summary>
/// Manga Reader Option: Allow Automatic Webtoon detection
/// </summary>
public bool AllowAutomaticWebtoonReaderDetection { get; set; }
#endregion
#region EpubReader
/// <summary>
/// Book Reader Option: Override extra Margin
/// </summary>
@ -75,17 +87,11 @@ public class AppUserPreferences
/// Book Reader Option: What direction should the next/prev page buttons go
/// </summary>
public ReadingDirection BookReaderReadingDirection { get; set; } = ReadingDirection.LeftToRight;
/// <summary>
/// Book Reader Option: Defines the writing styles vertical/horizontal
/// </summary>
public WritingStyle BookReaderWritingStyle { get; set; } = WritingStyle.Horizontal;
/// <summary>
/// UI Site Global Setting: The UI theme the user should use.
/// </summary>
/// <remarks>Should default to Dark</remarks>
public required SiteTheme Theme { get; set; } = Seed.DefaultThemes[0];
/// <summary>
/// Book Reader Option: The color theme to decorate the book contents
/// </summary>
/// <remarks>Should default to Dark</remarks>
@ -101,6 +107,33 @@ public class AppUserPreferences
/// </summary>
/// <remarks>Defaults to false</remarks>
public bool BookReaderImmersiveMode { get; set; } = false;
#endregion
#region PdfReader
/// <summary>
/// PDF Reader: Theme of the Reader
/// </summary>
public PdfTheme PdfTheme { get; set; } = PdfTheme.Dark;
/// <summary>
/// PDF Reader: Scroll mode of the reader
/// </summary>
public PdfScrollMode PdfScrollMode { get; set; } = PdfScrollMode.Vertical;
/// <summary>
/// PDF Reader: Spread Mode of the reader
/// </summary>
public PdfSpreadMode PdfSpreadMode { get; set; } = PdfSpreadMode.None;
#endregion
#region Global
/// <summary>
/// UI Site Global Setting: The UI theme the user should use.
/// </summary>
/// <remarks>Should default to Dark</remarks>
public required SiteTheme Theme { get; set; } = Seed.DefaultThemes[0];
/// <summary>
/// Global Site Option: If the UI should layout items as Cards or List items
/// </summary>
@ -131,6 +164,18 @@ public class AppUserPreferences
/// UI Site Global Setting: The language locale that should be used for the user
/// </summary>
public string Locale { get; set; }
#endregion
#region KavitaPlus
/// <summary>
/// Should this account have Scrobbling enabled for AniList
/// </summary>
public bool AniListScrobblingEnabled { get; set; }
/// <summary>
/// Should this account have Want to Read Sync enabled
/// </summary>
public bool WantToReadSync { get; set; }
#endregion
public AppUser AppUser { get; set; } = null!;
public int AppUserId { get; set; }

View file

@ -59,4 +59,10 @@ public class AppUserProgress : IEntityDate
/// User this progress belongs to
/// </summary>
public int AppUserId { get; set; }
public void MarkModified()
{
LastModified = DateTime.Now;
LastModifiedUtc = DateTime.UtcNow;
}
}

View file

@ -1,4 +1,6 @@

using System;
namespace API.Entities;
#nullable enable
public class AppUserRating
@ -9,7 +11,7 @@ public class AppUserRating
/// </summary>
public float Rating { get; set; }
/// <summary>
/// If the rating has been explicitly set. Otherwise the 0.0 rating should be ignored as it's not rated
/// If the rating has been explicitly set. Otherwise, the 0.0 rating should be ignored as it's not rated
/// </summary>
public bool HasBeenRated { get; set; }
/// <summary>
@ -19,6 +21,7 @@ public class AppUserRating
/// <summary>
/// An optional tagline for the review
/// </summary>
[Obsolete("No longer used")]
public string? Tagline { get; set; }
public int SeriesId { get; set; }
public Series Series { get; set; } = null!;

View file

@ -1,23 +1,43 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using API.Entities.Enums;
using API.Entities.Interfaces;
using API.Entities.Person;
using API.Extensions;
using API.Services.Tasks.Scanner.Parser;
namespace API.Entities;
public class Chapter : IEntityDate, IHasReadTimeEstimate
public class Chapter : IEntityDate, IHasReadTimeEstimate, IHasCoverImage
{
public int Id { get; set; }
/// <summary>
/// Range of numbers. Chapter 2-4 -> "2-4". Chapter 2 -> "2".
/// Range of numbers. Chapter 2-4 -> "2-4". Chapter 2 -> "2". If the chapter is a special, will return the Special Name
/// </summary>
public required string Range { get; set; }
/// <summary>
/// Smallest number of the Range. Can be a partial like Chapter 4.5
/// </summary>
[Obsolete("Use MinNumber and MaxNumber instead")]
public required string Number { get; set; }
/// <summary>
/// Minimum Chapter Number.
/// </summary>
public float MinNumber { get; set; }
/// <summary>
/// Maximum Chapter Number
/// </summary>
public float MaxNumber { get; set; }
/// <summary>
/// The sorting order of the Chapter. Inherits from MinNumber, but can be overridden.
/// </summary>
public float SortOrder { get; set; }
/// <summary>
/// Can the sort order be updated on scan or is it locked from UI
/// </summary>
public bool SortOrderLocked { get; set; }
/// <summary>
/// The files that represent this Chapter
/// </summary>
public ICollection<MangaFile> Files { get; set; } = null!;
@ -26,11 +46,9 @@ public class Chapter : IEntityDate, IHasReadTimeEstimate
public DateTime CreatedUtc { get; set; }
public DateTime LastModifiedUtc { get; set; }
/// <summary>
/// Relative path to the (managed) image file representing the cover image
/// </summary>
/// <remarks>The file is managed internally to Kavita's APPDIR</remarks>
public string? CoverImage { get; set; }
public string PrimaryColor { get; set; }
public string SecondaryColor { get; set; }
public bool CoverImageLocked { get; set; }
/// <summary>
/// Total number of pages in all MangaFiles
@ -44,6 +62,7 @@ public class Chapter : IEntityDate, IHasReadTimeEstimate
/// Used for books/specials to display custom title. For non-specials/books, will be set to <see cref="Range"/>
/// </summary>
public string? Title { get; set; }
/// <summary>
/// Age Rating for the issue/chapter
/// </summary>
@ -99,17 +118,43 @@ public class Chapter : IEntityDate, IHasReadTimeEstimate
/// <inheritdoc cref="IHasReadTimeEstimate"/>
public int MaxHoursToRead { get; set; }
/// <inheritdoc cref="IHasReadTimeEstimate"/>
public int AvgHoursToRead { get; set; }
public float AvgHoursToRead { get; set; }
/// <summary>
/// Comma-separated link of urls to external services that have some relation to the Chapter
/// </summary>
public string WebLinks { get; set; } = string.Empty;
public string ISBN { get; set; } = string.Empty;
#region Locks
public bool AgeRatingLocked { get; set; }
public bool TitleNameLocked { get; set; }
public bool GenresLocked { get; set; }
public bool TagsLocked { get; set; }
public bool WriterLocked { get; set; }
public bool CharacterLocked { get; set; }
public bool ColoristLocked { get; set; }
public bool EditorLocked { get; set; }
public bool InkerLocked { get; set; }
public bool ImprintLocked { get; set; }
public bool LettererLocked { get; set; }
public bool PencillerLocked { get; set; }
public bool PublisherLocked { get; set; }
public bool TranslatorLocked { get; set; }
public bool TeamLocked { get; set; }
public bool LocationLocked { get; set; }
public bool CoverArtistLocked { get; set; }
public bool LanguageLocked { get; set; }
public bool SummaryLocked { get; set; }
public bool ISBNLocked { get; set; }
public bool ReleaseDateLocked { get; set; }
#endregion
/// <summary>
/// All people attached at a Chapter level. Usually Comics will have different people per issue.
/// </summary>
public ICollection<Person> People { get; set; } = new List<Person>();
public ICollection<ChapterPeople> People { get; set; } = new List<ChapterPeople>();
/// <summary>
/// Genres for the Chapter
/// </summary>
@ -129,11 +174,85 @@ public class Chapter : IEntityDate, IHasReadTimeEstimate
IsSpecial = info.IsSpecialInfo();
if (IsSpecial)
{
Number = "0";
Number = Parser.DefaultChapter;
MinNumber = Parser.DefaultChapterNumber;
MaxNumber = Parser.DefaultChapterNumber;
}
Title = (IsSpecial && info.Format == MangaFormat.Epub)
Title = (IsSpecial && info.Format is MangaFormat.Epub or MangaFormat.Pdf)
? info.Title
: Range;
: Parser.RemoveExtensionIfSupported(Range);
var specialTreatment = info.IsSpecialInfo();
Range = specialTreatment ? info.Filename : info.Chapters;
}
/// <summary>
/// Returns the Chapter Number. If the chapter is a range, returns that, formatted.
/// </summary>
/// <returns></returns>
public string GetNumberTitle()
{
// BUG: TODO: On non-english locales, for floats, the range will be 20,5 but the NumberTitle will return 20.5
// Have I fixed this with TryParse CultureInvariant
try
{
if (MinNumber.Is(MaxNumber))
{
if (MinNumber.Is(Parser.DefaultChapterNumber) && IsSpecial)
{
return Parser.RemoveExtensionIfSupported(Title);
}
if (MinNumber.Is(0f) && !float.TryParse(Range, CultureInfo.InvariantCulture, out _))
{
return $"{Range.ToString(CultureInfo.InvariantCulture)}";
}
return $"{MinNumber.ToString(CultureInfo.InvariantCulture)}";
}
return $"{MinNumber.ToString(CultureInfo.InvariantCulture)}-{MaxNumber.ToString(CultureInfo.InvariantCulture)}";
}
catch (Exception)
{
return MinNumber.ToString(CultureInfo.InvariantCulture);
}
}
/// <summary>
/// Is the Chapter representing a single Volume (volume 1.cbz). If so, Min/Max will be Default and will not be special
/// </summary>
/// <returns></returns>
public bool IsSingleVolumeChapter()
{
return MinNumber.Is(Parser.DefaultChapterNumber) && !IsSpecial;
}
public void ResetColorScape()
{
PrimaryColor = string.Empty;
SecondaryColor = string.Empty;
}
public bool IsPersonRoleLocked(PersonRole role)
{
return role switch
{
PersonRole.Character => CharacterLocked,
PersonRole.Writer => WriterLocked,
PersonRole.Penciller => PencillerLocked,
PersonRole.Inker => InkerLocked,
PersonRole.Colorist => ColoristLocked,
PersonRole.Letterer => LettererLocked,
PersonRole.CoverArtist => CoverArtistLocked,
PersonRole.Editor => EditorLocked,
PersonRole.Publisher => PublisherLocked,
PersonRole.Translator => TranslatorLocked,
PersonRole.Imprint => ImprintLocked,
PersonRole.Team => TeamLocked,
PersonRole.Location => LocationLocked,
_ => throw new ArgumentOutOfRangeException(nameof(role), role, null)
};
}
}

View file

@ -1,5 +1,7 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using API.Entities.Metadata;
using API.Services.Plus;
using Microsoft.EntityFrameworkCore;
namespace API.Entities;
@ -7,6 +9,7 @@ namespace API.Entities;
/// <summary>
/// Represents a user entered field that is used as a tagging and grouping mechanism
/// </summary>
[Obsolete("Use AppUserCollection instead")]
[Index(nameof(Id), nameof(Promoted), IsUnique = true)]
public class CollectionTag
{
@ -41,6 +44,21 @@ public class CollectionTag
public ICollection<SeriesMetadata> SeriesMetadatas { get; set; } = null!;
/// <summary>
/// Is this Collection tag managed by another system, like Kavita+
/// </summary>
//public bool IsManaged { get; set; } = false;
/// <summary>
/// The last time this Collection was Synchronized. Only applicable for Managed Tags.
/// </summary>
//public DateTime LastSynchronized { get; set; }
/// <summary>
/// Who created this Collection (Kavita, or external services)
/// </summary>
//public ScrobbleProvider Provider { get; set; } = ScrobbleProvider.Kavita;
/// <summary>
/// Not Used due to not using concurrency update
/// </summary>

View file

@ -0,0 +1,31 @@
using System;
using API.Entities.Interfaces;
using Microsoft.EntityFrameworkCore;
namespace API.Entities;
/// <summary>
/// Records all emails that are sent from Kavita
/// </summary>
[Index("Sent", "AppUserId", "EmailTemplate", "SendDate")]
public class EmailHistory : IEntityDate
{
public long Id { get; set; }
public bool Sent { get; set; }
public DateTime SendDate { get; set; } = DateTime.UtcNow;
public string EmailTemplate { get; set; }
public string Subject { get; set; }
public string Body { get; set; }
public string DeliveryStatus { get; set; }
public string ErrorMessage { get; set; }
public int AppUserId { get; set; }
public virtual AppUser AppUser { get; set; }
public DateTime Created { get; set; }
public DateTime CreatedUtc { get; set; }
public DateTime LastModified { get; set; }
public DateTime LastModifiedUtc { get; set; }
}

View file

@ -15,5 +15,4 @@ public enum FileTypeGroup
Pdf = 3,
[Description("Images")]
Images = 4
}

View file

@ -12,7 +12,7 @@ public enum LibraryType
/// <summary>
/// Uses Comic regex for filename parsing
/// </summary>
[Description("Comic")]
[Description("Comic (Legacy)")]
Comic = 1,
/// <summary>
/// Uses Manga regex for filename parsing also uses epub metadata
@ -30,8 +30,13 @@ public enum LibraryType
[Description("Light Novel")]
LightNovel = 4,
/// <summary>
/// Uses Comic regex for filename parsing, uses Comic Vine type of Parsing
/// </summary>
[Description("Comic")]
ComicVine = 5,
/// <summary>
/// Uses Magazine regex and is restricted to PDF and Archive by default
/// </summary>
[Description("Magazine")]
Magazine = 5
Magazine = 6
}

View file

@ -0,0 +1,7 @@
namespace API.Entities.Enums;
public enum MetadataFieldType
{
Genre = 0,
Tag = 1,
}

View file

@ -24,7 +24,11 @@ public enum PersonRole
/// <summary>
/// The Translator
/// </summary>
Translator = 12
Translator = 12,
/// <summary>
/// The publisher before another Publisher bought
/// </summary>
Imprint = 13,
Team = 14,
Location = 15
}

View file

@ -71,6 +71,11 @@ public enum RelationKind
/// Same story, could be translation, colorization... Different edition of the series
/// </summary>
[Description("Edition")]
Edition = 13
Edition = 13,
/// <summary>
/// The target series is an annual of the Series
/// </summary>
[Description("Annual")]
Annual = 14
}

View file

@ -186,5 +186,15 @@ public enum ServerSettingKey
/// When the cleanup task should run - Critical to keeping Kavita working
/// </summary>
[Description("TaskCleanup")]
TaskCleanup = 37
TaskCleanup = 37,
/// <summary>
/// The Date Kavita was first installed
/// </summary>
[Description("FirstInstallDate")]
FirstInstallDate = 38,
/// <summary>
/// The Version of Kavita on the first run
/// </summary>
[Description("FirstInstallVersion")]
FirstInstallVersion = 39,
}

View file

@ -10,8 +10,8 @@ public enum ThemeProvider
[Description("System")]
System = 1,
/// <summary>
/// Theme is provided by the User (ie it's custom)
/// Theme is provided by the User (ie it's custom) or Downloaded via Themes Repo
/// </summary>
[Description("User")]
User = 2
[Description("Custom")]
Custom = 2,
}

View file

@ -0,0 +1,21 @@
using System.ComponentModel;
namespace API.Entities.Enums.UserPreferences;
public enum PdfLayoutMode
{
/// <summary>
/// Multiple pages render stacked (normal pdf experience)
/// </summary>
[Description("Multiple")]
Multiple = 0,
// [Description("Single")]
// Single = 1,
/// <summary>
/// A book mode where page turns are animated and layout is side-by-side
/// </summary>
[Description("Book")]
Book = 2,
// [Description("Infinite Scroll")]
// InfiniteScroll = 3
}

View file

@ -0,0 +1,21 @@
using System.ComponentModel;
namespace API.Entities.Enums.UserPreferences;
/// <summary>
/// Enum values match PdfViewer's enums
/// </summary>
public enum PdfScrollMode
{
[Description("Vertical")]
Vertical = 0,
[Description("Horizontal")]
Horizontal = 1,
// [Description("Wrapped")]
// Wrapped = 2,
/// <summary>
/// Single page view (tap to pagninate)
/// </summary>
[Description("Page")]
Page = 3
}

View file

@ -0,0 +1,13 @@
using System.ComponentModel;
namespace API.Entities.Enums.UserPreferences;
public enum PdfSpreadMode
{
[Description("None")]
None = 0,
[Description("Odd")]
Odd = 1,
[Description("Even")]
Even = 2
}

View file

@ -0,0 +1,11 @@
using System.ComponentModel;
namespace API.Entities.Enums.UserPreferences;
public enum PdfTheme
{
[Description("Dark")]
Dark = 0,
[Description("Light")]
Light = 1
}

View file

@ -0,0 +1,9 @@
namespace API.Entities.History;
/// <summary>
/// Records history of actions Kavita+ takes
/// </summary>
// public class KavitaPlusHistory
// {
//
// }

View file

@ -1,6 +1,6 @@
using System;
namespace API.Entities;
namespace API.Entities.History;
/// <summary>
/// This will track manual migrations so that I can use simple selects to check if a Manual Migration is needed

View file

@ -0,0 +1,26 @@
namespace API.Entities.Interfaces;
#nullable enable
public interface IHasCoverImage
{
/// <summary>
/// Absolute path to the (managed) image file
/// </summary>
/// <remarks>The file is managed internally to Kavita's APPDIR</remarks>
public string? CoverImage { get; set; }
/// <summary>
/// Primary color derived from the Cover Image
/// </summary>
public string? PrimaryColor { get; set; }
/// <summary>
/// Secondary color derived from the Cover Image
/// </summary>
public string? SecondaryColor { get; set; }
/// <summary>
/// Nulls out the ColorScape properties
/// </summary>
void ResetColorScape();
}

View file

@ -21,5 +21,5 @@ public interface IHasReadTimeEstimate
/// Average hours to read the chapter
/// </summary>
/// <remarks>Uses a fixed number to calculate from <see cref="ReaderService"/></remarks>
public int AvgHoursToRead { get; set; }
public float AvgHoursToRead { get; set; }
}

View file

@ -5,11 +5,13 @@ using API.Entities.Interfaces;
namespace API.Entities;
public class Library : IEntityDate
public class Library : IEntityDate, IHasCoverImage
{
public int Id { get; set; }
public required string Name { get; set; }
public string? CoverImage { get; set; }
public string PrimaryColor { get; set; }
public string SecondaryColor { get; set; }
public LibraryType Type { get; set; }
/// <summary>
/// If Folder Watching is enabled for this library
@ -38,11 +40,14 @@ public class Library : IEntityDate
/// <summary>
/// Should this library allow Scrobble events to emit from it
/// </summary>
/// <remarks>Scrobbling requires a valid LicenseKey</remarks>
/// <remarks>Requires a valid LicenseKey</remarks>
public bool AllowScrobbling { get; set; } = true;
/// <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;
public DateTime Created { get; set; }
@ -78,4 +83,10 @@ public class Library : IEntityDate
LastScanned = (DateTime) time;
}
}
public void ResetColorScape()
{
PrimaryColor = string.Empty;
SecondaryColor = string.Empty;
}
}

View file

@ -13,6 +13,10 @@ public class MangaFile : IEntityDate
{
public int Id { get; set; }
/// <summary>
/// The filename without extension
/// </summary>
public string FileName { get; set; }
/// <summary>
/// Absolute path to the archive file
/// </summary>
public required string FilePath { get; set; }

View file

@ -21,11 +21,12 @@ public class ExternalSeriesMetadata
public ICollection<ExternalRecommendation> ExternalRecommendations { get; set; } = null!;
/// <summary>
/// Average External Rating. -1 means not set
/// Average External Rating. -1 means not set, 0 - 100
/// </summary>
public int AverageExternalRating { get; set; } = 0;
public int AverageExternalRating { get; set; } = -1;
public int AniListId { get; set; }
public int CbrId { get; set; }
public long MalId { get; set; }
public string GoogleBooksId { get; set; }

View file

@ -5,10 +5,12 @@ namespace API.Entities.Metadata;
/// <summary>
/// A blacklist of Series for Kavita+
/// </summary>
[Obsolete("Kavita v0.8.5 moved the implementation to Series.IsBlacklisted")]
public class SeriesBlacklist
{
public int Id { get; set; }
public DateTime LastChecked { get; set; } = DateTime.UtcNow;
public int SeriesId { get; set; }
public Series Series { get; set; }
public DateTime LastChecked { get; set; } = DateTime.UtcNow;
}

View file

@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using API.Entities.Enums;
using API.Entities.Interfaces;
using API.Entities.Person;
using Microsoft.EntityFrameworkCore;
namespace API.Entities.Metadata;
@ -14,15 +16,6 @@ public class SeriesMetadata : IHasConcurrencyToken
public string Summary { get; set; } = string.Empty;
public ICollection<CollectionTag> CollectionTags { get; set; } = new List<CollectionTag>();
public ICollection<Genre> Genres { get; set; } = new List<Genre>();
public ICollection<Tag> Tags { get; set; } = new List<Tag>();
/// <summary>
/// All people attached at a Series level.
/// </summary>
public ICollection<Person> People { get; set; } = new List<Person>();
/// <summary>
/// Highest Age Rating from all Chapters
/// </summary>
@ -50,7 +43,8 @@ public class SeriesMetadata : IHasConcurrencyToken
/// <remarks>This is not populated from Chapters of the Series</remarks>
public string WebLinks { get; set; } = string.Empty;
// Locks
#region Locks
public bool LanguageLocked { get; set; }
public bool SummaryLocked { get; set; }
/// <summary>
@ -68,17 +62,36 @@ public class SeriesMetadata : IHasConcurrencyToken
public bool ColoristLocked { get; set; }
public bool EditorLocked { get; set; }
public bool InkerLocked { get; set; }
public bool ImprintLocked { get; set; }
public bool LettererLocked { get; set; }
public bool PencillerLocked { get; set; }
public bool PublisherLocked { get; set; }
public bool TranslatorLocked { get; set; }
public bool TeamLocked { get; set; }
public bool LocationLocked { get; set; }
public bool CoverArtistLocked { get; set; }
public bool ReleaseYearLocked { get; set; }
#endregion
#region Relationships
[Obsolete("Use AppUserCollection instead")]
public ICollection<CollectionTag> CollectionTags { get; set; } = new List<CollectionTag>();
public ICollection<Genre> Genres { get; set; } = new List<Genre>();
public ICollection<Tag> Tags { get; set; } = new List<Tag>();
/// <summary>
/// All people attached at a Series level.
/// </summary>
public ICollection<SeriesMetadataPeople> People { get; set; } = new List<SeriesMetadataPeople>();
// Relationship
public Series Series { get; set; } = null!;
public int SeriesId { get; set; }
public Series Series { get; set; } = null!;
#endregion
/// <inheritdoc />
[ConcurrencyCheck]
@ -90,4 +103,26 @@ public class SeriesMetadata : IHasConcurrencyToken
{
RowVersion++;
}
/// <summary>
/// Any People in this Role present
/// </summary>
/// <param name="role"></param>
/// <returns></returns>
public bool AnyOfRole(PersonRole role)
{
return People.Any(p => p.Role == role);
}
/// <summary>
/// Are all instances of the role from Kavita+
/// </summary>
/// <param name="role"></param>
/// <returns></returns>
public bool AllKavitaPlus(PersonRole role)
{
var people = People.Where(p => p.Role == role);
if (people.Any()) return people.All(p => p.KavitaPlusConnection);
return false;
}
}

View file

@ -0,0 +1,26 @@
using API.Entities.Enums;
using API.Entities.MetadataMatching;
namespace API.Entities;
public class MetadataFieldMapping
{
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; }
public int MetadataSettingsId { get; set; }
public virtual MetadataSettings MetadataSettings { get; set; }
}

View file

@ -0,0 +1,31 @@
namespace API.Entities.MetadataMatching;
/// <summary>
/// Represents which field that can be written to as an override when already locked
/// </summary>
public enum MetadataSettingField
{
#region Series Metadata
Summary = 1,
PublicationStatus = 2,
StartDate = 3,
Genres = 4,
Tags = 5,
LocalizedName = 6,
Covers = 7,
AgeRating = 8,
People = 9,
#endregion
#region Chapter Metadata
ChapterTitle = 10,
ChapterSummary = 11,
ChapterReleaseDate = 12,
ChapterPublisher = 13,
ChapterCovers = 14,
#endregion
}

View file

@ -0,0 +1,110 @@
using System.Collections.Generic;
using API.Entities.Enums;
namespace API.Entities.MetadataMatching;
/// <summary>
/// Handles the metadata settings for Kavita+
/// </summary>
public class MetadataSettings
{
public int Id { get; set; }
/// <summary>
/// If writing any sort of metadata from upstream (AniList, Hardcover) source is allowed
/// </summary>
public bool Enabled { get; set; }
#region Series Metadata
/// <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; }
/// <summary>
/// Allow setting the cover image
/// </summary>
public bool EnableCoverImage { get; set; }
#endregion
#region Chapter Metadata
/// <summary>
/// Allow Summary to be set within Chapter/Issue
/// </summary>
public bool EnableChapterSummary { get; set; }
/// <summary>
/// Allow Release Date to be set within Chapter/Issue
/// </summary>
public bool EnableChapterReleaseDate { get; set; }
/// <summary>
/// Allow Title to be set within Chapter/Issue
/// </summary>
public bool EnableChapterTitle { get; set; }
/// <summary>
/// Allow Publisher to be set within Chapter/Issue
/// </summary>
public bool EnableChapterPublisher { get; set; }
/// <summary>
/// Allow setting the cover image for the Chapter/Issue
/// </summary>
public bool EnableChapterCoverImage { get; set; }
#endregion
// 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<MetadataFieldMapping> FieldMappings { get; set; }
/// <summary>
/// A list of overrides that will enable writing to locked fields
/// </summary>
public List<MetadataSettingField> Overrides { 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

@ -1,17 +0,0 @@
using System.Collections.Generic;
using API.Entities.Enums;
using API.Entities.Metadata;
namespace API.Entities;
public class Person
{
public int Id { get; set; }
public required string Name { get; set; }
public required string NormalizedName { get; set; }
public required PersonRole Role { get; set; }
// Relationships
public ICollection<SeriesMetadata> SeriesMetadatas { get; set; } = null!;
public ICollection<Chapter> ChapterMetadatas { get; set; } = null!;
}

View file

@ -0,0 +1,23 @@
using API.Entities.Enums;
namespace API.Entities.Person;
public class ChapterPeople
{
public int ChapterId { get; set; }
public virtual Chapter Chapter { get; set; }
public int PersonId { get; set; }
public virtual Person Person { get; set; }
/// <summary>
/// The source of this connection. If not Kavita, this implies Metadata Download linked this and it can be removed between matches
/// </summary>
public bool KavitaPlusConnection { get; set; }
/// <summary>
/// A weight that allows lower numbers to sort first
/// </summary>
public int OrderWeight { get; set; }
public required PersonRole Role { get; set; }
}

View file

@ -0,0 +1,59 @@
using System.Collections.Generic;
using API.Entities.Interfaces;
namespace API.Entities.Person;
public class Person : IHasCoverImage
{
public int Id { get; set; }
public required string Name { get; set; }
public required string NormalizedName { get; set; }
//public ICollection<PersonAlias> Aliases { get; set; } = default!;
public string? CoverImage { get; set; }
public bool CoverImageLocked { get; set; }
public string PrimaryColor { get; set; }
public string SecondaryColor { get; set; }
public string Description { get; set; }
/// <summary>
/// ASIN for person
/// </summary>
/// <remarks>Can be used for Amazon author lookup</remarks>
public string? Asin { get; set; }
/// <summary>
/// https://anilist.co/staff/{AniListId}/
/// </summary>
/// <remarks>Kavita+ Only</remarks>
public int AniListId { get; set; } = 0;
/// <summary>
/// https://myanimelist.net/people/{MalId}/
/// https://myanimelist.net/character/{MalId}/CharacterName
/// </summary>
/// <remarks>Kavita+ Only</remarks>
public long MalId { get; set; } = 0;
/// <summary>
/// https://hardcover.app/authors/{HardcoverId}
/// </summary>
/// <remarks>Kavita+ Only</remarks>
public string? HardcoverId { get; set; }
/// <summary>
/// https://metron.cloud/creator/{slug}/
/// </summary>
/// <remarks>Kavita+ Only</remarks>
//public long MetronId { get; set; } = 0;
// Relationships
public ICollection<ChapterPeople> ChapterPeople { get; set; } = new List<ChapterPeople>();
public ICollection<SeriesMetadataPeople> SeriesMetadataPeople { get; set; } = new List<SeriesMetadataPeople>();
public void ResetColorScape()
{
PrimaryColor = string.Empty;
SecondaryColor = string.Empty;
}
}

View file

@ -0,0 +1,24 @@
using API.Entities.Enums;
using API.Entities.Metadata;
namespace API.Entities.Person;
public class SeriesMetadataPeople
{
public int SeriesMetadataId { get; set; }
public virtual SeriesMetadata SeriesMetadata { get; set; }
public int PersonId { get; set; }
public virtual Person Person { get; set; }
/// <summary>
/// The source of this connection. If not Kavita, this implies Metadata Download linked this and it can be removed between matches
/// </summary>
public bool KavitaPlusConnection { get; set; } = false;
/// <summary>
/// A weight that allows lower numbers to sort first
/// </summary>
public int OrderWeight { get; set; }
public required PersonRole Role { get; set; }
}

View file

@ -10,7 +10,7 @@ namespace API.Entities;
/// <summary>
/// This is a collection of <see cref="ReadingListItem"/> which represent individual chapters and an order.
/// </summary>
public class ReadingList : IEntityDate
public class ReadingList : IEntityDate, IHasCoverImage
{
public int Id { get; init; }
public required string Title { get; set; }
@ -23,11 +23,9 @@ public class ReadingList : IEntityDate
/// Reading lists that are promoted are only done by admins
/// </summary>
public bool Promoted { get; set; }
/// <summary>
/// Absolute path to the (managed) image file
/// </summary>
/// <remarks>The file is managed internally to Kavita's APPDIR</remarks>
public string? CoverImage { get; set; }
public string? PrimaryColor { get; set; }
public string? SecondaryColor { get; set; }
public bool CoverImageLocked { get; set; }
/// <summary>
@ -61,4 +59,10 @@ public class ReadingList : IEntityDate
// Relationships
public int AppUserId { get; set; }
public AppUser AppUser { get; set; } = null!;
public void ResetColorScape()
{
PrimaryColor = string.Empty;
SecondaryColor = string.Empty;
}
}

View file

@ -28,7 +28,7 @@ public class ScrobbleEvent : IEntityDate
/// </summary>
public string? ReviewBody { get; set; }
public string? ReviewTitle { get; set; }
public required MediaFormat Format { get; set; }
public required PlusMediaFormat Format { get; set; }
/// <summary>
/// Depends on the ScrobbleEvent if filled in
/// </summary>

View file

@ -7,5 +7,6 @@ public enum ScrobbleEventSortField
LastModified = 2,
Type= 3,
Series = 4,
IsProcessed = 5
IsProcessed = 5,
ScrobbleEventFilter = 6
}

View file

@ -6,7 +6,7 @@ using API.Entities.Metadata;
namespace API.Entities;
public class Series : IEntityDate, IHasReadTimeEstimate
public class Series : IEntityDate, IHasReadTimeEstimate, IHasCoverImage
{
public int Id { get; set; }
/// <summary>
@ -38,7 +38,7 @@ public class Series : IEntityDate, IHasReadTimeEstimate
/// </summary>
public DateTime Created { get; set; }
/// <summary>
/// Whenever a modification occurs. Ie) New volumes, removed volumes, title update, etc
/// Whenever a modification occurs. ex: New volumes, removed volumes, title update, etc
/// </summary>
public DateTime LastModified { get; set; }
@ -64,6 +64,11 @@ public class Series : IEntityDate, IHasReadTimeEstimate
/// <remarks><see cref="Services.Tasks.Scanner.Parser.Parser.NormalizePath"/> must be used before setting</remarks>
public string? FolderPath { get; set; }
/// <summary>
/// Lowest path (that is under library root) that contains all files for the series.
/// </summary>
/// <remarks><see cref="Services.Tasks.Scanner.Parser.Parser.NormalizePath"/> must be used before setting</remarks>
public string? LowestFolderPath { get; set; }
/// <summary>
/// Last time the folder was scanned
/// </summary>
public DateTime LastFolderScanned { get; set; }
@ -76,6 +81,9 @@ public class Series : IEntityDate, IHasReadTimeEstimate
/// </summary>
public MangaFormat Format { get; set; } = MangaFormat.Unknown;
public string PrimaryColor { get; set; } = string.Empty;
public string SecondaryColor { get; set; } = string.Empty;
public bool SortNameLocked { get; set; }
public bool LocalizedNameLocked { get; set; }
@ -93,13 +101,25 @@ public class Series : IEntityDate, IHasReadTimeEstimate
public int MinHoursToRead { get; set; }
public int MaxHoursToRead { get; set; }
public int AvgHoursToRead { get; set; }
public float AvgHoursToRead { get; set; }
#region KavitaPlus
/// <summary>
/// Do not match the series with any external Metadata service. This will automatically opt it out of scrobbling.
/// </summary>
public bool DontMatch { get; set; }
/// <summary>
/// If the series was unable to match, it will be blacklisted until a manual metadata match overrides it
/// </summary>
public bool IsBlacklisted { get; set; }
#endregion
public SeriesMetadata Metadata { get; set; } = null!;
public ExternalSeriesMetadata ExternalSeriesMetadata { get; set; } = null!;
public ICollection<AppUserRating> Ratings { get; set; } = null!;
public ICollection<AppUserProgress> Progress { get; set; } = null!;
public ICollection<AppUserCollection> Collections { get; set; } = null!;
/// <summary>
/// Relations to other Series, like Sequels, Prequels, etc
@ -109,6 +129,8 @@ public class Series : IEntityDate, IHasReadTimeEstimate
public ICollection<SeriesRelation> RelationOf { get; set; } = null!;
// Relationships
public List<Volume> Volumes { get; set; } = null!;
public Library Library { get; set; } = null!;
@ -126,4 +148,28 @@ public class Series : IEntityDate, IHasReadTimeEstimate
LastChapterAdded = DateTime.Now;
LastChapterAddedUtc = DateTime.UtcNow;
}
public bool MatchesSeriesByName(string nameNormalized, string localizedNameNormalized)
{
return NormalizedName == nameNormalized ||
NormalizedLocalizedName == nameNormalized ||
NormalizedName == localizedNameNormalized ||
NormalizedLocalizedName == localizedNameNormalized;
}
public void ResetColorScape()
{
PrimaryColor = string.Empty;
SecondaryColor = string.Empty;
}
/// <summary>
/// Is this Series capable of Scrobbling
/// </summary>
/// <remarks>This includes if there is no Match/Manual Match needed, the series is blacklisted, or has a NoMatch</remarks>
/// <returns></returns>
public bool WillScrobble()
{
return !IsBlacklisted && !DontMatch;
}
}

View file

@ -10,4 +10,5 @@ public enum SideNavStreamType
ExternalSource = 6,
AllSeries = 7,
WantToRead = 8,
BrowseAuthors = 9
}

View file

@ -37,4 +37,30 @@ public class SiteTheme : IEntityDate, ITheme
public DateTime LastModified { get; set; }
public DateTime CreatedUtc { get; set; }
public DateTime LastModifiedUtc { get; set; }
#region ThemeBrowser
/// <summary>
/// The Url on the repo to download the file from
/// </summary>
public string? GitHubPath { get; set; }
/// <summary>
/// Hash of the Css File
/// </summary>
public string? ShaHash { get; set; }
/// <summary>
/// Pipe (|) separated urls of the images. Empty string if
/// </summary>
public string PreviewUrls { get; set; }
// /// <summary>
// /// A description about the theme
// /// </summary>
public string Description { get; set; }
// /// <summary>
// /// Author of the Theme
// /// </summary>
public string Author { get; set; }
public string CompatibleVersion { get; set; }
#endregion
}

View file

@ -1,10 +1,13 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using API.Entities.Interfaces;
using API.Extensions;
using API.Services.Tasks.Scanner.Parser;
namespace API.Entities;
public class Volume : IEntityDate, IHasReadTimeEstimate
public class Volume : IEntityDate, IHasReadTimeEstimate, IHasCoverImage
{
public int Id { get; set; }
/// <summary>
@ -13,6 +16,10 @@ public class Volume : IEntityDate, IHasReadTimeEstimate
/// <remarks>For Books with Series_index, this will map to the Series Index.</remarks>
public required string Name { get; set; }
/// <summary>
/// This is just the original Parsed volume number for lookups
/// </summary>
public string LookupName { get; set; }
/// <summary>
/// The minimum number in the Name field in Int form
/// </summary>
/// <remarks>Removed in v0.7.13.8, this was an int and we need the ability to have 0.5 volumes render on the UI</remarks>
@ -26,17 +33,16 @@ public class Volume : IEntityDate, IHasReadTimeEstimate
/// The maximum number in the Name field (same as Minimum if Name isn't a range)
/// </summary>
public required float MaxNumber { get; set; }
public IList<Chapter> Chapters { get; set; } = null!;
public DateTime Created { get; set; }
public DateTime LastModified { get; set; }
public DateTime CreatedUtc { get; set; }
public DateTime LastModifiedUtc { get; set; }
/// <summary>
/// Absolute path to the (managed) image file
/// </summary>
/// <remarks>The file is managed internally to Kavita's APPDIR</remarks>
public string? CoverImage { get; set; }
public bool CoverImageLocked { get; set; }
public string PrimaryColor { get; set; }
public string SecondaryColor { get; set; }
/// <summary>
/// Total pages of all chapters in this volume
/// </summary>
@ -48,11 +54,32 @@ public class Volume : IEntityDate, IHasReadTimeEstimate
public long WordCount { get; set; }
public int MinHoursToRead { get; set; }
public int MaxHoursToRead { get; set; }
public int AvgHoursToRead { get; set; }
public float AvgHoursToRead { get; set; }
// Relationships
public IList<Chapter> Chapters { get; set; } = null!;
public Series Series { get; set; } = null!;
public int SeriesId { get; set; }
/// <summary>
/// Returns the Chapter Number. If the chapter is a range, returns that, formatted.
/// </summary>
/// <returns></returns>
public string GetNumberTitle()
{
if (MinNumber.Equals(MaxNumber))
{
return MinNumber.ToString(CultureInfo.InvariantCulture);
}
return $"{MinNumber.ToString(CultureInfo.InvariantCulture)}-{MaxNumber.ToString(CultureInfo.InvariantCulture)}";
}
public void ResetColorScape()
{
PrimaryColor = string.Empty;
SecondaryColor = string.Empty;
}
}