skoji / gepub

a generic EPUB library for Ruby : supports EPUB 3
Other
240 stars 42 forks source link

Generate and allow writing output after every chapter? #136

Open gregschwartz opened 1 year ago

gregschwartz commented 1 year ago

Very much appreciating this gem, it's been a huge help! I'm pulling down serially posted stories to put them on to my Kindle. (Mostly from the amazing /r/HFY but also other places.)

For example, it retrieves The Sacred Noise part 1 and part 2.

Then it moves on to the next series, grabbing Large Scale Engineering and then Economies of Scale (which is part 2).

Repeat for all the series I'm reading.

I have it working to retrieve everything within the book.ordered do loop, then exporting everything once after finishing retrieving all series.

However, I'd like to export the ePub in between each series, in case retrieving a series causes a crash. (These examples are 2 parts, some stories are 50+ parts.) So I tried this after each series:

epubname = File.join(File.dirname(__FILE__), "Stories " + dateForFilename + ".epub")
book.generate_epub(epubname)

However the nav.xhtml is not regenerated after the first generate_epub() call. So it only contains the first series. And the resulting ePub has some other oddities, too.

tl;dr: is there a way to build the book without a book.ordered do loop? Or make it correctly regenerate if you call generate_epub() multiple times?

Thank you!