TangentFoxy / .lua-files

Utility scripts I install into my path for fun.
0 stars 0 forks source link

.lua-files

Personally convenient Lua scripts to add to my path.

Installation

  1. Put this folder somewhere.
  2. Add that somewhere to your path. (On Windows, search for Environment Variables (it's "part of" Control Panel) and use the UI to add them to System variables.)
  3. (On Windows) Add .LUA to PATHEXT.

Scripts

make-epub.lua

This script is only intended for personal use. Do not use it to infringe on copyright.

Usage:

  make-epub.lua <config (JSON file)> [action]

If "." is used instead of a JSON file, every JSON file in the current directory
will be used to make multiple ebooks back-to-back.

[action]: If not specified, all steps will be taken in order (except cleanall).
            download:  All pages will be downloaded to their own HTML files.
            convert:   Each page is converted to Markdown.
            concat:    A file is created for each section out of its pages.
            markdown:  Metadata frontmatter and Markdown section files will be
                       concatenated into a single Markdown file.
            epub:      Markdown file will be converted to an ePub using pandoc.
            cleanpage: All page files will be deleted, along with their extra
                       directories.
            cleanall:  Deletes everything except the config file and ePub.

[flag]: If "--continue" is passed, script will continue with the default order
          of actions from the action specified.

Requirements:
- Binaries:      pandoc, curl

The JSON config spec has two major variations ("Book" and "Anthology").

The following is shared:

Variation: Book

Example:

{
  "authors": ["Name"],
  "title": "Book",
  "base_file_name": "Book",
  "keywords": ["erotica", "fantasy"],
  "base_url": "https://www.literotica.com/s/title-ch-",
  "first_section_url": "https://www.literotica.com/s/title",
  "sections": {
    "start": 1,
    "finish": 4,
    "naming": "Chapter",
    "automatic_naming": true
  },
  "page_counts": [1, 5, 3, 3]
}

Variation: Anthology

Example:

{
  "authors": ["Name"],
  "title": "Anthology",
  "keywords": ["LitErotica", "erotica"],
  "manually_specified_sections": true,
  "sections": [
    "https://www.literotica.com/s/unique-title",
    "https://www.literotica.com/s/another-title"
  ],
  "section_titles": [
    "Unique Title",
    "Another Title"
  ],
  "page_counts": [5, 2]
}