View Single Post
Old 03-17-2023, 07:03 PM   #1750
enuddleyarbl
Guru
enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.
 
enuddleyarbl's Avatar
 
Posts: 734
Karma: 1077122
Join Date: Sep 2013
Device: Kobo Forma
Just sticking various of Modify ePub's modules into Notepad++, I think I was able to find the issue. It looks like this is handled in add_replace_jacket and is_cover_or_title_id of jacket.py:
Code:
...
    # Next add it to the spine. We want it at the start of the book, but
    # after the Calibre titlepage and cover image.
    # TODO: Might want to make this a bit more bulletproof by looking at the guide etc.

    insert_pos = 1
    spine_items = list(container.get_spine_items())
    while insert_pos < len(spine_items):
        spine_id = spine_items[insert_pos].get('id').lower()
        if not is_cover_or_title_id(spine_id):
            break
        insert_pos += 1

    if jacket_end_book:
        insert_pos = -1
    container.add_to_spine(id, index=insert_pos)
    container.set(container.opf_name, container.opf)
    return True

def is_cover_or_title_id(spine_id):
    return spine_id.startswith('cvi') or spine_id.startswith('cover') or spine_id.startswith('titlepage') or spine_id.startswith('tp')
So, starting at the beginning of the spine, it starts looking for a place just after the Calibre cover and titlepage for the jacket. It defines those pages as ones with ids starting with "cvi", "cover", "titlepage" or "tp". And that last one seems to be the issue. Even though I change the name of the existing title page to "tpage.xhtml", I don't change the id in the manifest. So, whatever the author/publisher assigned it as an id is what's being checked. In this book's case, the id is "tp". So, Modify ePub goes right by it and inserts the jacket at the next position. It looks like most of the time, the id of that title page is NOT "tp" (or starting with tp -- for instance, in one of my multitude (usual) of books where the jacket gets put into the 2nd position, the tpage.xhtml file has an id of "title"). So, the jacket gets put just before that page instead of just after it.

I don't see how Modify ePub could change its behavior to handle all cases (it mentions a TODO of checking the guide -- but there IS no guide in this particular book), so it looks like the work-around (assuming this bothers me enough to do it) is to change the id of that tpage.xhtml file to something not starting in "tp" in both the manifest and the spine.

QED. At least I understand what I'm seeing, now.

Last edited by enuddleyarbl; 03-17-2023 at 08:49 PM. Reason: Why do I keep putting apostrophes where they don't belong?
enuddleyarbl is offline   Reply With Quote