Skip to content

Commit

Permalink
2.0.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
noembryo committed May 2, 2024
1 parent ccd7c42 commit e5931bc
Show file tree
Hide file tree
Showing 31 changed files with 4,026 additions and 1,576 deletions.
81 changes: 50 additions & 31 deletions README.md
Expand Up @@ -11,26 +11,37 @@

**KOHighlights** is a utility for viewing and exporting the
[Koreader](https://github.com/koreader/koreader)'s highlights to simple text, html, csv or markdown files.
This is a totally re-written application using the Qt framework (PySide).
The original KOHighlights (using the wxPython) can be found
[here](https://github.com/noonkey/KoHighlights), but is considered deprecated..


### Screenshots
___
#### Screenshots
<p align="center">
<a href="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screens/screen%20l1.png">
<img src="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screens/screen%20l1.png" height="160"></a>
<a href="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screens/screen%20d1.png">
<img src="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screens/screen%20d1.png" height="160"></a>
<a href="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screens/screen%20l2.png">
<img src="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screens/screen%20l2.png" height="160"></a>
<a href="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screens/screen%20d2.png">
<img src="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screens/screen%20d2.png" height="160"></a>
<!-- </p>
<p align="center"> -->
<a href="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screens/screen%20l3.png">
<img src="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screens/screen%20l3.png" height="160"></a>
<a href="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screens/screen%20d3.png">
<img src="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screens/screen%20d3.png" height="160"></a>
<a href="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screens/screen%20l4.png">
<img src="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screens/screen%20l4.png" height="160"></a>
<a href="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screens/screen%20d4.png">
<img src="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screens/screen%20d4.png" height="160"></a>
</p>
<!-- ![HighLights ScreenShot](screen1.png) -->
<!-- ![HighLights ScreenShot](screen2.png) -->
<!-- ![HighLights ScreenShot](screen3.png) -->

<p align="center">
<a href="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screen1.png">
<img src="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screen1.png" height="180"></a>
<a href="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screen2.png">
<img src="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screen2.png" height="180"></a>
<a href="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screen3.png">
<img src="https://raw.githubusercontent.com/noembryo/KoHighlights/master/screen3.png" height="180"></a>
</p>
___

## Usage
## Usage/Features
* Load items by:
* Selecting the reader's drive or any folder that contains books that where opened with Koreader. This will automatically load all the metadata files from all subdirectories.
* Drag and drop files or folders. This will load the files and/or all the files inside the folders.
Expand All @@ -41,26 +52,20 @@ The original KOHighlights (using the wxPython) can be found
* Comma-separated values files (.csv)
* Markdown files (.md)
* View the highlights and various info for a book by selecting it in the list.
* Save the highlights to the "Archive" and view them, even if your reader is not connected.
* Merge highlights/Sync position from the same book that is read in two different devices and/or sync its reading position. To do it you have to:
* Load both metadata (e.g. by scanning your reader's _and_ your tablet's books).
* Select the relevant rows of the (same) book.
* If the book has the same cre_dom_version (version of the CREngine), then the "Merge/Sync" button gets activated and you get the options to sync the highlights or the position or both.
* Merge highlights/Sync position of a book with its archived version
(book's right click menu)
* Show/hide the page, date, chapter or even the highlight text while viewing or saving the highlights of the books.
* Save the highlights to the "Archive" database and view them, even if your reader is not connected.
* Merge highlights/Sync position from the same book that is read in different devices and/or sync its reading position.
* Merge highlights/Sync position of a book with its archived version.
* Show/hide the page, date, chapter or even the highlight (!) text while viewing or exporting the highlights of the books.
* Double click or press the Open Book button to view the book in your system's reader.
* Delete some or all the highlights of any book.
* Clear/reset the .sdr folders with the metadata or the books in the eReader.

### Prerequisites
These plugins must be enabled in KOReader
* Progress sync plugin
* Reading statistics plugin
The progress sync plugin must be enabled in KOReader

### Portable
In Windows, KOHighlights can run in Portable mode using a `portable_settings` directory to store its settings, that is located inside the installation directory of the app.
Because of this, it is advised to not install the app inside the `Program Files` folder if you indent to use it as portable.
Because of this, it is advised to not install the app inside the default `Program Files` folder if you indent to use it as portable.
There are two ways to start the app in Portable mode:
* Run the `KoHighlights Portable.exe` that is located next to the `KoHighlights.exe`.
* Run `KoHighlights.exe` with a `-p` argument.
Expand All @@ -71,13 +76,27 @@ Check the latest release on the [Downloads Page][ReleaseLink].
Read the version history at [App's Page](http://www.noembryo.com/apps.php?kohighlights).

## Dependencies
Should run in any system with Python 2.7.x or 3.x (more testing required)
It needs the [PySide](https://pypi.org/project/PySide/),
* **Source code:**
Should run in any system with Python 3.6+ (more testing required)
It needs the [PySide2](https://pypi.org/project/PySide2/),
[BeautifulSoup4](https://pypi.org/project/beautifulsoup4/),
[future](https://pypi.org/project/future/) and
[packaging](https://pypi.org/project/packaging/) and
[requests](https://pypi.org/project/requests/) libraries.
In Linux the `libqt4-sql-sqlite` package must be installed.
PySide2/PySide6 are also supported (download the archive from the releases)
In Windows, it might also need the [PyWin32](https://pypi.org/project/PyWin32/) and the [Pypiwin32](https://pypi.org/project/pypiwin32/) libraries.
PySide6 is also supported (download the archive from the releases)
* **Compiled binaries:**
* ***Windows***:
From version 2.x, KOHighlights dropped support for Windows XP.
Can run on any version of Windows from Windows 7 upwards.
For Windows 7, Microsoft Visual C++ 14.0 is required. Get it
[here](https://aka.ms/vs/17/release/vc_redist.x86.exe).
The Windows 7 32bit version also needs the KB2533623 update thats is included in [KB3063858](https://www.microsoft.com/en-us/download/details.aspx?id=47409) ([direct link](https://download.microsoft.com/download/C/9/6/C96CD606-3E05-4E1C-B201-51211AE80B1E/Windows6.1-KB3063858-x86.msu)).
* ***Linux***:
The binary is compiled using Xubuntu 18.04.
Any newer version should work.




## Extra
KOHighlights includes SLPPU (a converter between python and lua objects).
Expand Down
52 changes: 25 additions & 27 deletions boot_config.py
@@ -1,46 +1,35 @@
# coding=utf-8
from __future__ import (absolute_import, division, print_function, unicode_literals)

import time
import sys, os
import traceback
import gzip, json
from os.path import dirname, join, isdir, expanduser

__author__ = "noEmbryo"


def _(text): # for future gettext support
return text


APP_NAME = "KOHighlights"
APP_DIR = dirname(os.path.abspath(sys.argv[0]))
os.chdir(APP_DIR) # Set the current working directory to the app's directory

PORTABLE = False
PYTHON2 = sys.version_info < (3, 0)

USE_QT6 = False # select between PySide2/Qt5 and Pyside6/Qt6 if both are installed

if PYTHON2:
from io import open
from codecs import open as c_open
from PySide.QtCore import qVersion
if USE_QT6:
from PySide6.QtCore import qVersion
else:
# noinspection PyShadowingBuiltins
unicode, basestring = str, str
c_open = open
if USE_QT6:
from PySide6.QtCore import qVersion
else:
from PySide2.QtCore import qVersion
from PySide2.QtCore import qVersion

# noinspection PyTypeChecker
qt_version = qVersion().split(".")[0]
QT4 = qt_version == "4"
QT5 = qt_version == "5"
QT6 = qt_version == "6"
if QT6 and QT5 and USE_QT6:
QT5 = False

PORTABLE = False
if sys.platform == "win32": # Windows
import win32api
import win32event
Expand All @@ -65,7 +54,7 @@ def __del__(self):
sys.exit(0)
try:
# noinspection PyUnresolvedReferences
portable_arg = sys.argv[1] if not PYTHON2 else sys.argv[1].decode("mbcs")
portable_arg = sys.argv[1]
PORTABLE = portable_arg == "-p"
except IndexError: # no arguments in the call
pass
Expand All @@ -86,7 +75,7 @@ def __del__(self):
import socket
app_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
# Create an abstract socket, by prefixing it with null.
app_socket.bind(str("\0{}_lock_port".format(APP_NAME)))
app_socket.bind(str(f"\0{APP_NAME}_lock_port"))
except socket.error: # port in use - another instance is running
sys.exit(0)
SETTINGS_DIR = join(expanduser("~"), ".config", APP_NAME)
Expand All @@ -96,10 +85,10 @@ def __del__(self):
def except_hook(class_type, value, trace_back):
""" Print the error to a log file
"""
name = join(SETTINGS_DIR, "error_log_{}.txt".format(time.strftime(str("%Y-%m-%d"))))
name = join(SETTINGS_DIR, f"error_log_{time.strftime(str('%Y-%m-%d'))}.txt")
with open(name, "a", encoding="utf8") as log:
log.write("\nCrash@{}\n".format(time.strftime(str("%Y-%m-%d %H:%M:%S"))))
traceback.print_exception(class_type, value, trace_back, file=c_open(name, str("a")))
log.write(f"\nCrash@{time.strftime(str('%Y-%m-%d %H:%M:%S'))}\n")
traceback.print_exception(class_type, value, trace_back, file=open(name, str("a")))
sys.__excepthook__(class_type, value, trace_back)


Expand All @@ -108,14 +97,13 @@ def except_hook(class_type, value, trace_back):
# noinspection PyBroadException
try:
with gzip.GzipFile(join(SETTINGS_DIR, "settings.json.gz")) as settings:
j_text = settings.read() if PYTHON2 else settings.read().decode("utf8")
app_config = json.loads(j_text)
app_config = json.loads(settings.read().decode("utf8"))
except Exception: # IOError on first run or everything else
app_config = {}
FIRST_RUN = True


BOOKS_VIEW, HIGHLIGHTS_VIEW = range(2) # app views
BOOKS_VIEW, HIGHLIGHTS_VIEW, SYNC_VIEW = range(3) # app views
CHANGE_DB, NEW_DB, RELOAD_DB = range(3) # db change mode
(TITLE, AUTHOR, TYPE, PERCENT, RATING,
HIGH_COUNT, MODIFIED, PATH) = range(8) # file_table columns
Expand All @@ -125,14 +113,24 @@ def except_hook(class_type, value, trace_back):
(MANY_TEXT, ONE_TEXT, MANY_HTML, ONE_HTML,
MANY_CSV, ONE_CSV, MANY_MD, ONE_MD) = range(8) # save_actions
DB_MD5, DB_DATE, DB_PATH, DB_DATA = range(4) # db data (columns)
FILTER_ALL, FILTER_HIGH, FILTER_COMM, FILTER_TITLES = range(4) # db data (columns)
FILTER_ALL, FILTER_HIGH, FILTER_COMM, FILTER_TITLES = range(4) # filter type
(THEME_NONE_OLD, THEME_NONE_NEW, THEME_DARK_OLD, THEME_DARK_NEW,
THEME_LIGHT_OLD, THEME_LIGHT_NEW) = range(6) # theme idx
ACT_PAGE, ACT_DATE, ACT_TEXT, ACT_CHAPTER, ACT_COMMENT = range(5) # show items actions


NO_TITLE = _("NO TITLE FOUND")
NO_AUTHOR = _("NO AUTHOR FOUND")
OLD_TYPE = _("OLD TYPE FILE")
DO_NOT_SHOW = _("Don't show this again")
DB_VERSION = 0
DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
TOOLTIP_MERGE = _("Merge the highlights from the same book in two different\ndevices, "
"and/or sync their reading position.\nActivated only if two entries "
"of the same book are selected.")
TOOLTIP_SYNC = _("Start the sync process for all enabled groups")
SYNC_FILE = join(SETTINGS_DIR, "sync_groups.json")

CSV_HEAD = "Title\tAuthors\tPage\tDate\tChapter\tHighlight\tComment\n"
CSV_KEYS = ["title", "authors", "page", "date", "chapter", "text", "comment"]
HTML_HEAD = """<!DOCTYPE html>
Expand Down

0 comments on commit e5931bc

Please sign in to comment.