Skip to content

Conversation

@pilotMike
Copy link

@pilotMike pilotMike commented May 13, 2025

Adds support for multiple chapters. The previous version ignored any leading chapter numbers in the uri of {chapterId}/images/{image}. It now accounts for that and is working in a locally run user interface for an epub that was broken. I didn't check in the unit test over the GetBookPage method since it requires a specific file.

I can provide a link to the specific epub that wasn't working - it's 50MB though.

References: #3800

Added

  • Multi-chapter support that can show up in merged epubs. Chapter URIs were previously ignoring everything except the last end of an image or stylesheet uri, which could result in multiple matches and fail. It now works.

Changed

  • BookService in getting image keys and stylesheet keys. The page variable is now getting passed down and included in the key uri logic.
  • BookController to also use chapter number in generating a key

Fixed

  • Fixed: Fixed a bug (Fixes #issue 3800)

Not included unit test

// Test included as example. I can provide a link to the file for further testing.
    /// <summary>
    /// Scenario: a manga volume that was created by stitching together the chapters in Calibre has 2 cover files:
    /// * cover.jpg
    /// * 1/cover.jpeg
    /// * 1/images/00001.jpg
    ///
    /// With the image file determined as cover.jpeg (note the 'e').
    /// As a result, it was not found with single or default
    /// </summary>
    [Theory]
    [MemberData(nameof(ChapterLists))]
    public async Task ShouldParseSecondPageComicStitchedTogetherInCalibre(int page)
    {
        var bookPath = Path.Combine("Data", "The Color of the End - Haruo Iwamune.epub");

        var page2 = await _bookService.GetBookPage(page, 0,  bookPath, "");
    }

    public static IEnumerable<object[]> ChapterLists() => Enumerable.Range(0, 9).Select(i => new object[] { i });

Previous Result:
image

Current Result:

Screen.Recording.2025-05-13.at.11.36.39.AM.mov

…leading chapter numbers in the uri of {chapterId}/images/{image}. It now accounts for that and is working in a locally run user interface for an epub that was broken. I didn't check in the unit test over the GetBookPage method since it requires a specific file. I'll provide that in the PR description, though.
@sonarqubecloud
Copy link

@pilotMike pilotMike changed the title [Feat} Adds support for multiple chapters. [Feat] Adds support for multiple chapters. May 13, 2025
@pilotMike pilotMike changed the base branch from develop to main May 13, 2025 18:06
@pilotMike pilotMike changed the base branch from main to develop May 13, 2025 18:06
@pilotMike
Copy link
Author

@majora2007 tagging in case this is something that you'd want to incorporate :)

@github-project-automation github-project-automation bot moved this to In progress in Kavita May 31, 2025
@majora2007 majora2007 moved this from In progress to To do in Kavita Jun 5, 2025
@majora2007 majora2007 added the needs-triage Needs to be triaged by a developer and assigned a release label Aug 5, 2025
@majora2007
Copy link
Member

majora2007 commented Sep 19, 2025

User sent file: The Color of the End - Haruo Iwamune.epub for testing this issue

@majora2007
Copy link
Member

@pilotMike I was trying to find the file you sent me. Can you resend it to me so I can try to understand what this is trying to fix?

@pilotMike
Copy link
Author

@majora2007 Here is a burn after reading bin link to the file. Let me know if I need to resend another https://paste.michaeldileo.org/?6bc3d13ab21fd428#-Dy61zGXfnk4ocHYCEe5vMYoDRk6vpkfmaPTfX3gbUWC3

@majora2007
Copy link
Member

Thanks

@majora2007
Copy link
Member

I looked at the epub and it's not valid. It is essentially an epub with multiple folders within, each folder being a self contained epub. That's not part of the standard and seems to just be hacked together.

How did you come across this book? Are you creating it to keep multiple chapters into a series (you would probably be better off taking each folder and just zipping into a chapter.epub)

@pilotMike
Copy link
Author

Its been a while since I did it, but iirc, each chapter was available individually of the manga and the "book" you'd buy had a certain number of chapters. I downloaded each chapter of the book and imported it into Calibre to combine/merge into a single epub. This file was how calibre did the output. For what it's worth, other e-reader software is able to open this file, such as the e-reader on OSX (and calibre of course).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-triage Needs to be triaged by a developer and assigned a release

Projects

Status: To do

Development

Successfully merging this pull request may close these issues.

2 participants