shithub: rc

Download patch

ref: 8333763762a317aa8fda04bd743686912047004c
parent: 0307ffc0d3c3ccef73202f099645a2663872e8e6
author: sl <sl@x1yg3>
date: Sun Jul 6 18:17:00 EDT 2025

add epub2txt

--- a/INDEX
+++ b/INDEX
@@ -19,6 +19,7 @@
 dsrc - delete posts on a given barf website
 epub2html - convert epub to html
 epub2pdf - convert epub to pdf
+epub2txt - convert epub to text
 flac2alac - Convert FLAC to ALAC using ffmpeg.
 flac2mp3 - Convert FLAC to MP3 using lame.
 flacsplit - Split single FLAC into multiple files based on .cue sheet using shntool.
--- /dev/null
+++ b/epub2txt
@@ -1,0 +1,23 @@
+#!/bin/rc
+# epub2txt - convert epub to text
+# usage:  epub2txt file.epub
+# depend: epub2html
+
+# set some defaults
+rfork e
+if(! ~ $#* 1) exit usage
+keep=yes
+name=`{basename $1 | sed 's/\.[Ee][Pp][Uu][Bb]//'}
+if(! test -f $name.html){
+    keep=no
+    epub2html $* || exit $status
+}
+ifs='
+'
+
+# convert extracted epub to text
+> $name.txt
+for(file in `{awk -F" '/<a/ { print $2 }' $name.html})
+    html2ms < $"file | deroff | fmt >> $name.txt
+if(~ $keep no)
+    rm -rf $name.html $name^_files
--