Creating EPUB documents from Fictionpress stories

I consume a lot of written media on my Kindle, and I’m often frustrated when I have to use my mobile phone or computer to read online content. I needed a new project and I was hearing a lot about Node.js. In order to learn more about Node.js, I decided to write a couple of libraries to grab content from a specific website (Fictionpress) and convert it into a format that my Kindle could use.

The two libraries are now available on NPM, a Node.js package manager.

Sample Code

'use strict';

var fpScraper = require('fictionpress-scraper');
var epub = require('quick-epub');

// Replace null with a valid storyID
var storyID = null;

// Grab the story data, then generate an EPUB document
 // Tweak received data so that it matches expected format for quick-epub
 var epubData = {
  title: story.title,
  publisher: 'Fictionpress',
  description: story.summary,
  contents: story.content,
  output: + '.epub'

 // Generate EPUB
 return epub.createFile(epubData);
 console.log('Fictionpress EPUB generated.');