using System;
using System.Collections.Generic;
using API.Entities.Enums;
using API.Entities.Interfaces;
using API.Entities.Metadata;
using API.Extensions;
namespace API.Entities;
public class Series : IEntityDate, IHasReadTimeEstimate
{
public int Id { get; set; }
///
/// The UI visible Name of the Series. This may or may not be the same as the OriginalName
///
public required string Name { get; set; }
///
/// Used internally for name matching.
///
public required string NormalizedName { get; set; }
///
/// Used internally for localized name matching.
///
public required string NormalizedLocalizedName { get; set; }
///
/// The name used to sort the Series. By default, will be the same as Name.
///
public required string SortName { get; set; }
///
/// Name in original language (Japanese for Manga). By default, will be same as Name.
///
public required string LocalizedName { get; set; }
///
/// Original Name on disk. Not exposed to UI.
///
public required string OriginalName { get; set; }
///
/// Time of creation
///
public DateTime Created { get; set; }
///
/// Whenever a modification occurs. Ie) New volumes, removed volumes, title update, etc
///
public DateTime LastModified { get; set; }
public DateTime CreatedUtc { get; set; }
public DateTime LastModifiedUtc { get; set; }
///
/// Absolute path to the (managed) image file
///
/// The file is managed internally to Kavita's APPDIR
public string? CoverImage { get; set; }
///
/// Denotes if the CoverImage has been overridden by the user. If so, it will not be updated during normal scan operations.
///
public bool CoverImageLocked { get; set; }
///
/// Sum of all Volume page counts
///
public int Pages { get; set; }
///
/// Highest path (that is under library root) that contains the series.
///
/// must be used before setting
public string? FolderPath { get; set; }
///
/// Lowest path (that is under library root) that contains all files for the series.
///
/// must be used before setting
public string? LowestFolderPath { get; set; }
///
/// Last time the folder was scanned
///
public DateTime LastFolderScanned { get; set; }
///
/// Last time the folder was scanned in Utc
///
public DateTime LastFolderScannedUtc { get; set; }
///
/// The type of all the files attached to this series
///
public MangaFormat Format { get; set; } = MangaFormat.Unknown;
public bool SortNameLocked { get; set; }
public bool LocalizedNameLocked { get; set; }
///
/// When a Chapter was last added onto the Series
///
public DateTime LastChapterAdded { get; set; }
public DateTime LastChapterAddedUtc { get; set; }
///
/// Total Word count of all chapters in this chapter.
///
/// Word Count is only available from EPUB files
public long WordCount { get; set; }
public int MinHoursToRead { get; set; }
public int MaxHoursToRead { get; set; }
public int AvgHoursToRead { get; set; }
public SeriesMetadata Metadata { get; set; } = null!;
public ExternalSeriesMetadata ExternalSeriesMetadata { get; set; } = null!;
public ICollection Ratings { get; set; } = null!;
public ICollection Progress { get; set; } = null!;
public ICollection Collections { get; set; } = null!;
///
/// Relations to other Series, like Sequels, Prequels, etc
///
/// 1 to Many relationship
public ICollection Relations { get; set; } = null!;
public ICollection RelationOf { get; set; } = null!;
// Relationships
public List Volumes { get; set; } = null!;
public Library Library { get; set; } = null!;
public int LibraryId { get; set; }
public void UpdateLastFolderScanned()
{
LastFolderScanned = DateTime.Now;
LastFolderScannedUtc = DateTime.UtcNow;
}
public void UpdateLastChapterAdded()
{
LastChapterAdded = DateTime.Now;
LastChapterAddedUtc = DateTime.UtcNow;
}
public bool MatchesSeriesByName(string nameNormalized, string localizedNameNormalized)
{
return NormalizedName == nameNormalized ||
NormalizedLocalizedName == nameNormalized ||
NormalizedName == localizedNameNormalized ||
NormalizedLocalizedName == localizedNameNormalized;
}
}