PDF Reader Settings, New Reading Modes, and lots of fixes (#2828)

Co-authored-by: Elry <144011449+ElryWeeb@users.noreply.github.com>
Co-authored-by: AlienHack <the4got10@windowslive.com>
Co-authored-by: William Brockhus <pickeringw@gmail.com>
Co-authored-by: Shivam Amin <xShivam.Amin@gmail.com>
This commit is contained in:
Joe Milazzo 2024-03-30 15:07:03 -05:00 committed by GitHub
parent f22f30b5a9
commit 2bde0ac82a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
55 changed files with 4410 additions and 439 deletions

View file

@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using API.Entities;
using API.Helpers;
using API.Helpers.Builders;
using API.Services.Tasks.Scanner.Parser;
namespace API.Extensions;
@ -24,6 +25,7 @@ public static class ChapterListExtensions
/// Gets a single chapter (or null if doesn't exist) where Range matches the info.Chapters property. If the info
/// is <see cref="ParserInfo.IsSpecial"/> then, the filename is used to search against Range or if filename exists within Files of said Chapter.
/// </summary>
/// <remarks>This uses GetNumberTitle() to calculate the Range to compare against the info.Chapters</remarks>
/// <param name="chapters"></param>
/// <param name="info"></param>
/// <returns></returns>
@ -31,9 +33,12 @@ public static class ChapterListExtensions
{
var normalizedPath = Parser.NormalizePath(info.FullFilePath);
var specialTreatment = info.IsSpecialInfo();
// NOTE: This can fail to find the chapter when Range is "1.0" as the chapter will store it as "1" hence why we need to emulate a Chapter
var fakeChapter = new ChapterBuilder(info.Chapters, info.Chapters).Build();
fakeChapter.UpdateFrom(info);
return specialTreatment
? chapters.FirstOrDefault(c => c.Range == Parser.RemoveExtensionIfSupported(info.Filename) || c.Files.Select(f => Parser.NormalizePath(f.FilePath)).Contains(normalizedPath))
: chapters.FirstOrDefault(c => c.Range == info.Chapters);
: chapters.FirstOrDefault(c => c.Range == fakeChapter.GetNumberTitle());
}
/// <summary>