aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xepy.py74
-rw-r--r--setup.py17
2 files changed, 51 insertions, 40 deletions
diff --git a/epy.py b/epy.py
index d76355a..6c5b79c 100755
--- a/epy.py
+++ b/epy.py
@@ -14,7 +14,7 @@ Options:
"""
-__version__ = "2021.2.3"
+__version__ = "2021.4.1"
__license__ = "GPL-3.0"
__author__ = "Benawi Adha"
__email__ = "benawiadha@gmail.com"
@@ -205,33 +205,36 @@ class Epub:
# TODO: test is break necessary
break
- toc = ET.parse(self.file.open(self.toc)).getroot()
- # EPUB3
- if self.version == "2.0":
- navPoints = toc.findall("DAISY:navMap//DAISY:navPoint", self.NS)
- elif self.version == "3.0":
- navPoints = toc.findall(
- "XHTML:body//XHTML:nav[@EPUB:type='toc']//XHTML:a",
- self.NS
- )
- for i in navPoints:
+ try:
+ toc = ET.parse(self.file.open(self.toc)).getroot()
+ # EPUB3
if self.version == "2.0":
- src = i.find("DAISY:content", self.NS).get("src")
- name = i.find("DAISY:navLabel/DAISY:text", self.NS).text
+ navPoints = toc.findall("DAISY:navMap//DAISY:navPoint", self.NS)
elif self.version == "3.0":
- src = i.get("href")
- name = "".join(list(i.itertext()))
- src = src.split("#")
- try:
- idx = contents.index(unquote(src[0]))
- except ValueError:
- continue
- self.toc_entries[0].append(name)
- self.toc_entries[1].append(idx)
- if len(src) == 2:
- self.toc_entries[2].append(src[1])
- elif len(src) == 1:
- self.toc_entries[2].append("")
+ navPoints = toc.findall(
+ "XHTML:body//XHTML:nav[@EPUB:type='toc']//XHTML:a",
+ self.NS
+ )
+ for i in navPoints:
+ if self.version == "2.0":
+ src = i.find("DAISY:content", self.NS).get("src")
+ name = i.find("DAISY:navLabel/DAISY:text", self.NS).text
+ elif self.version == "3.0":
+ src = i.get("href")
+ name = "".join(list(i.itertext()))
+ src = src.split("#")
+ try:
+ idx = contents.index(unquote(src[0]))
+ except ValueError:
+ continue
+ self.toc_entries[0].append(name)
+ self.toc_entries[1].append(idx)
+ if len(src) == 2:
+ self.toc_entries[2].append(src[1])
+ elif len(src) == 1:
+ self.toc_entries[2].append("")
+ except AttributeError:
+ pass
def get_raw_text(self, chpath):
# using try-except block to catch
@@ -410,7 +413,7 @@ class HTMLtoLines(HTMLParser):
pref = {"pre"}
bull = {"li"}
hide = {"script", "style", "head"}
- ital = {"i", "em"}
+ ital = {"i", "em", "blockquote"}
bold = {"b"}
# hide = {"script", "style", "head", ", "sub}
@@ -453,16 +456,17 @@ class HTMLtoLines(HTMLParser):
if i[0].endswith("href"):
self.text.append("[IMG:{}]".format(len(self.imgs)))
self.imgs.append(unquote(i[1]))
- elif tag in self.ital:
- self.initital.append([len(self.text)-1, len(self.text[-1])])
- elif tag in self.bold:
- self.initbold.append([len(self.text)-1, len(self.text[-1])])
if self.sects != {""}:
for i in attrs:
if i[0] == "id" and i[1] in self.sects:
# self.text[-1] += " (#" + i[1] + ") "
# self.sectsindex.append([len(self.text), i[1]])
self.sectsindex[len(self.text)-1] = i[1]
+ # formatting
+ if tag in self.ital:
+ self.initital.append([len(self.text)-1, len(self.text[-1])])
+ elif tag in self.bold:
+ self.initbold.append([len(self.text)-1, len(self.text[-1])])
def handle_startendtag(self, tag, attrs):
if tag == "br":
@@ -507,7 +511,8 @@ class HTMLtoLines(HTMLParser):
self.text[-1] += "}"
elif tag == "image":
self.text.append("")
- elif tag in self.ital:
+ # formatting
+ if tag in self.ital:
self.initital[-1] += [len(self.text)-1, len(self.text[-1])]
elif tag in self.bold:
self.initbold[-1] += [len(self.text)-1, len(self.text[-1])]
@@ -1001,6 +1006,9 @@ def loadstate():
except FileNotFoundError:
pass
+ if sys.platform == "win32":
+ CFG["PageScrollAnimation"] = False
+
def parse_keys():
global WINKEYS
@@ -2080,7 +2088,7 @@ def preread(stdscr, file):
curses.mousemask(-1)
# curses.mouseinterval(0)
SCREEN.clear()
- rows, cols = SCREEN.getmaxyx()
+ _, cols = SCREEN.getmaxyx()
show_loader(SCREEN)
ebook = det_ebook_cls(file)
diff --git a/setup.py b/setup.py
index 4fc30ca..0fd8e8e 100644
--- a/setup.py
+++ b/setup.py
@@ -1,22 +1,25 @@
import sys
from setuptools import setup
-from epy import __version__, __author__, __email__, __url__, __license__
with open("README.md", "r") as fh:
long_description = fh.read()
+requirements = ["mobi"]
+if sys.platform == "win32":
+ requirements.append("windows-curses")
+
setup(
name="epy-reader",
- version=__version__,
+ version="2021.4.1",
description="Terminal/CLI Ebook (epub, fb2, mobi, azw3) Reader",
long_description=long_description,
long_description_content_type="text/markdown",
- url=__url__,
- author=__author__,
- author_email=__email__,
- license=__license__,
+ url="https://github.com/wustho/epy",
+ author="Benawi Adha",
+ author_email="benawiadha@gmail.com",
+ license="GPL-3.0",
keywords=["epub", "epub3", "fb2", "mobi", "azw3", "CLI", "Terminal", "Reader"],
- install_requires=["mobi"] + (["windows-curses"] if sys.platform == "win32" else []),
+ install_requires=requirements,
python_requires="~=3.0",
py_modules=["epy"],
entry_points={ "console_scripts": ["epy = epy:main"] },