mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-05-24 00:52:23 -04:00
* Added a tooltip to inform user that format and collection filter selections do not only show for the selected library. * Refactored a lot of code around when we update chapter cover images. Applied an optimization for when we re-calculate volume/series covers, such that it only occurs when the first chapter's image updates. * Updated code to ensure only lastmodified gets refreshed in metadata since it always follows a scan * Optimized how metadata is populated on the series. Instead of re-reading the comicInfos, instead I read the data from the underlying chapter entities. This reduces N additional reads AND enables the ability in the future to show/edit chapter level metadata. * Spelling mistake * Fixed a concurency issue by not selecting Genres from DB. Added a test for long paths. * Fixed a bug in filter where collection tag wasn't populating on load * Cleaned up the logic for changelog to better compare against the installed verison. For nightly users, show the last stable as installed. * Removed some demo code * SplitQuery to allow loading tags much faster for series metadata load.
128 lines
3.9 KiB
C#
128 lines
3.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using API.Data.Metadata;
|
|
using API.Entities;
|
|
using API.Entities.Enums;
|
|
using API.Entities.Metadata;
|
|
using API.Extensions;
|
|
using API.Parser;
|
|
using API.Services.Tasks;
|
|
|
|
namespace API.Data
|
|
{
|
|
/// <summary>
|
|
/// Responsible for creating Series, Volume, Chapter, MangaFiles for use in <see cref="ScannerService"/>
|
|
/// </summary>
|
|
public static class DbFactory
|
|
{
|
|
public static Series Series(string name)
|
|
{
|
|
return new ()
|
|
{
|
|
Name = name,
|
|
OriginalName = name,
|
|
LocalizedName = name,
|
|
NormalizedName = Parser.Parser.Normalize(name),
|
|
SortName = name,
|
|
Volumes = new List<Volume>(),
|
|
Metadata = SeriesMetadata(Array.Empty<CollectionTag>())
|
|
};
|
|
}
|
|
|
|
public static SeriesMetadata SeriesMetadata(ComicInfo info)
|
|
{
|
|
return SeriesMetadata(Array.Empty<CollectionTag>());
|
|
}
|
|
|
|
public static Volume Volume(string volumeNumber)
|
|
{
|
|
return new Volume()
|
|
{
|
|
Name = volumeNumber,
|
|
Number = (int) Parser.Parser.MinimumNumberFromRange(volumeNumber),
|
|
Chapters = new List<Chapter>()
|
|
};
|
|
}
|
|
|
|
public static Chapter Chapter(ParserInfo info)
|
|
{
|
|
var specialTreatment = info.IsSpecialInfo();
|
|
var specialTitle = specialTreatment ? info.Filename : info.Chapters;
|
|
return new Chapter()
|
|
{
|
|
Number = specialTreatment ? "0" : Parser.Parser.MinimumNumberFromRange(info.Chapters) + string.Empty,
|
|
Range = specialTreatment ? info.Filename : info.Chapters,
|
|
Title = (specialTreatment && info.Format == MangaFormat.Epub)
|
|
? info.Title
|
|
: specialTitle,
|
|
Files = new List<MangaFile>(),
|
|
IsSpecial = specialTreatment,
|
|
};
|
|
}
|
|
|
|
public static SeriesMetadata SeriesMetadata(ICollection<CollectionTag> collectionTags)
|
|
{
|
|
return new SeriesMetadata()
|
|
{
|
|
CollectionTags = collectionTags,
|
|
Summary = string.Empty
|
|
};
|
|
}
|
|
|
|
public static CollectionTag CollectionTag(int id, string title, string summary, bool promoted)
|
|
{
|
|
return new CollectionTag()
|
|
{
|
|
Id = id,
|
|
NormalizedTitle = API.Parser.Parser.Normalize(title?.Trim()).ToUpper(),
|
|
Title = title?.Trim(),
|
|
Summary = summary?.Trim(),
|
|
Promoted = promoted
|
|
};
|
|
}
|
|
|
|
public static Genre Genre(string name, bool external)
|
|
{
|
|
return new Genre()
|
|
{
|
|
Title = name.Trim().SentenceCase(),
|
|
NormalizedTitle = Parser.Parser.Normalize(name),
|
|
ExternalTag = external
|
|
};
|
|
}
|
|
|
|
public static Tag Tag(string name, bool external)
|
|
{
|
|
return new Tag()
|
|
{
|
|
Title = name.Trim().SentenceCase(),
|
|
NormalizedTitle = Parser.Parser.Normalize(name),
|
|
ExternalTag = external
|
|
};
|
|
}
|
|
|
|
public static Person Person(string name, PersonRole role)
|
|
{
|
|
return new Person()
|
|
{
|
|
Name = name.Trim(),
|
|
NormalizedName = Parser.Parser.Normalize(name),
|
|
Role = role
|
|
};
|
|
}
|
|
|
|
public static MangaFile MangaFile(string filePath, MangaFormat format, int pages)
|
|
{
|
|
return new MangaFile()
|
|
{
|
|
FilePath = filePath,
|
|
Format = format,
|
|
Pages = pages,
|
|
LastModified = File.GetLastWriteTime(filePath) // NOTE: Changed this from DateTime.Now
|
|
};
|
|
}
|
|
|
|
}
|
|
}
|