This goes through downloading a web novel from Shousetsuka Ni Narou, packing it into an EPUB, then converting that into Kobo EPUB.
Readers of Japanese media, and readers of ebooks. KEPUB is a Kobo format, so this step can be omitted if a Kobo ereader is not owned.
Check how many chapters are in the series. For this example I'll be converting Ascendance of a Bookworm with 677 chapters.
Download all chapters first:
for i in {1..677}; do
echo $i.html;
curl -SsfLo $i.html -A 'Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0' https://ncode.syosetu.com/n4830bu/$i/;
done
Extract HTML tags containing the novel and save them as markdown. We only need the chapter names and content. Mark the former with h1 tags for pandoc
:
for i in {1..677}; do
echo -n '# ' > $i.md;
htmlq -tf $i.html '.novel_subtitle' >> $i.md;
htmlq -tf $i.html '.novel_view' >> $i.md;
done
Ascendance of a Bookworm is split into five parts. In this case I decided to separate these into five ebooks, too. For the boundaries I simply looked at which chapter begins a part and which ends it.
cat {1..77}.md > part1.md
cat {78..172}.md > part2.md
# and so on
If it's not needed, simply concatenate all .md
files into one book.md
file.
cat {1..677}.md > book.md
Add a YAML front matter to every markdown file. This will later be the EPUB metadata. See the docs for more info on this.
---
title:
- type: main
text: 本好きの下剋上 第一部
- type: subtitle
text: 兵士の娘
creator:
- role: aut
text: 香月 美夜
- role: mrk
text: (your name?)
- role: ppm
text: マイン
date: 2013
lang: ja
description: 本が好きで、司書資格を取り、大学図書館への就職が決まっていたのに、大学卒業直後に死んでしまった麗乃。転生したのは、識字率が低くて本が少ない世界の兵士の娘。いくら読みたくても周りに本なんてあるはずない。本がないならどうする? 作ってしまえばいいじゃない。目指すは図書館司書! 本に囲まれて生きるため、本を作るところから始めよう。※最初の主人公の性格が最悪です。ある程度成長するまで、気分悪くなる恐れがあります。(R15は念のため
belongs-to-collection: 本好きの下剋上
group-position: 1
---
Set relevant epub:type
attributes. Ascendance of a Bookworm features prologues at the beginning of every part, so I marked them.
# プロローグ {epub:type=prologue}
Convert the book or its part files to EPUB.
pandoc part1.md -f markdown -t epub3 -o part1.epub
# and so on
Import the book into Calibre and/or move onto your ereader.
If you use a Kobo ereader, convert the standard EPUBs to KEPUBs. There is a method by using Calibre, and a manual one.
Download the KePub extensions via Calibre's plugin manager (found in Settings > Extensions > Install new extensions) and restart Calibre.
Select the ebook you'd like to kepubify, then Convert books and select KEPUB as the output format in the upper right corner. Set some options if you want, then OK. Then use Calibre to move this onto your Kobo.
kepubify part1.epub
# and so on
Then simply move the .kepub
file onto your Kobo.